diff --git a/DOCKER_VERSION b/DOCKER_VERSION index 7849b73d..8ac3c445 100644 --- a/DOCKER_VERSION +++ b/DOCKER_VERSION @@ -1 +1 @@ -6.3.3 +6.3.4 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d711f4ca..1813b585 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog 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 - ws has a --version option diff --git a/ixwebsocket/IXSocketServer.cpp b/ixwebsocket/IXSocketServer.cpp index ec634d28..a2535811 100644 --- a/ixwebsocket/IXSocketServer.cpp +++ b/ixwebsocket/IXSocketServer.cpp @@ -299,4 +299,9 @@ namespace ix std::this_thread::sleep_for(std::chrono::milliseconds(10)); } } + + void SocketServer::setTLSOptions(const SocketTLSOptions& socketTLSOptions) + { + _socketTLSOptions = socketTLSOptions; + } } // namespace ix diff --git a/ixwebsocket/IXSocketServer.h b/ixwebsocket/IXSocketServer.h index f48bb9bb..12f5a297 100644 --- a/ixwebsocket/IXSocketServer.h +++ b/ixwebsocket/IXSocketServer.h @@ -7,6 +7,7 @@ #pragma once #include "IXConnectionState.h" +#include "IXSocketTLSOptions.h" #include #include #include @@ -51,6 +52,8 @@ namespace ix std::pair listen(); void wait(); + void setTLSOptions(const SocketTLSOptions& socketTLSOptions); + protected: // Logging void logError(const std::string& str); @@ -99,5 +102,7 @@ namespace ix // Returns true if all connection threads are joined void closeTerminatedThreads(); size_t getConnectionsThreadsCount(); + + SocketTLSOptions _socketTLSOptions; }; } // namespace ix diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index b1c46364..7cf369dd 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "6.3.3" +#define IX_WEBSOCKET_VERSION "6.3.4" diff --git a/makefile b/makefile index 9cbf2418..c46e38d6 100644 --- a/makefile +++ b/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) 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: 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: xargs rm -fv < build/install_manifest.txt diff --git a/ws/ws_broadcast_server.cpp b/ws/ws_broadcast_server.cpp index 01a4a844..dc3165c2 100644 --- a/ws/ws_broadcast_server.cpp +++ b/ws/ws_broadcast_server.cpp @@ -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, std::shared_ptr connectionState) { diff --git a/ws/ws_connect.cpp b/ws/ws_connect.cpp index 5942e3ba..a5cc6004 100644 --- a/ws/ws_connect.cpp +++ b/ws/ws_connect.cpp @@ -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) diff --git a/ws/ws_echo_server.cpp b/ws/ws_echo_server.cpp index ac9a73e2..5f9fb63a 100644 --- a/ws/ws_echo_server.cpp +++ b/ws/ws_echo_server.cpp @@ -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 webSocket, diff --git a/ws/ws_httpd.cpp b/ws/ws_httpd.cpp index f588ea4f..2a8da3d2 100644 --- a/ws/ws_httpd.cpp +++ b/ws/ws_httpd.cpp @@ -22,6 +22,7 @@ namespace ix spdlog::info("Listening on {}:{}", hostname, port); ix::HttpServer server(port, hostname); + server.setTLSOptions(tlsOptions); if (redirect) { diff --git a/ws/ws_ping_pong.cpp b/ws/ws_ping_pong.cpp index b11dec1d..433cd95e 100644 --- a/ws/ws_ping_pong.cpp +++ b/ws/ws_ping_pong.cpp @@ -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) diff --git a/ws/ws_receive.cpp b/ws/ws_receive.cpp index 75587f8e..152ee76c 100644 --- a/ws/ws_receive.cpp +++ b/ws/ws_receive.cpp @@ -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(); diff --git a/ws/ws_send.cpp b/ws/ws_send.cpp index 93ea8e5f..f1ea9a36 100644 --- a/ws/ws_send.cpp +++ b/ws/ws_send.cpp @@ -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(); diff --git a/ws/ws_transfer.cpp b/ws/ws_transfer.cpp index b7d8ac6c..9413f0da 100644 --- a/ws/ws_transfer.cpp +++ b/ws/ws_transfer.cpp @@ -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 webSocket, std::shared_ptr connectionState) {