Modify cfgLogStreamDefault
add support for UNIX socket in LogStream connection
@@ -2595,9 +2595,9 @@ initCtl(config_t *cfg)
* internal configuration, overriding default config, env vars
* and the config file to:
*
- * - use a single IP:port for events, metrics & remote commands
+ * - use a single IP:port/UNIX socket for events, metrics & remote commands
* - set metrics to use ndjson
- * - use a separate connection over the single IP:port for payloads
+ * - use a separate connection over the single IP:port/UNIX socket for payloads
* - include the abbreviated json header for payloads
* - watch types enabled for files, console, net, fs, http, dns
* - log level warning
@@ -2610,7 +2610,11 @@ cfgLogStreamDefault(config_t *cfg)
snprintf(g_logmsg, sizeof(g_logmsg), DEFAULT_LOGSTREAM_LOGMSG);
- // override the CFG_LS transport type to be TCP
+ if (cfgTransportType(cfg, CFG_LS) == CFG_UNIX) {
+ const char *path = cfgTransportPath(cfg, CFG_LS);
+ cfgTransportPathSet(cfg, CFG_CTL, path);
+ } else {
+ // override the CFG_LS transport type to be TCP for type different than UNIX
cfgTransportTypeSet(cfg, CFG_LS, CFG_TCP);
// host is already set
// port is already set
@@ -2622,11 +2626,6 @@ cfgLogStreamDefault(config_t *cfg)
cfgTransportTlsValidateServerSet(cfg, CFG_LS, TRUE);
cfgTransportTlsCACertPathSet(cfg, CFG_LS, NULL);
}
-
- // copy the CFG_LS configuration to CFG_CTL
- {
- cfg_transport_t type = cfgTransportType(cfg, CFG_LS);
- cfgTransportTypeSet(cfg, CFG_CTL, type);
const char *host = cfgTransportHost(cfg, CFG_LS);
cfgTransportHostSet(cfg, CFG_CTL, host);
const char *port = cfgTransportPort(cfg, CFG_LS);
@@ -2639,10 +2638,13 @@ cfgLogStreamDefault(config_t *cfg)
cfgTransportTlsCACertPathSet(cfg, CFG_CTL, cacertpath);
}
+ cfg_transport_t type = cfgTransportType(cfg, CFG_LS);
+ cfgTransportTypeSet(cfg, CFG_CTL, type);
+
if (cfgMtcEnable(cfg) != TRUE) {
strncat(g_logmsg, "Metrics enable, ", 20);
}
- cfgMtcEnableSet(cfg, (unsigned)1);
+ cfgMtcEnableSet(cfg, 1U);
if (cfgMtcFormat(cfg) != TRUE) {
strncat(g_logmsg, "Metrics format, ", 20);
@@ -2652,7 +2654,7 @@ cfgLogStreamDefault(config_t *cfg)
if (cfgEvtEnable(cfg) != TRUE) {
strncat(g_logmsg, "Event enable, ", 20);
}
- cfgEvtEnableSet(cfg, (unsigned)1);
+ cfgEvtEnableSet(cfg, 1U);
if (cfgLogLevel(cfg) > CFG_LOG_WARN ) {
strncat(g_logmsg, "Log level, ", 20);
