Compare commits
8 Commits
v11.2.8
...
feature/pr
Author | SHA1 | Date | |
---|---|---|---|
0c5a4af722 | |||
3baf59a031 | |||
b5804c2082 | |||
30bcddb99f | |||
47fd04e210 | |||
4f5b0c4f07 | |||
c2d497abc5 | |||
bbe2ae6dd3 |
1
.github/workflows/unittest_linux.yml
vendored
1
.github/workflows/unittest_linux.yml
vendored
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linux:
|
linux:
|
||||||
|
1
.github/workflows/unittest_linux_asan.yml
vendored
1
.github/workflows/unittest_linux_asan.yml
vendored
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
linux:
|
linux:
|
||||||
|
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
mac_tsan_mbedtls:
|
mac_tsan_mbedtls:
|
||||||
|
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
mac_tsan_openssl:
|
mac_tsan_openssl:
|
||||||
|
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
mac_tsan_sectransport:
|
mac_tsan_sectransport:
|
||||||
|
1
.github/workflows/unittest_uwp.yml
vendored
1
.github/workflows/unittest_uwp.yml
vendored
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
uwp:
|
uwp:
|
||||||
|
1
.github/workflows/unittest_windows.yml
vendored
1
.github/workflows/unittest_windows.yml
vendored
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
windows:
|
windows:
|
||||||
|
1
.github/workflows/unittest_windows_gcc.yml
vendored
1
.github/workflows/unittest_windows_gcc.yml
vendored
@ -3,6 +3,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- 'docs/**'
|
- 'docs/**'
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
windows:
|
windows:
|
||||||
|
@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [11.2.10] - 2021-07-27
|
||||||
|
|
||||||
|
(ws) bump CLI command line parsing library from 1.8 to 2.0
|
||||||
|
|
||||||
|
## [11.2.9] - 2021-06-08
|
||||||
|
|
||||||
|
(ws) ws connect has a -g option to gzip decompress messages for API such as the websocket Huobi Global.
|
||||||
|
|
||||||
|
## [11.2.8] - 2021-06-03
|
||||||
|
|
||||||
|
(websocket client + server) WebSocketMessage class tweak to fix unsafe patterns
|
||||||
|
|
||||||
## [11.2.7] - 2021-05-27
|
## [11.2.7] - 2021-05-27
|
||||||
|
|
||||||
(websocket server) Handle and accept firefox browser special upgrade value (keep-alive, Upgrade)
|
(websocket server) Handle and accept firefox browser special upgrade value (keep-alive, Upgrade)
|
||||||
|
@ -190,14 +190,14 @@ namespace ix
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set a default Accept header if none is present
|
// Set a default Accept header if none is present
|
||||||
if (headers.find("Accept") == headers.end())
|
if (args->extraHeaders.find("Accept") == args->extraHeaders.end())
|
||||||
{
|
{
|
||||||
ss << "Accept: */*"
|
ss << "Accept: */*"
|
||||||
<< "\r\n";
|
<< "\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a default User agent if none is present
|
// Set a default User agent if none is present
|
||||||
if (headers.find("User-Agent") == headers.end())
|
if (args->extraHeaders.find("User-Agent") == args->extraHeaders.end())
|
||||||
{
|
{
|
||||||
ss << "User-Agent: " << userAgent() << "\r\n";
|
ss << "User-Agent: " << userAgent() << "\r\n";
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace ix
|
|||||||
_extraHeaders = headers;
|
_extraHeaders = headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& WebSocket::getUrl() const
|
const std::string WebSocket::getUrl() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(_configMutex);
|
std::lock_guard<std::mutex> lock(_configMutex);
|
||||||
return _url;
|
return _url;
|
||||||
@ -94,7 +94,7 @@ namespace ix
|
|||||||
_socketTLSOptions = socketTLSOptions;
|
_socketTLSOptions = socketTLSOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WebSocketPerMessageDeflateOptions& WebSocket::getPerMessageDeflateOptions() const
|
const WebSocketPerMessageDeflateOptions WebSocket::getPerMessageDeflateOptions() const
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(_configMutex);
|
std::lock_guard<std::mutex> lock(_configMutex);
|
||||||
return _perMessageDeflateOptions;
|
return _perMessageDeflateOptions;
|
||||||
|
@ -92,8 +92,8 @@ namespace ix
|
|||||||
ReadyState getReadyState() const;
|
ReadyState getReadyState() const;
|
||||||
static std::string readyStateToString(ReadyState readyState);
|
static std::string readyStateToString(ReadyState readyState);
|
||||||
|
|
||||||
const std::string& getUrl() const;
|
const std::string getUrl() const;
|
||||||
const WebSocketPerMessageDeflateOptions& getPerMessageDeflateOptions() const;
|
const WebSocketPerMessageDeflateOptions getPerMessageDeflateOptions() const;
|
||||||
int getPingInterval() const;
|
int getPingInterval() const;
|
||||||
size_t bufferedAmount() const;
|
size_t bufferedAmount() const;
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@ namespace ix
|
|||||||
{
|
{
|
||||||
/// Default values as defined in the RFC
|
/// Default values as defined in the RFC
|
||||||
const uint8_t WebSocketPerMessageDeflateOptions::kDefaultServerMaxWindowBits = 15;
|
const uint8_t WebSocketPerMessageDeflateOptions::kDefaultServerMaxWindowBits = 15;
|
||||||
static const int minServerMaxWindowBits = 8;
|
static const uint8_t minServerMaxWindowBits = 8;
|
||||||
static const int maxServerMaxWindowBits = 15;
|
static const uint8_t maxServerMaxWindowBits = 15;
|
||||||
|
|
||||||
const uint8_t WebSocketPerMessageDeflateOptions::kDefaultClientMaxWindowBits = 15;
|
const uint8_t WebSocketPerMessageDeflateOptions::kDefaultClientMaxWindowBits = 15;
|
||||||
static const int minClientMaxWindowBits = 8;
|
static const uint8_t minClientMaxWindowBits = 8;
|
||||||
static const int maxClientMaxWindowBits = 15;
|
static const uint8_t maxClientMaxWindowBits = 15;
|
||||||
|
|
||||||
WebSocketPerMessageDeflateOptions::WebSocketPerMessageDeflateOptions(
|
WebSocketPerMessageDeflateOptions::WebSocketPerMessageDeflateOptions(
|
||||||
bool enabled,
|
bool enabled,
|
||||||
@ -85,11 +85,7 @@ namespace ix
|
|||||||
|
|
||||||
if (startsWith(token, "server_max_window_bits="))
|
if (startsWith(token, "server_max_window_bits="))
|
||||||
{
|
{
|
||||||
std::string val = token.substr(token.find_last_of("=") + 1);
|
uint8_t x = strtol(token.substr(token.find_last_of("=") + 1).c_str(), nullptr, 10);
|
||||||
std::stringstream ss;
|
|
||||||
ss << val;
|
|
||||||
int x;
|
|
||||||
ss >> x;
|
|
||||||
|
|
||||||
// Sanitize values to be in the proper range [8, 15] in
|
// Sanitize values to be in the proper range [8, 15] in
|
||||||
// case a server would give us bogus values
|
// case a server would give us bogus values
|
||||||
@ -99,11 +95,7 @@ namespace ix
|
|||||||
|
|
||||||
if (startsWith(token, "client_max_window_bits="))
|
if (startsWith(token, "client_max_window_bits="))
|
||||||
{
|
{
|
||||||
std::string val = token.substr(token.find_last_of("=") + 1);
|
uint8_t x = strtol(token.substr(token.find_last_of("=") + 1).c_str(), nullptr, 10);
|
||||||
std::stringstream ss;
|
|
||||||
ss << val;
|
|
||||||
int x;
|
|
||||||
ss >> x;
|
|
||||||
|
|
||||||
// Sanitize values to be in the proper range [8, 15] in
|
// Sanitize values to be in the proper range [8, 15] in
|
||||||
// case a server would give us bogus values
|
// case a server would give us bogus values
|
||||||
|
@ -39,8 +39,8 @@ namespace ix
|
|||||||
bool _enabled;
|
bool _enabled;
|
||||||
bool _clientNoContextTakeover;
|
bool _clientNoContextTakeover;
|
||||||
bool _serverNoContextTakeover;
|
bool _serverNoContextTakeover;
|
||||||
int _clientMaxWindowBits;
|
uint8_t _clientMaxWindowBits;
|
||||||
int _serverMaxWindowBits;
|
uint8_t _serverMaxWindowBits;
|
||||||
|
|
||||||
void sanitizeClientMaxWindowBits();
|
void sanitizeClientMaxWindowBits();
|
||||||
};
|
};
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "11.2.7"
|
#define IX_WEBSOCKET_VERSION "11.2.10"
|
||||||
|
30
makefile.dev
30
makefile.dev
@ -22,37 +22,37 @@ install: brew
|
|||||||
# Default rule does not use python as that requires first time users to have Python3 installed
|
# Default rule does not use python as that requires first time users to have Python3 installed
|
||||||
#
|
#
|
||||||
brew:
|
brew:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; ninja install)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=OFF -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; ninja install)
|
||||||
|
|
||||||
# Docker default target. We've had problems with OpenSSL and TLS 1.3 (on the
|
# Docker default target. We've had problems with OpenSSL and TLS 1.3 (on the
|
||||||
# server side ?) and I can't work-around it easily, so we're using mbedtls on
|
# server side ?) and I can't work-around it easily, so we're using mbedtls on
|
||||||
# Linux for the SSL backend, which works great.
|
# Linux for the SSL backend, which works great.
|
||||||
ws_mbedtls_install:
|
ws_mbedtls_install:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_ZLIB=OFF -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; ninja install)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=ON -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_ZLIB=OFF -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; ninja install)
|
||||||
|
|
||||||
ws:
|
ws:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. && ninja install)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. && ninja install)
|
||||||
|
|
||||||
ws_unity:
|
ws_unity:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. && ninja install)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=ON -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. && ninja install)
|
||||||
|
|
||||||
ws_install:
|
ws_install:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_TLS=1 -DUSE_WS=1 .. -DUSE_TEST=0 && ninja install)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_TLS=1 -DUSE_WS=1 .. -DUSE_TEST=0 && ninja install)
|
||||||
|
|
||||||
ws_install_release:
|
ws_install_release:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_TLS=1 -DUSE_WS=1 .. -DUSE_TEST=0 && ninja install)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_TLS=1 -DUSE_WS=1 .. -DUSE_TEST=0 && ninja install)
|
||||||
|
|
||||||
ws_openssl_install:
|
ws_openssl_install:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_OPEN_SSL=1 .. ; ninja install)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_OPEN_SSL=1 .. ; ninja install)
|
||||||
|
|
||||||
ws_mbedtls:
|
ws_mbedtls:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j 4)
|
mkdir -p build && (cd build ; cmake -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j 4)
|
||||||
|
|
||||||
ws_no_ssl:
|
ws_no_ssl:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_WS=1 .. ; make -j 4)
|
mkdir -p build && (cd build ; cmake -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_BUILD_TYPE=Debug -DUSE_WS=1 .. ; make -j 4)
|
||||||
|
|
||||||
ws_no_python:
|
ws_no_python:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j4 install)
|
mkdir -p build && (cd build ; cmake -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_BUILD_TYPE=MinSizeRel -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j4 install)
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
xargs rm -fv < build/install_manifest.txt
|
xargs rm -fv < build/install_manifest.txt
|
||||||
@ -111,27 +111,27 @@ test_server:
|
|||||||
(cd test && npm i ws && node broadcast-server.js)
|
(cd test && npm i ws && node broadcast-server.js)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_TEST=1 ..)
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_TEST=1 ..)
|
||||||
(cd build ; ninja)
|
(cd build ; ninja)
|
||||||
(cd build ; ninja -v test)
|
(cd build ; ninja -v test)
|
||||||
|
|
||||||
test_asan:
|
test_asan:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer")
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer")
|
||||||
(cd build ; ninja)
|
(cd build ; ninja)
|
||||||
(cd build ; ctest -V .)
|
(cd build ; ctest -V .)
|
||||||
|
|
||||||
test_tsan_mbedtls:
|
test_tsan_mbedtls:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_MBED_TLS=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer")
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_MBED_TLS=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer")
|
||||||
(cd build ; ninja)
|
(cd build ; ninja)
|
||||||
(cd build ; ninja test)
|
(cd build ; ninja test)
|
||||||
|
|
||||||
test_tsan_openssl:
|
test_tsan_openssl:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja --DCMAKE_UNITY_BUILD=ON DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_OPENS_SSL=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer")
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_UNITY_BUILD=ON DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_OPENS_SSL=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer")
|
||||||
(cd build ; ninja)
|
(cd build ; ninja)
|
||||||
(cd build ; ninja test)
|
(cd build ; ninja test)
|
||||||
|
|
||||||
test_tsan_sectransport:
|
test_tsan_sectransport:
|
||||||
mkdir -p build && (cd build ; cmake -GNinja --DCMAKE_UNITY_BUILD=ON DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_OPENS_SSL=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer")
|
mkdir -p build && (cd build ; cmake -GNinja -DCMAKE_INSTALL_MESSAGE=LAZY -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_OPENS_SSL=1 -DUSE_TEST=1 .. -DCMAKE_C_FLAGS="-fsanitize=thread -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=thread -fno-omit-frame-pointer")
|
||||||
(cd build ; ninja)
|
(cd build ; ninja)
|
||||||
(cd build ; ninja test)
|
(cd build ; ninja test)
|
||||||
|
|
||||||
|
5444
third_party/cli11/CLI11.hpp
vendored
5444
third_party/cli11/CLI11.hpp
vendored
File diff suppressed because it is too large
Load Diff
35
ws/ws.cpp
35
ws/ws.cpp
@ -632,7 +632,8 @@ namespace ix
|
|||||||
uint32_t maxWaitBetweenReconnectionRetries,
|
uint32_t maxWaitBetweenReconnectionRetries,
|
||||||
const ix::SocketTLSOptions& tlsOptions,
|
const ix::SocketTLSOptions& tlsOptions,
|
||||||
const std::string& subprotocol,
|
const std::string& subprotocol,
|
||||||
int pingIntervalSecs);
|
int pingIntervalSecs,
|
||||||
|
bool decompressGzipMessages);
|
||||||
|
|
||||||
void subscribe(const std::string& channel);
|
void subscribe(const std::string& channel);
|
||||||
void start();
|
void start();
|
||||||
@ -657,6 +658,7 @@ namespace ix
|
|||||||
bool _binaryMode;
|
bool _binaryMode;
|
||||||
std::atomic<int> _receivedBytes;
|
std::atomic<int> _receivedBytes;
|
||||||
std::atomic<int> _sentBytes;
|
std::atomic<int> _sentBytes;
|
||||||
|
bool _decompressGzipMessages;
|
||||||
|
|
||||||
void log(const std::string& msg);
|
void log(const std::string& msg);
|
||||||
WebSocketHttpHeaders parseHeaders(const std::string& data);
|
WebSocketHttpHeaders parseHeaders(const std::string& data);
|
||||||
@ -670,12 +672,14 @@ namespace ix
|
|||||||
uint32_t maxWaitBetweenReconnectionRetries,
|
uint32_t maxWaitBetweenReconnectionRetries,
|
||||||
const ix::SocketTLSOptions& tlsOptions,
|
const ix::SocketTLSOptions& tlsOptions,
|
||||||
const std::string& subprotocol,
|
const std::string& subprotocol,
|
||||||
int pingIntervalSecs)
|
int pingIntervalSecs,
|
||||||
|
bool decompressGzipMessages)
|
||||||
: _url(url)
|
: _url(url)
|
||||||
, _disablePerMessageDeflate(disablePerMessageDeflate)
|
, _disablePerMessageDeflate(disablePerMessageDeflate)
|
||||||
, _binaryMode(binaryMode)
|
, _binaryMode(binaryMode)
|
||||||
, _receivedBytes(0)
|
, _receivedBytes(0)
|
||||||
, _sentBytes(0)
|
, _sentBytes(0)
|
||||||
|
, _decompressGzipMessages(decompressGzipMessages)
|
||||||
{
|
{
|
||||||
if (disableAutomaticReconnection)
|
if (disableAutomaticReconnection)
|
||||||
{
|
{
|
||||||
@ -784,7 +788,21 @@ namespace ix
|
|||||||
{
|
{
|
||||||
spdlog::info("Received {} bytes", msg->wireSize);
|
spdlog::info("Received {} bytes", msg->wireSize);
|
||||||
|
|
||||||
ss << "ws_connect: received message: " << msg->str;
|
std::string payload = msg->str;
|
||||||
|
if (_decompressGzipMessages)
|
||||||
|
{
|
||||||
|
std::string decompressedBytes;
|
||||||
|
if (gzipDecompress(payload, decompressedBytes))
|
||||||
|
{
|
||||||
|
payload = decompressedBytes;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
spdlog::error("Error decompressing: {}", payload);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ss << "ws_connect: received message: " << payload;
|
||||||
log(ss.str());
|
log(ss.str());
|
||||||
}
|
}
|
||||||
else if (msg->type == ix::WebSocketMessageType::Error)
|
else if (msg->type == ix::WebSocketMessageType::Error)
|
||||||
@ -837,7 +855,8 @@ namespace ix
|
|||||||
uint32_t maxWaitBetweenReconnectionRetries,
|
uint32_t maxWaitBetweenReconnectionRetries,
|
||||||
const ix::SocketTLSOptions& tlsOptions,
|
const ix::SocketTLSOptions& tlsOptions,
|
||||||
const std::string& subprotocol,
|
const std::string& subprotocol,
|
||||||
int pingIntervalSecs)
|
int pingIntervalSecs,
|
||||||
|
bool decompressGzipMessages)
|
||||||
{
|
{
|
||||||
std::cout << "Type Ctrl-D to exit prompt..." << std::endl;
|
std::cout << "Type Ctrl-D to exit prompt..." << std::endl;
|
||||||
WebSocketConnect webSocketChat(url,
|
WebSocketConnect webSocketChat(url,
|
||||||
@ -848,7 +867,8 @@ namespace ix
|
|||||||
maxWaitBetweenReconnectionRetries,
|
maxWaitBetweenReconnectionRetries,
|
||||||
tlsOptions,
|
tlsOptions,
|
||||||
subprotocol,
|
subprotocol,
|
||||||
pingIntervalSecs);
|
pingIntervalSecs,
|
||||||
|
decompressGzipMessages);
|
||||||
webSocketChat.start();
|
webSocketChat.start();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@ -2490,6 +2510,7 @@ int main(int argc, char** argv)
|
|||||||
uint32_t maxWaitBetweenReconnectionRetries = 10 * 1000; // 10 seconds
|
uint32_t maxWaitBetweenReconnectionRetries = 10 * 1000; // 10 seconds
|
||||||
int pingIntervalSecs = 30;
|
int pingIntervalSecs = 30;
|
||||||
int runCount = 1;
|
int runCount = 1;
|
||||||
|
bool decompressGzipMessages = false;
|
||||||
|
|
||||||
auto addGenericOptions = [&pidfile](CLI::App* app) {
|
auto addGenericOptions = [&pidfile](CLI::App* app) {
|
||||||
app->add_option("--pidfile", pidfile, "Pid file");
|
app->add_option("--pidfile", pidfile, "Pid file");
|
||||||
@ -2552,6 +2573,7 @@ int main(int argc, char** argv)
|
|||||||
"Max Wait Time between reconnection retries");
|
"Max Wait Time between reconnection retries");
|
||||||
connectApp->add_option("--ping_interval", pingIntervalSecs, "Interval between sending pings");
|
connectApp->add_option("--ping_interval", pingIntervalSecs, "Interval between sending pings");
|
||||||
connectApp->add_option("--subprotocol", subprotocol, "Subprotocol");
|
connectApp->add_option("--subprotocol", subprotocol, "Subprotocol");
|
||||||
|
connectApp->add_flag("-g", decompressGzipMessages, "Decompress gziped messages");
|
||||||
addGenericOptions(connectApp);
|
addGenericOptions(connectApp);
|
||||||
addTLSOptions(connectApp);
|
addTLSOptions(connectApp);
|
||||||
|
|
||||||
@ -2740,7 +2762,8 @@ int main(int argc, char** argv)
|
|||||||
maxWaitBetweenReconnectionRetries,
|
maxWaitBetweenReconnectionRetries,
|
||||||
tlsOptions,
|
tlsOptions,
|
||||||
subprotocol,
|
subprotocol,
|
||||||
pingIntervalSecs);
|
pingIntervalSecs,
|
||||||
|
decompressGzipMessages);
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("autoroute"))
|
else if (app.got_subcommand("autoroute"))
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user