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
7a26ff4de8
commit
845bbc5208
@ -1 +1 @@
|
||||
6.3.3
|
||||
6.3.4
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -7,6 +7,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "IXConnectionState.h"
|
||||
#include "IXSocketTLSOptions.h"
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
@ -51,6 +52,8 @@ namespace ix
|
||||
std::pair<bool, std::string> 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
|
||||
|
@ -6,4 +6,4 @@
|
||||
|
||||
#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)
|
||||
|
||||
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
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user