(cobra) IXCobraConfig struct has tlsOptions and per message deflate options
This commit is contained in:
parent
0a11132b07
commit
6a4d69afc5
@ -1,6 +1,10 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
All changes to this project will be documented in this file.
|
All changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [8.2.1] - 2020-03-11
|
||||||
|
|
||||||
|
(cobra) IXCobraConfig struct has tlsOptions and per message deflate options
|
||||||
|
|
||||||
## [8.2.0] - 2020-03-11
|
## [8.2.0] - 2020-03-11
|
||||||
|
|
||||||
(cobra) add IXCobraConfig struct to pass cobra config around
|
(cobra) add IXCobraConfig struct to pass cobra config around
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <ixwebsocket/IXWebSocketPerMessageDeflateOptions.h>
|
||||||
|
#include <ixwebsocket/IXSocketTLSOptions.h>
|
||||||
|
|
||||||
namespace ix
|
namespace ix
|
||||||
{
|
{
|
||||||
struct CobraConfig
|
struct CobraConfig
|
||||||
@ -14,6 +17,8 @@ namespace ix
|
|||||||
std::string endpoint;
|
std::string endpoint;
|
||||||
std::string rolename;
|
std::string rolename;
|
||||||
std::string rolesecret;
|
std::string rolesecret;
|
||||||
|
WebSocketPerMessageDeflateOptions webSocketPerMessageDeflateOptions;
|
||||||
|
SocketTLSOptions socketTLSOptions;
|
||||||
|
|
||||||
CobraConfig(const std::string& a = std::string(),
|
CobraConfig(const std::string& a = std::string(),
|
||||||
const std::string& e = std::string(),
|
const std::string& e = std::string(),
|
||||||
@ -28,4 +33,3 @@ namespace ix
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
|
||||||
|
@ -276,6 +276,16 @@ namespace ix
|
|||||||
_webSocket->setPingTimeout(3 * kPingIntervalSecs);
|
_webSocket->setPingTimeout(3 * kPingIntervalSecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CobraConnection::configure(const ix::CobraConfig& config)
|
||||||
|
{
|
||||||
|
configure(config.appkey,
|
||||||
|
config.endpoint,
|
||||||
|
config.rolename,
|
||||||
|
config.rolesecret,
|
||||||
|
config.webSocketPerMessageDeflateOptions,
|
||||||
|
config.socketTLSOptions);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handshake message schema.
|
// Handshake message schema.
|
||||||
//
|
//
|
||||||
|
@ -69,6 +69,8 @@ namespace ix
|
|||||||
const WebSocketPerMessageDeflateOptions& webSocketPerMessageDeflateOptions,
|
const WebSocketPerMessageDeflateOptions& webSocketPerMessageDeflateOptions,
|
||||||
const SocketTLSOptions& socketTLSOptions);
|
const SocketTLSOptions& socketTLSOptions);
|
||||||
|
|
||||||
|
void configure(const ix::CobraConfig& config);
|
||||||
|
|
||||||
/// Set the traffic tracker callback
|
/// Set the traffic tracker callback
|
||||||
static void setTrafficTrackerCallback(const TrafficTrackerCallback& callback);
|
static void setTrafficTrackerCallback(const TrafficTrackerCallback& callback);
|
||||||
|
|
||||||
|
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define IX_WEBSOCKET_VERSION "8.2.0"
|
#define IX_WEBSOCKET_VERSION "8.2.1"
|
||||||
|
19
ws/ws.cpp
19
ws/ws.cpp
@ -356,6 +356,10 @@ int main(int argc, char** argv)
|
|||||||
tlsOptions.caFile = "NONE";
|
tlsOptions.caFile = "NONE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cobra config
|
||||||
|
cobraConfig.webSocketPerMessageDeflateOptions = ix::WebSocketPerMessageDeflateOptions(true);
|
||||||
|
cobraConfig.socketTLSOptions = tlsOptions;
|
||||||
|
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
if (app.got_subcommand("transfer"))
|
if (app.got_subcommand("transfer"))
|
||||||
{
|
{
|
||||||
@ -425,17 +429,17 @@ int main(int argc, char** argv)
|
|||||||
else if (app.got_subcommand("cobra_subscribe"))
|
else if (app.got_subcommand("cobra_subscribe"))
|
||||||
{
|
{
|
||||||
ret = ix::ws_cobra_subscribe_main(
|
ret = ix::ws_cobra_subscribe_main(
|
||||||
cobraConfig, channel, filter, quiet, fluentd, tlsOptions);
|
cobraConfig, channel, filter, quiet, fluentd);
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("cobra_publish"))
|
else if (app.got_subcommand("cobra_publish"))
|
||||||
{
|
{
|
||||||
ret = ix::ws_cobra_publish_main(
|
ret = ix::ws_cobra_publish_main(
|
||||||
cobraConfig, channel, path, tlsOptions);
|
cobraConfig, channel, path);
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("cobra_metrics_publish"))
|
else if (app.got_subcommand("cobra_metrics_publish"))
|
||||||
{
|
{
|
||||||
ret = ix::ws_cobra_metrics_publish_main(
|
ret = ix::ws_cobra_metrics_publish_main(
|
||||||
cobraConfig, channel, path, stress, tlsOptions);
|
cobraConfig, channel, path, stress);
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("cobra_to_statsd"))
|
else if (app.got_subcommand("cobra_to_statsd"))
|
||||||
{
|
{
|
||||||
@ -446,8 +450,7 @@ int main(int argc, char** argv)
|
|||||||
statsdPort,
|
statsdPort,
|
||||||
prefix,
|
prefix,
|
||||||
fields,
|
fields,
|
||||||
verbose,
|
verbose);
|
||||||
tlsOptions);
|
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("cobra_to_sentry"))
|
else if (app.got_subcommand("cobra_to_sentry"))
|
||||||
{
|
{
|
||||||
@ -458,8 +461,7 @@ int main(int argc, char** argv)
|
|||||||
verbose,
|
verbose,
|
||||||
strict,
|
strict,
|
||||||
jobs,
|
jobs,
|
||||||
maxQueueSize,
|
maxQueueSize);
|
||||||
tlsOptions);
|
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("cobra_metrics_to_redis"))
|
else if (app.got_subcommand("cobra_metrics_to_redis"))
|
||||||
{
|
{
|
||||||
@ -467,8 +469,7 @@ int main(int argc, char** argv)
|
|||||||
channel,
|
channel,
|
||||||
filter,
|
filter,
|
||||||
hostname,
|
hostname,
|
||||||
redisPort,
|
redisPort);
|
||||||
tlsOptions);
|
|
||||||
}
|
}
|
||||||
else if (app.got_subcommand("snake"))
|
else if (app.got_subcommand("snake"))
|
||||||
{
|
{
|
||||||
|
18
ws/ws.h
18
ws/ws.h
@ -79,19 +79,16 @@ namespace ix
|
|||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
const std::string& filter,
|
const std::string& filter,
|
||||||
bool quiet,
|
bool quiet,
|
||||||
bool fluentd,
|
bool fluentd);
|
||||||
const ix::SocketTLSOptions& tlsOptions);
|
|
||||||
|
|
||||||
int ws_cobra_publish_main(const ix::CobraConfig& appkey,
|
int ws_cobra_publish_main(const ix::CobraConfig& appkey,
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
const std::string& path,
|
const std::string& path);
|
||||||
const ix::SocketTLSOptions& tlsOptions);
|
|
||||||
|
|
||||||
int ws_cobra_metrics_publish_main(const ix::CobraConfig& config,
|
int ws_cobra_metrics_publish_main(const ix::CobraConfig& config,
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
bool stress,
|
bool stress);
|
||||||
const ix::SocketTLSOptions& tlsOptions);
|
|
||||||
|
|
||||||
int ws_cobra_to_statsd_main(const ix::CobraConfig& config,
|
int ws_cobra_to_statsd_main(const ix::CobraConfig& config,
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
@ -100,8 +97,7 @@ namespace ix
|
|||||||
int port,
|
int port,
|
||||||
const std::string& prefix,
|
const std::string& prefix,
|
||||||
const std::string& fields,
|
const std::string& fields,
|
||||||
bool verbose,
|
bool verbose);
|
||||||
const ix::SocketTLSOptions& tlsOptions);
|
|
||||||
|
|
||||||
int ws_cobra_to_sentry_main(const ix::CobraConfig& config,
|
int ws_cobra_to_sentry_main(const ix::CobraConfig& config,
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
@ -110,15 +106,13 @@ namespace ix
|
|||||||
bool verbose,
|
bool verbose,
|
||||||
bool strict,
|
bool strict,
|
||||||
int jobs,
|
int jobs,
|
||||||
size_t maxQueueSize,
|
size_t maxQueueSize);
|
||||||
const ix::SocketTLSOptions& tlsOptions);
|
|
||||||
|
|
||||||
int ws_cobra_metrics_to_redis(const ix::CobraConfig& config,
|
int ws_cobra_metrics_to_redis(const ix::CobraConfig& config,
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
const std::string& filter,
|
const std::string& filter,
|
||||||
const std::string& host,
|
const std::string& host,
|
||||||
int port,
|
int port);
|
||||||
const ix::SocketTLSOptions& tlsOptions);
|
|
||||||
|
|
||||||
int ws_snake_main(int port,
|
int ws_snake_main(int port,
|
||||||
const std::string& hostname,
|
const std::string& hostname,
|
||||||
|
@ -18,8 +18,7 @@ namespace ix
|
|||||||
int ws_cobra_metrics_publish_main(const ix::CobraConfig& config,
|
int ws_cobra_metrics_publish_main(const ix::CobraConfig& config,
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
bool stress,
|
bool stress)
|
||||||
const ix::SocketTLSOptions& tlsOptions)
|
|
||||||
{
|
{
|
||||||
std::atomic<int> sentMessages(0);
|
std::atomic<int> sentMessages(0);
|
||||||
std::atomic<int> ackedMessages(0);
|
std::atomic<int> ackedMessages(0);
|
||||||
@ -34,7 +33,7 @@ namespace ix
|
|||||||
|
|
||||||
bool enablePerMessageDeflate = true;
|
bool enablePerMessageDeflate = true;
|
||||||
cobraMetricsPublisher.configure(
|
cobraMetricsPublisher.configure(
|
||||||
config.appkey, config.endpoint, channel, config.rolename, config.rolesecret, enablePerMessageDeflate, tlsOptions);
|
config.appkey, config.endpoint, channel, config.rolename, config.rolesecret, enablePerMessageDeflate, config.socketTLSOptions);
|
||||||
|
|
||||||
while (!cobraMetricsPublisher.isAuthenticated())
|
while (!cobraMetricsPublisher.isAuthenticated())
|
||||||
;
|
;
|
||||||
|
@ -21,16 +21,10 @@ namespace ix
|
|||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
const std::string& filter,
|
const std::string& filter,
|
||||||
const std::string& host,
|
const std::string& host,
|
||||||
int port,
|
int port)
|
||||||
const ix::SocketTLSOptions& tlsOptions)
|
|
||||||
{
|
{
|
||||||
ix::CobraConnection conn;
|
ix::CobraConnection conn;
|
||||||
conn.configure(config.appkey,
|
conn.configure(config);
|
||||||
config.endpoint,
|
|
||||||
config.rolename,
|
|
||||||
config.rolesecret,
|
|
||||||
ix::WebSocketPerMessageDeflateOptions(true),
|
|
||||||
tlsOptions);
|
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|
||||||
// Display incoming messages
|
// Display incoming messages
|
||||||
|
@ -18,8 +18,7 @@ namespace ix
|
|||||||
{
|
{
|
||||||
int ws_cobra_publish_main(const ix::CobraConfig& config,
|
int ws_cobra_publish_main(const ix::CobraConfig& config,
|
||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
const std::string& path,
|
const std::string& path)
|
||||||
const ix::SocketTLSOptions& tlsOptions)
|
|
||||||
{
|
{
|
||||||
std::ifstream f(path);
|
std::ifstream f(path);
|
||||||
std::string str((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
std::string str((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
||||||
@ -33,12 +32,7 @@ namespace ix
|
|||||||
}
|
}
|
||||||
|
|
||||||
ix::CobraConnection conn;
|
ix::CobraConnection conn;
|
||||||
conn.configure(config.appkey,
|
conn.configure(config);
|
||||||
config.endpoint,
|
|
||||||
config.rolename,
|
|
||||||
config.rolesecret,
|
|
||||||
ix::WebSocketPerMessageDeflateOptions(true),
|
|
||||||
tlsOptions);
|
|
||||||
|
|
||||||
// Display incoming messages
|
// Display incoming messages
|
||||||
std::atomic<bool> authenticated(false);
|
std::atomic<bool> authenticated(false);
|
||||||
|
@ -35,16 +35,10 @@ namespace ix
|
|||||||
const std::string& channel,
|
const std::string& channel,
|
||||||
const std::string& filter,
|
const std::string& filter,
|
||||||
bool quiet,
|
bool quiet,
|
||||||
bool fluentd,
|
bool fluentd)
|
||||||
const ix::SocketTLSOptions& tlsOptions)
|
|
||||||
{
|
{
|
||||||
ix::CobraConnection conn;
|
ix::CobraConnection conn;
|
||||||
conn.configure(config.appkey,
|
conn.configure(config);
|
||||||
config.endpoint,
|
|
||||||
config.rolename,
|
|
||||||
config.rolesecret,
|
|
||||||
ix::WebSocketPerMessageDeflateOptions(true),
|
|
||||||
tlsOptions);
|
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|
||||||
Json::FastWriter jsonWriter;
|
Json::FastWriter jsonWriter;
|
||||||
|
@ -99,16 +99,10 @@ namespace ix
|
|||||||
bool verbose,
|
bool verbose,
|
||||||
bool strict,
|
bool strict,
|
||||||
int jobs,
|
int jobs,
|
||||||
size_t maxQueueSize,
|
size_t maxQueueSize)
|
||||||
const ix::SocketTLSOptions& tlsOptions)
|
|
||||||
{
|
{
|
||||||
ix::CobraConnection conn;
|
ix::CobraConnection conn;
|
||||||
conn.configure(config.appkey,
|
conn.configure(config);
|
||||||
config.endpoint,
|
|
||||||
config.rolename,
|
|
||||||
config.rolesecret,
|
|
||||||
ix::WebSocketPerMessageDeflateOptions(true),
|
|
||||||
tlsOptions);
|
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|
||||||
Json::FastWriter jsonWriter;
|
Json::FastWriter jsonWriter;
|
||||||
|
@ -116,16 +116,10 @@ namespace ix
|
|||||||
int port,
|
int port,
|
||||||
const std::string& prefix,
|
const std::string& prefix,
|
||||||
const std::string& fields,
|
const std::string& fields,
|
||||||
bool verbose,
|
bool verbose)
|
||||||
const ix::SocketTLSOptions& tlsOptions)
|
|
||||||
{
|
{
|
||||||
ix::CobraConnection conn;
|
ix::CobraConnection conn;
|
||||||
conn.configure(config.appkey,
|
conn.configure(config);
|
||||||
config.endpoint,
|
|
||||||
config.rolename,
|
|
||||||
config.rolesecret,
|
|
||||||
ix::WebSocketPerMessageDeflateOptions(true),
|
|
||||||
tlsOptions);
|
|
||||||
conn.connect();
|
conn.connect();
|
||||||
|
|
||||||
auto tokens = parseFields(fields);
|
auto tokens = parseFields(fields);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user