]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
redis: add support for unix socket
authorEric Leblond <eric@regit.org>
Fri, 29 May 2020 10:08:31 +0000 (12:08 +0200)
committerVictor Julien <victor@inliniac.net>
Sat, 6 Jun 2020 12:31:50 +0000 (14:31 +0200)
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

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