(cobra) Add TLS options to all cobra commands and classes. Add example to the doc.
This commit is contained in:
62
ws/ws.cpp
62
ws/ws.cpp
@ -218,6 +218,7 @@ int main(int argc, char** argv)
|
||||
cobraSubscribeApp->add_option("--pidfile", pidfile, "Pid file");
|
||||
cobraSubscribeApp->add_option("--filter", filter, "Stream SQL Filter");
|
||||
cobraSubscribeApp->add_flag("-q", quiet, "Quiet / only display stats");
|
||||
addTLSOptions(cobraSubscribeApp);
|
||||
|
||||
CLI::App* cobraPublish = app.add_subcommand("cobra_publish", "Cobra publisher");
|
||||
cobraPublish->add_option("--appkey", appkey, "Appkey")->required();
|
||||
@ -229,6 +230,7 @@ int main(int argc, char** argv)
|
||||
cobraPublish->add_option("path", path, "Path to the file to send")
|
||||
->required()
|
||||
->check(CLI::ExistingPath);
|
||||
addTLSOptions(cobraPublish);
|
||||
|
||||
CLI::App* cobraMetricsPublish =
|
||||
app.add_subcommand("cobra_metrics_publish", "Cobra metrics publisher");
|
||||
@ -242,6 +244,7 @@ int main(int argc, char** argv)
|
||||
->required()
|
||||
->check(CLI::ExistingPath);
|
||||
cobraMetricsPublish->add_flag("--stress", stress, "Stress mode");
|
||||
addTLSOptions(cobraMetricsPublish);
|
||||
|
||||
CLI::App* cobra2statsd = app.add_subcommand("cobra_to_statsd", "Cobra metrics to statsd");
|
||||
cobra2statsd->add_option("--appkey", appkey, "Appkey");
|
||||
@ -256,6 +259,7 @@ int main(int argc, char** argv)
|
||||
cobra2statsd->add_flag("-v", verbose, "Verbose");
|
||||
cobra2statsd->add_option("--pidfile", pidfile, "Pid file");
|
||||
cobra2statsd->add_option("--filter", filter, "Stream SQL Filter");
|
||||
addTLSOptions(cobra2statsd);
|
||||
|
||||
CLI::App* cobra2sentry = app.add_subcommand("cobra_to_sentry", "Cobra metrics to sentry");
|
||||
cobra2sentry->add_option("--appkey", appkey, "Appkey")->required();
|
||||
@ -269,6 +273,7 @@ int main(int argc, char** argv)
|
||||
cobra2sentry->add_flag("-s", strict, "Strict mode. Error out when sending to sentry fails");
|
||||
cobra2sentry->add_option("--pidfile", pidfile, "Pid file");
|
||||
cobra2sentry->add_option("--filter", filter, "Stream SQL Filter");
|
||||
addTLSOptions(cobra2sentry);
|
||||
|
||||
CLI::App* cobra2redisApp =
|
||||
app.add_subcommand("cobra_metrics_to_redis", "Cobra metrics to redis");
|
||||
@ -282,17 +287,19 @@ int main(int argc, char** argv)
|
||||
cobra2redisApp->add_option("--hostname", hostname, "Redis hostname");
|
||||
cobra2redisApp->add_option("--port", redisPort, "Redis port");
|
||||
cobra2redisApp->add_flag("-q", quiet, "Quiet / only display stats");
|
||||
addTLSOptions(cobra2redisApp);
|
||||
|
||||
CLI::App* runApp = app.add_subcommand("snake", "Snake server");
|
||||
runApp->add_option("--port", port, "Connection url");
|
||||
runApp->add_option("--host", hostname, "Hostname");
|
||||
runApp->add_option("--pidfile", pidfile, "Pid file");
|
||||
runApp->add_option("--redis_hosts", redisHosts, "Redis hosts");
|
||||
runApp->add_option("--redis_port", redisPort, "Redis hosts");
|
||||
runApp->add_option("--redis_password", redisPassword, "Redis password");
|
||||
runApp->add_option("--apps_config_path", appsConfigPath, "Path to auth data")
|
||||
CLI::App* snakeApp = app.add_subcommand("snake", "Snake server");
|
||||
snakeApp->add_option("--port", port, "Connection url");
|
||||
snakeApp->add_option("--host", hostname, "Hostname");
|
||||
snakeApp->add_option("--pidfile", pidfile, "Pid file");
|
||||
snakeApp->add_option("--redis_hosts", redisHosts, "Redis hosts");
|
||||
snakeApp->add_option("--redis_port", redisPort, "Redis hosts");
|
||||
snakeApp->add_option("--redis_password", redisPassword, "Redis password");
|
||||
snakeApp->add_option("--apps_config_path", appsConfigPath, "Path to auth data")
|
||||
->check(CLI::ExistingPath);
|
||||
runApp->add_flag("-v", verbose, "Verbose");
|
||||
snakeApp->add_flag("-v", verbose, "Verbose");
|
||||
addTLSOptions(snakeApp);
|
||||
|
||||
CLI::App* httpServerApp = app.add_subcommand("httpd", "HTTP server");
|
||||
httpServerApp->add_option("--port", port, "Port");
|
||||
@ -314,6 +321,7 @@ int main(int argc, char** argv)
|
||||
proxyServerApp->add_option("--host", hostname, "Hostname");
|
||||
proxyServerApp->add_option("--remote_host", remoteHost, "Remote Hostname");
|
||||
proxyServerApp->add_flag("-v", verbose, "Verbose");
|
||||
addTLSOptions(proxyServerApp);
|
||||
|
||||
CLI::App* minidumpApp = app.add_subcommand("upload_minidump", "Upload a minidump to sentry");
|
||||
minidumpApp->add_option("--minidump", minidump, "Minidump path")->check(CLI::ExistingPath);
|
||||
@ -408,16 +416,17 @@ int main(int argc, char** argv)
|
||||
else if (app.got_subcommand("cobra_subscribe"))
|
||||
{
|
||||
ret = ix::ws_cobra_subscribe_main(
|
||||
appkey, endpoint, rolename, rolesecret, channel, filter, quiet);
|
||||
appkey, endpoint, rolename, rolesecret, channel, filter, quiet, tlsOptions);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_publish"))
|
||||
{
|
||||
ret = ix::ws_cobra_publish_main(appkey, endpoint, rolename, rolesecret, channel, path);
|
||||
ret = ix::ws_cobra_publish_main(
|
||||
appkey, endpoint, rolename, rolesecret, channel, path, tlsOptions);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_metrics_publish"))
|
||||
{
|
||||
ret = ix::ws_cobra_metrics_publish_main(
|
||||
appkey, endpoint, rolename, rolesecret, channel, path, stress);
|
||||
appkey, endpoint, rolename, rolesecret, channel, path, stress, tlsOptions);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_to_statsd"))
|
||||
{
|
||||
@ -431,22 +440,39 @@ int main(int argc, char** argv)
|
||||
statsdPort,
|
||||
prefix,
|
||||
fields,
|
||||
verbose);
|
||||
verbose,
|
||||
tlsOptions);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_to_sentry"))
|
||||
{
|
||||
ret = ix::ws_cobra_to_sentry_main(
|
||||
appkey, endpoint, rolename, rolesecret, channel, filter, dsn, verbose, strict, jobs);
|
||||
ret = ix::ws_cobra_to_sentry_main(appkey,
|
||||
endpoint,
|
||||
rolename,
|
||||
rolesecret,
|
||||
channel,
|
||||
filter,
|
||||
dsn,
|
||||
verbose,
|
||||
strict,
|
||||
jobs,
|
||||
tlsOptions);
|
||||
}
|
||||
else if (app.got_subcommand("cobra_metrics_to_redis"))
|
||||
{
|
||||
ret = ix::ws_cobra_metrics_to_redis(
|
||||
appkey, endpoint, rolename, rolesecret, channel, filter, hostname, redisPort);
|
||||
ret = ix::ws_cobra_metrics_to_redis(appkey,
|
||||
endpoint,
|
||||
rolename,
|
||||
rolesecret,
|
||||
channel,
|
||||
filter,
|
||||
hostname,
|
||||
redisPort,
|
||||
tlsOptions);
|
||||
}
|
||||
else if (app.got_subcommand("snake"))
|
||||
{
|
||||
ret = ix::ws_snake_main(
|
||||
port, hostname, redisHosts, redisPort, redisPassword, verbose, appsConfigPath);
|
||||
port, hostname, redisHosts, redisPort, redisPassword, verbose, appsConfigPath, tlsOptions);
|
||||
}
|
||||
else if (app.got_subcommand("httpd"))
|
||||
{
|
||||
|
21
ws/ws.h
21
ws/ws.h
@ -76,14 +76,16 @@ namespace ix
|
||||
const std::string& rolesecret,
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
bool quiet);
|
||||
bool quiet,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
|
||||
int ws_cobra_publish_main(const std::string& appkey,
|
||||
const std::string& endpoint,
|
||||
const std::string& rolename,
|
||||
const std::string& rolesecret,
|
||||
const std::string& channel,
|
||||
const std::string& path);
|
||||
const std::string& path,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
|
||||
int ws_cobra_metrics_publish_main(const std::string& appkey,
|
||||
const std::string& endpoint,
|
||||
@ -91,7 +93,8 @@ namespace ix
|
||||
const std::string& rolesecret,
|
||||
const std::string& channel,
|
||||
const std::string& path,
|
||||
bool stress);
|
||||
bool stress,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
|
||||
int ws_cobra_to_statsd_main(const std::string& appkey,
|
||||
const std::string& endpoint,
|
||||
@ -103,7 +106,8 @@ namespace ix
|
||||
int port,
|
||||
const std::string& prefix,
|
||||
const std::string& fields,
|
||||
bool verbose);
|
||||
bool verbose,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
|
||||
int ws_cobra_to_sentry_main(const std::string& appkey,
|
||||
const std::string& endpoint,
|
||||
@ -114,7 +118,8 @@ namespace ix
|
||||
const std::string& dsn,
|
||||
bool verbose,
|
||||
bool strict,
|
||||
int jobs);
|
||||
int jobs,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
|
||||
int ws_cobra_metrics_to_redis(const std::string& appkey,
|
||||
const std::string& endpoint,
|
||||
@ -123,7 +128,8 @@ namespace ix
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& host,
|
||||
int port);
|
||||
int port,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
|
||||
int ws_snake_main(int port,
|
||||
const std::string& hostname,
|
||||
@ -131,7 +137,8 @@ namespace ix
|
||||
int redisPort,
|
||||
const std::string& redisPassword,
|
||||
bool verbose,
|
||||
const std::string& appsConfigPath);
|
||||
const std::string& appsConfigPath,
|
||||
const ix::SocketTLSOptions& tlsOptions);
|
||||
|
||||
int ws_httpd_main(int port,
|
||||
const std::string& hostname,
|
||||
|
@ -22,7 +22,8 @@ namespace ix
|
||||
const std::string& rolesecret,
|
||||
const std::string& channel,
|
||||
const std::string& path,
|
||||
bool stress)
|
||||
bool stress,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
{
|
||||
std::atomic<int> sentMessages(0);
|
||||
std::atomic<int> ackedMessages(0);
|
||||
@ -37,7 +38,7 @@ namespace ix
|
||||
|
||||
bool enablePerMessageDeflate = true;
|
||||
cobraMetricsPublisher.configure(
|
||||
appkey, endpoint, channel, rolename, rolesecret, enablePerMessageDeflate);
|
||||
appkey, endpoint, channel, rolename, rolesecret, enablePerMessageDeflate, tlsOptions);
|
||||
|
||||
while (!cobraMetricsPublisher.isAuthenticated())
|
||||
;
|
||||
|
@ -25,11 +25,16 @@ namespace ix
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
const std::string& host,
|
||||
int port)
|
||||
int port,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
{
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(
|
||||
appkey, endpoint, rolename, rolesecret, ix::WebSocketPerMessageDeflateOptions(true));
|
||||
conn.configure(appkey,
|
||||
endpoint,
|
||||
rolename,
|
||||
rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.connect();
|
||||
|
||||
// Display incoming messages
|
||||
|
@ -22,7 +22,8 @@ namespace ix
|
||||
const std::string& rolename,
|
||||
const std::string& rolesecret,
|
||||
const std::string& channel,
|
||||
const std::string& path)
|
||||
const std::string& path,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
{
|
||||
std::ifstream f(path);
|
||||
std::string str((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
|
||||
@ -36,8 +37,12 @@ namespace ix
|
||||
}
|
||||
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(
|
||||
appkey, endpoint, rolename, rolesecret, ix::WebSocketPerMessageDeflateOptions(true));
|
||||
conn.configure(appkey,
|
||||
endpoint,
|
||||
rolename,
|
||||
rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.connect();
|
||||
|
||||
// Display incoming messages
|
||||
|
@ -20,11 +20,16 @@ namespace ix
|
||||
const std::string& rolesecret,
|
||||
const std::string& channel,
|
||||
const std::string& filter,
|
||||
bool quiet)
|
||||
bool quiet,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
{
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(
|
||||
appkey, endpoint, rolename, rolesecret, ix::WebSocketPerMessageDeflateOptions(true));
|
||||
conn.configure(appkey,
|
||||
endpoint,
|
||||
rolename,
|
||||
rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.connect();
|
||||
|
||||
Json::FastWriter jsonWriter;
|
||||
|
@ -28,11 +28,16 @@ namespace ix
|
||||
const std::string& dsn,
|
||||
bool verbose,
|
||||
bool strict,
|
||||
int jobs)
|
||||
int jobs,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
{
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(
|
||||
appkey, endpoint, rolename, rolesecret, ix::WebSocketPerMessageDeflateOptions(true));
|
||||
conn.configure(appkey,
|
||||
endpoint,
|
||||
rolename,
|
||||
rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.connect();
|
||||
|
||||
Json::FastWriter jsonWriter;
|
||||
|
@ -66,11 +66,16 @@ namespace ix
|
||||
int port,
|
||||
const std::string& prefix,
|
||||
const std::string& fields,
|
||||
bool verbose)
|
||||
bool verbose,
|
||||
const ix::SocketTLSOptions& tlsOptions)
|
||||
{
|
||||
ix::CobraConnection conn;
|
||||
conn.configure(
|
||||
appkey, endpoint, rolename, rolesecret, ix::WebSocketPerMessageDeflateOptions(true));
|
||||
conn.configure(appkey,
|
||||
endpoint,
|
||||
rolename,
|
||||
rolesecret,
|
||||
ix::WebSocketPerMessageDeflateOptions(true),
|
||||
tlsOptions);
|
||||
conn.connect();
|
||||
|
||||
auto tokens = parseFields(fields);
|
||||
|
@ -43,7 +43,8 @@ namespace ix
|
||||
int redisPort,
|
||||
const std::string& redisPassword,
|
||||
bool verbose,
|
||||
const std::string& appsConfigPath)
|
||||
const std::string& appsConfigPath,
|
||||
const SocketTLSOptions& socketTLSOptions)
|
||||
{
|
||||
snake::AppConfig appConfig;
|
||||
appConfig.port = port;
|
||||
@ -51,6 +52,7 @@ namespace ix
|
||||
appConfig.verbose = verbose;
|
||||
appConfig.redisPort = redisPort;
|
||||
appConfig.redisPassword = redisPassword;
|
||||
appConfig.socketTLSOptions = socketTLSOptions;
|
||||
|
||||
// Parse config file
|
||||
auto str = readAsString(appsConfigPath);
|
||||
|
Reference in New Issue
Block a user