]> 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)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 9 Feb 2018 19:34:29 +0000 (19:34 +0000)
Issue: #1992
Closes: #1992
src/lua/lua_redis.c

index 9c5c3fde7b564d679414b1779847af5cb1eca222..b845b6d49b42629cce08fd07dba795a08a9afa5b 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_malloc0 (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);