]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
util-log-redis: add support for unix socket
authorEric Leblond <eric@regit.org>
Fri, 29 May 2020 10:08:31 +0000 (12:08 +0200)
committerJeff Lucovsky <jeff@lucovsky.org>
Sun, 5 Jul 2020 15:40:54 +0000 (11:40 -0400)
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)

src/util-log-redis.c

index af0380ef7665b5bd61518f054868b5b36a424217..a145e4f564bfb3447399ce227b1fc2fb73e1e5c2 100644 (file)
@@ -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);