From: Eric Leblond Date: Fri, 29 May 2020 10:08:31 +0000 (+0200) Subject: redis: add support for unix socket X-Git-Tag: suricata-6.0.0-beta1~351 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=025de61f439c4a32035ff4dc6986d73c1a5a772d;p=thirdparty%2Fsuricata.git 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. --- 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);