From 025de61f439c4a32035ff4dc6986d73c1a5a772d Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Fri, 29 May 2020 12:08:31 +0200 Subject: [PATCH] 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. --- src/util-log-redis.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/util-log-redis.c b/src/util-log-redis.c index b6ff2b6717..afc4d4858a 100644 --- a/src/util-log-redis.c +++ b/src/util-log-redis.c @@ -201,7 +201,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); @@ -295,7 +299,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); -- 2.47.3