From: Eric Leblond Date: Fri, 29 May 2020 10:08:31 +0000 (+0200) Subject: util-log-redis: add support for unix socket X-Git-Tag: suricata-5.0.4~55 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=03d7cc74c797908a493ed6d5e5c03e5a193abef7;p=thirdparty%2Fsuricata.git util-log-redis: add support for unix socket If there is a '/' in the redis server string then we consider that the connection should be done other a unix socket. (cherry picked from commit e12437e31e9cab25576e9cb3d70cba620ba3023e) --- diff --git a/src/util-log-redis.c b/src/util-log-redis.c index af0380ef76..a145e4f564 100644 --- a/src/util-log-redis.c +++ b/src/util-log-redis.c @@ -203,7 +203,11 @@ static int SCConfLogReopenAsyncRedis(LogFileCtx *log_ctx) return -1; } - ctx->async = redisAsyncConnect(redis_server, redis_port); + if (strchr(redis_server, '/') == NULL) { + ctx->async = redisAsyncConnect(redis_server, redis_port); + } else { + ctx->async = redisAsyncConnectUnix(redis_server); + } if (ctx->ev_base != NULL) { event_base_free(ctx->ev_base); @@ -297,7 +301,12 @@ static int SCConfLogReopenSyncRedis(LogFileCtx *log_ctx) if (ctx->sync != NULL) { redisFree(ctx->sync); } - ctx->sync = redisConnect(redis_server, redis_port); + + if (strchr(redis_server, '/') == NULL) { + ctx->sync = redisConnect(redis_server, redis_port); + } else { + ctx->sync = redisConnectUnix(redis_server); + } if (ctx->sync == NULL) { SCLogError(SC_ERR_SOCKET, "Error connecting to redis server."); ctx->tried = time(NULL);