all ws subcommands propagate tls options to servers (unimplemented) or ws or http client (implemented) (contributed by Matt DeBoer)
This commit is contained in:
@ -17,6 +17,7 @@ namespace ix
|
||||
std::cout << "Listening on " << hostname << ":" << port << std::endl;
|
||||
|
||||
ix::WebSocketServer server(port, hostname);
|
||||
server.setTLSOptions(tlsOptions);
|
||||
|
||||
server.setOnConnectionCallback([&server](std::shared_ptr<WebSocket> webSocket,
|
||||
std::shared_ptr<ConnectionState> connectionState) {
|
||||
|
@ -22,7 +22,8 @@ namespace ix
|
||||
bool disableAutomaticReconnection,
|
||||
bool disablePerMessageDeflate,
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries);
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
|
||||
void subscribe(const std::string& channel);
|
||||
void start();
|
||||
@ -46,7 +47,8 @@ namespace ix
|
||||
bool disableAutomaticReconnection,
|
||||
bool disablePerMessageDeflate,
|
||||
bool binaryMode,
|
||||
uint32_t maxWaitBetweenReconnectionRetries)
|
||||
uint32_t maxWaitBetweenReconnectionRetries,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
: _url(url)
|
||||
, _disablePerMessageDeflate(disablePerMessageDeflate)
|
||||
, _binaryMode(binaryMode)
|
||||
@ -56,6 +58,7 @@ namespace ix
|
||||
_webSocket.disableAutomaticReconnection();
|
||||
}
|
||||
_webSocket.setMaxWaitBetweenReconnectionRetries(maxWaitBetweenReconnectionRetries);
|
||||
_webSocket.setTLSOptions(tlsOptions);
|
||||
|
||||
_headers = parseHeaders(headers);
|
||||
}
|
||||
@ -196,7 +199,8 @@ namespace ix
|
||||
disableAutomaticReconnection,
|
||||
disablePerMessageDeflate,
|
||||
binaryMode,
|
||||
maxWaitBetweenReconnectionRetries);
|
||||
maxWaitBetweenReconnectionRetries,
|
||||
tlsOptions);
|
||||
webSocketChat.start();
|
||||
|
||||
while (true)
|
||||
|
@ -18,6 +18,7 @@ namespace ix
|
||||
std::cout << "Listening on " << hostname << ":" << port << std::endl;
|
||||
|
||||
ix::WebSocketServer server(port, hostname);
|
||||
server.setTLSOptions(tlsOptions);
|
||||
|
||||
server.setOnConnectionCallback(
|
||||
[greetings](std::shared_ptr<ix::WebSocket> webSocket,
|
||||
|
@ -22,6 +22,7 @@ namespace ix
|
||||
spdlog::info("Listening on {}:{}", hostname, port);
|
||||
|
||||
ix::HttpServer server(port, hostname);
|
||||
server.setTLSOptions(tlsOptions);
|
||||
|
||||
if (redirect)
|
||||
{
|
||||
|
@ -15,7 +15,8 @@ namespace ix
|
||||
class WebSocketPingPong
|
||||
{
|
||||
public:
|
||||
WebSocketPingPong(const std::string& _url);
|
||||
WebSocketPingPong(const std::string& _url,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
|
||||
void subscribe(const std::string& channel);
|
||||
void start();
|
||||
@ -31,10 +32,11 @@ namespace ix
|
||||
void log(const std::string& msg);
|
||||
};
|
||||
|
||||
WebSocketPingPong::WebSocketPingPong(const std::string& url)
|
||||
WebSocketPingPong::WebSocketPingPong(const std::string& url,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
: _url(url)
|
||||
{
|
||||
;
|
||||
_webSocket.setTLSOptions(tlsOptions);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
std::cout << "Type Ctrl-D to exit prompt..." << std::endl;
|
||||
WebSocketPingPong webSocketPingPong(url);
|
||||
WebSocketPingPong webSocketPingPong(url, tlsOptions);
|
||||
webSocketPingPong.start();
|
||||
|
||||
while (true)
|
||||
|
@ -26,7 +26,8 @@ namespace ix
|
||||
class WebSocketReceiver
|
||||
{
|
||||
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 start();
|
||||
@ -54,13 +55,15 @@ namespace ix
|
||||
|
||||
WebSocketReceiver::WebSocketReceiver(const std::string& url,
|
||||
bool enablePerMessageDeflate,
|
||||
int delayMs)
|
||||
int delayMs,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
: _url(url)
|
||||
, _enablePerMessageDeflate(enablePerMessageDeflate)
|
||||
, _delayMs(delayMs)
|
||||
, _receivedFragmentCounter(0)
|
||||
{
|
||||
_webSocket.disableAutomaticReconnection();
|
||||
_webSocket.setTLSOptions(tlsOptions);
|
||||
}
|
||||
|
||||
void WebSocketReceiver::stop()
|
||||
@ -244,7 +247,7 @@ namespace ix
|
||||
int delayMs,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
{
|
||||
WebSocketReceiver webSocketReceiver(url, enablePerMessageDeflate, delayMs);
|
||||
WebSocketReceiver webSocketReceiver(url, enablePerMessageDeflate, delayMs, tlsOptions);
|
||||
webSocketReceiver.start();
|
||||
|
||||
webSocketReceiver.waitForConnection();
|
||||
|
@ -26,7 +26,9 @@ namespace ix
|
||||
class WebSocketSender
|
||||
{
|
||||
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 start();
|
||||
@ -49,11 +51,14 @@ namespace ix
|
||||
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)
|
||||
, _enablePerMessageDeflate(enablePerMessageDeflate)
|
||||
{
|
||||
_webSocket.disableAutomaticReconnection();
|
||||
_webSocket.setTLSOptions(tlsOptions);
|
||||
}
|
||||
|
||||
void WebSocketSender::stop()
|
||||
@ -268,7 +273,7 @@ namespace ix
|
||||
bool throttle,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
{
|
||||
WebSocketSender webSocketSender(url, enablePerMessageDeflate);
|
||||
WebSocketSender webSocketSender(url, enablePerMessageDeflate, tlsOptions);
|
||||
webSocketSender.start();
|
||||
|
||||
webSocketSender.waitForConnection();
|
||||
|
@ -17,6 +17,7 @@ namespace ix
|
||||
std::cout << "ws_transfer: Listening on " << hostname << ":" << port << std::endl;
|
||||
|
||||
ix::WebSocketServer server(port, hostname);
|
||||
server.setTLSOptions(tlsOptions);
|
||||
|
||||
server.setOnConnectionCallback([&server](std::shared_ptr<ix::WebSocket> webSocket,
|
||||
std::shared_ptr<ConnectionState> connectionState) {
|
||||
|
Reference in New Issue
Block a user