]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix connecting to a unix socket in rspamadm statconvert
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 9 Feb 2018 19:34:29 +0000 (19:34 +0000)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 12 Feb 2018 10:16:08 +0000 (12:16 +0200)
Issue: #1992
Closes: #1992
src/lua/lua_redis.c

index c21d69f33cca156bd390841f83b03553982d24df..5c906471ca7ab593abd76ee1ada2a884d82023ba 100644 (file)
@@ -927,8 +927,16 @@ lua_redis_make_request_sync (lua_State *L)
 
        if (ret) {
                double_to_tv (timeout, &tv);
-               ctx = redisConnectWithTimeout (rspamd_inet_address_to_string (addr->addr),
-                               rspamd_inet_address_get_port (addr->addr), tv);
+
+               if (rspamd_inet_address_get_af (addr->addr) == AF_UNIX) {
+                       ctx = redisConnectUnixWithTimeout (
+                                       rspamd_inet_address_to_string (addr->addr), tv);
+               }
+               else {
+                       ctx = redisConnectWithTimeout (
+                                       rspamd_inet_address_to_string (addr->addr),
+                                       rspamd_inet_address_get_port (addr->addr), tv);
+               }
 
                if (ip) {
                        rspamd_inet_address_free (ip);
@@ -1086,9 +1094,16 @@ lua_redis_connect_sync (lua_State *L)
                ctx = g_slice_alloc0 (sizeof (struct lua_redis_ctx));
                REF_INIT_RETAIN (ctx, lua_redis_dtor);
                ctx->flags = flags;
-               ctx->d.sync = redisConnectWithTimeout (
-                               rspamd_inet_address_to_string (addr->addr),
-                               rspamd_inet_address_get_port (addr->addr), tv);
+
+               if (rspamd_inet_address_get_af (addr->addr) == AF_UNIX) {
+                       ctx->d.sync = redisConnectUnixWithTimeout (
+                                       rspamd_inet_address_to_string (addr->addr), tv);
+               }
+               else {
+                       ctx->d.sync = redisConnectWithTimeout (
+                                       rspamd_inet_address_to_string (addr->addr),
+                                       rspamd_inet_address_get_port (addr->addr), tv);
+               }
 
                if (ip) {
                        rspamd_inet_address_free (ip);