all ws subcommands propagate tls options to servers (unimplemented) or ws or http client (implemented) (contributed by Matt DeBoer)
This commit is contained in:
parent
0539d2df2e
commit
58d6e4bb26
@ -1 +1 @@
|
|||||||
6.3.3
|
6.3.4
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [6.3.4] - 2019-09-30
|
||||||
|
|
||||||
|
- all ws subcommands propagate tls options to servers (unimplemented) or ws or http client (implemented) (contributed by Matt DeBoer)
|
||||||
|
|
||||||
## [6.3.3] - 2019-09-30
|
## [6.3.3] - 2019-09-30
|
||||||
|
|
||||||
- ws has a --version option
|
- ws has a --version option
|
||||||
|
@ -299,4 +299,9 @@ namespace ix
|
|||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SocketServer::setTLSOptions(const SocketTLSOptions& socketTLSOptions)
|
||||||
|
{
|
||||||
|
_socketTLSOptions = socketTLSOptions;
|
||||||
|
}
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "IXConnectionState.h"
|
#include "IXConnectionState.h"
|
||||||
|
#include "IXSocketTLSOptions.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -51,6 +52,8 @@ namespace ix
|
|||||||
std::pair<bool, std::string> listen();
|
std::pair<bool, std::string> listen();
|
||||||
void wait();
|
void wait();
|
||||||
|
|
||||||
|
void setTLSOptions(const SocketTLSOptions& socketTLSOptions);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Logging
|
// Logging
|
||||||
void logError(const std::string& str);
|
void logError(const std::string& str);
|
||||||
@ -99,5 +102,7 @@ namespace ix
|
|||||||
// Returns true if all connection threads are joined
|
// Returns true if all connection threads are joined
|
||||||
void closeTerminatedThreads();
|
void closeTerminatedThreads();
|
||||||
size_t getConnectionsThreadsCount();
|
size_t getConnectionsThreadsCount();
|
||||||
|
|
||||||
|
SocketTLSOptions _socketTLSOptions;
|
||||||
};
|
};
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "6.3.3"
|
#define IX_WEBSOCKET_VERSION "6.3.4"
|
||||||
|
5
makefile
5
makefile
@ -12,11 +12,14 @@ brew:
|
|||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j 4 install)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j 4 install)
|
||||||
|
|
||||||
ws:
|
ws:
|
||||||
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_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 .. ; make -j 4)
|
||||||
|
|
||||||
ws_openssl:
|
ws_openssl:
|
||||||
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_OPEN_SSL=1 .. ; make -j 4)
|
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_OPEN_SSL=1 .. ; make -j 4)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
xargs rm -fv < build/install_manifest.txt
|
xargs rm -fv < build/install_manifest.txt
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ namespace ix
|
|||||||
std::cout << "Listening on " << hostname << ":" << port << std::endl;
|
std::cout << "Listening on " << hostname << ":" << port << std::endl;
|
||||||
|
|
||||||
ix::WebSocketServer server(port, hostname);
|
ix::WebSocketServer server(port, hostname);
|
||||||
|
server.setTLSOptions(tlsOptions);
|
||||||
|
|
||||||
server.setOnConnectionCallback([&server](std::shared_ptr<WebSocket> webSocket,
|
server.setOnConnectionCallback([&server](std::shared_ptr<WebSocket> webSocket,
|
||||||
std::shared_ptr<ConnectionState> connectionState) {
|
std::shared_ptr<ConnectionState> connectionState) {
|
||||||
|
@ -22,7 +22,8 @@ namespace ix
|
|||||||
bool disableAutomaticReconnection,
|
bool disableAutomaticReconnection,
|
||||||
bool disablePerMessageDeflate,
|
bool disablePerMessageDeflate,
|
||||||
bool binaryMode,
|
bool binaryMode,
|
||||||
uint32_t maxWaitBetweenReconnectionRetries);
|
uint32_t maxWaitBetweenReconnectionRetries,
|
||||||
|
const ix::SocketTLSOptions& tlsOptions);
|
||||||
|
|
||||||
void subscribe(const std::string& channel);
|
void subscribe(const std::string& channel);
|
||||||
void start();
|
void start();
|
||||||
@ -46,7 +47,8 @@ namespace ix
|
|||||||
bool disableAutomaticReconnection,
|
bool disableAutomaticReconnection,
|
||||||
bool disablePerMessageDeflate,
|
bool disablePerMessageDeflate,
|
||||||
bool binaryMode,
|
bool binaryMode,
|
||||||
uint32_t maxWaitBetweenReconnectionRetries)
|
uint32_t maxWaitBetweenReconnectionRetries,
|
||||||
|
const ix::SocketTLSOptions& tlsOptions)
|
||||||
: _url(url)
|
: _url(url)
|
||||||
, _disablePerMessageDeflate(disablePerMessageDeflate)
|
, _disablePerMessageDeflate(disablePerMessageDeflate)
|
||||||
, _binaryMode(binaryMode)
|
, _binaryMode(binaryMode)
|
||||||
@ -56,6 +58,7 @@ namespace ix
|
|||||||
_webSocket.disableAutomaticReconnection();
|
_webSocket.disableAutomaticReconnection();
|
||||||
}
|
}
|
||||||
_webSocket.setMaxWaitBetweenReconnectionRetries(maxWaitBetweenReconnectionRetries);
|
_webSocket.setMaxWaitBetweenReconnectionRetries(maxWaitBetweenReconnectionRetries);
|
||||||
|
_webSocket.setTLSOptions(tlsOptions);
|
||||||
|
|
||||||
_headers = parseHeaders(headers);
|
_headers = parseHeaders(headers);
|
||||||
}
|
}
|
||||||
@ -196,7 +199,8 @@ namespace ix
|
|||||||
disableAutomaticReconnection,
|
disableAutomaticReconnection,
|
||||||
disablePerMessageDeflate,
|
disablePerMessageDeflate,
|
||||||
binaryMode,
|
binaryMode,
|
||||||
maxWaitBetweenReconnectionRetries);
|
maxWaitBetweenReconnectionRetries,
|
||||||
|
tlsOptions);
|
||||||
webSocketChat.start();
|
webSocketChat.start();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -18,6 +18,7 @@ namespace ix
|
|||||||
std::cout << "Listening on " << hostname << ":" << port << std::endl;
|
std::cout << "Listening on " << hostname << ":" << port << std::endl;
|
||||||
|
|
||||||
ix::WebSocketServer server(port, hostname);
|
ix::WebSocketServer server(port, hostname);
|
||||||
|
server.setTLSOptions(tlsOptions);
|
||||||
|
|
||||||
server.setOnConnectionCallback(
|
server.setOnConnectionCallback(
|
||||||
[greetings](std::shared_ptr<ix::WebSocket> webSocket,
|
[greetings](std::shared_ptr<ix::WebSocket> webSocket,
|
||||||
|
@ -22,6 +22,7 @@ namespace ix
|
|||||||
spdlog::info("Listening on {}:{}", hostname, port);
|
spdlog::info("Listening on {}:{}", hostname, port);
|
||||||
|
|
||||||
ix::HttpServer server(port, hostname);
|
ix::HttpServer server(port, hostname);
|
||||||
|
server.setTLSOptions(tlsOptions);
|
||||||
|
|
||||||
if (redirect)
|
if (redirect)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,8 @@ namespace ix
|
|||||||
class WebSocketPingPong
|
class WebSocketPingPong
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WebSocketPingPong(const std::string& _url);
|
WebSocketPingPong(const std::string& _url,
|
||||||
|
const ix::SocketTLSOptions& tlsOptions);
|
||||||
|
|
||||||
void subscribe(const std::string& channel);
|
void subscribe(const std::string& channel);
|
||||||
void start();
|
void start();
|
||||||
@ -31,10 +32,11 @@ namespace ix
|
|||||||
void log(const std::string& msg);
|
void log(const std::string& msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
WebSocketPingPong::WebSocketPingPong(const std::string& url)
|
WebSocketPingPong::WebSocketPingPong(const std::string& url,
|
||||||
|
const ix::SocketTLSOptions& tlsOptions)
|
||||||
: _url(url)
|
: _url(url)
|
||||||
{
|
{
|
||||||
;
|
_webSocket.setTLSOptions(tlsOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketPingPong::log(const std::string& msg)
|
void WebSocketPingPong::log(const std::string& msg)
|
||||||
@ -127,7 +129,7 @@ namespace ix
|
|||||||
int ws_ping_pong_main(const std::string& url, const ix::SocketTLSOptions& tlsOptions)
|
int ws_ping_pong_main(const std::string& url, const ix::SocketTLSOptions& tlsOptions)
|
||||||
{
|
{
|
||||||
std::cout << "Type Ctrl-D to exit prompt..." << std::endl;
|
std::cout << "Type Ctrl-D to exit prompt..." << std::endl;
|
||||||
WebSocketPingPong webSocketPingPong(url);
|
WebSocketPingPong webSocketPingPong(url, tlsOptions);
|
||||||
webSocketPingPong.start();
|
webSocketPingPong.start();
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
|
@ -26,7 +26,8 @@ namespace ix
|
|||||||
class WebSocketReceiver
|
class WebSocketReceiver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WebSocketReceiver(const std::string& _url, bool enablePerMessageDeflate, int delayMs);
|
WebSocketReceiver(const std::string& _url, bool enablePerMessageDeflate, int delayMs,
|
||||||
|
const ix::SocketTLSOptions& tlsOptions);
|
||||||
|
|
||||||
void subscribe(const std::string& channel);
|
void subscribe(const std::string& channel);
|
||||||
void start();
|
void start();
|
||||||
@ -54,13 +55,15 @@ namespace ix
|
|||||||
|
|
||||||
WebSocketReceiver::WebSocketReceiver(const std::string& url,
|
WebSocketReceiver::WebSocketReceiver(const std::string& url,
|
||||||
bool enablePerMessageDeflate,
|
bool enablePerMessageDeflate,
|
||||||
int delayMs)
|
int delayMs,
|
||||||
|
const ix::SocketTLSOptions& tlsOptions)
|
||||||
: _url(url)
|
: _url(url)
|
||||||
, _enablePerMessageDeflate(enablePerMessageDeflate)
|
, _enablePerMessageDeflate(enablePerMessageDeflate)
|
||||||
, _delayMs(delayMs)
|
, _delayMs(delayMs)
|
||||||
, _receivedFragmentCounter(0)
|
, _receivedFragmentCounter(0)
|
||||||
{
|
{
|
||||||
_webSocket.disableAutomaticReconnection();
|
_webSocket.disableAutomaticReconnection();
|
||||||
|
_webSocket.setTLSOptions(tlsOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketReceiver::stop()
|
void WebSocketReceiver::stop()
|
||||||
@ -244,7 +247,7 @@ namespace ix
|
|||||||
int delayMs,
|
int delayMs,
|
||||||
const ix::SocketTLSOptions& tlsOptions)
|
const ix::SocketTLSOptions& tlsOptions)
|
||||||
{
|
{
|
||||||
WebSocketReceiver webSocketReceiver(url, enablePerMessageDeflate, delayMs);
|
WebSocketReceiver webSocketReceiver(url, enablePerMessageDeflate, delayMs, tlsOptions);
|
||||||
webSocketReceiver.start();
|
webSocketReceiver.start();
|
||||||
|
|
||||||
webSocketReceiver.waitForConnection();
|
webSocketReceiver.waitForConnection();
|
||||||
|
@ -26,7 +26,9 @@ namespace ix
|
|||||||
class WebSocketSender
|
class WebSocketSender
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WebSocketSender(const std::string& _url, bool enablePerMessageDeflate);
|
WebSocketSender(const std::string& _url,
|
||||||
|
bool enablePerMessageDeflate,
|
||||||
|
const ix::SocketTLSOptions& tlsOptions);
|
||||||
|
|
||||||
void subscribe(const std::string& channel);
|
void subscribe(const std::string& channel);
|
||||||
void start();
|
void start();
|
||||||
@ -49,11 +51,14 @@ namespace ix
|
|||||||
void log(const std::string& msg);
|
void log(const std::string& msg);
|
||||||
};
|
};
|
||||||
|
|
||||||
WebSocketSender::WebSocketSender(const std::string& url, bool enablePerMessageDeflate)
|
WebSocketSender::WebSocketSender(const std::string& url,
|
||||||
|
bool enablePerMessageDeflate,
|
||||||
|
const ix::SocketTLSOptions& tlsOptions)
|
||||||
: _url(url)
|
: _url(url)
|
||||||
, _enablePerMessageDeflate(enablePerMessageDeflate)
|
, _enablePerMessageDeflate(enablePerMessageDeflate)
|
||||||
{
|
{
|
||||||
_webSocket.disableAutomaticReconnection();
|
_webSocket.disableAutomaticReconnection();
|
||||||
|
_webSocket.setTLSOptions(tlsOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebSocketSender::stop()
|
void WebSocketSender::stop()
|
||||||
@ -268,7 +273,7 @@ namespace ix
|
|||||||
bool throttle,
|
bool throttle,
|
||||||
const ix::SocketTLSOptions& tlsOptions)
|
const ix::SocketTLSOptions& tlsOptions)
|
||||||
{
|
{
|
||||||
WebSocketSender webSocketSender(url, enablePerMessageDeflate);
|
WebSocketSender webSocketSender(url, enablePerMessageDeflate, tlsOptions);
|
||||||
webSocketSender.start();
|
webSocketSender.start();
|
||||||
|
|
||||||
webSocketSender.waitForConnection();
|
webSocketSender.waitForConnection();
|
||||||
|
@ -17,6 +17,7 @@ namespace ix
|
|||||||
std::cout << "ws_transfer: Listening on " << hostname << ":" << port << std::endl;
|
std::cout << "ws_transfer: Listening on " << hostname << ":" << port << std::endl;
|
||||||
|
|
||||||
ix::WebSocketServer server(port, hostname);
|
ix::WebSocketServer server(port, hostname);
|
||||||
|
server.setTLSOptions(tlsOptions);
|
||||||
|
|
||||||
server.setOnConnectionCallback([&server](std::shared_ptr<ix::WebSocket> webSocket,
|
server.setOnConnectionCallback([&server](std::shared_ptr<ix::WebSocket> webSocket,
|
||||||
std::shared_ptr<ConnectionState> connectionState) {
|
std::shared_ptr<ConnectionState> connectionState) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user