diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-09 19:34:29 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-09 19:34:29 +0000 |
commit | 76afba6b433236cefd224d862fc6dc47bc26a5b6 (patch) | |
tree | 51b8e053717b9773cae45a2edf7357e28cd8a0a6 /src/lua | |
parent | cbf07c7c5a4f8a6ae556eb833c7f130e9810ffbf (diff) | |
download | rspamd-76afba6b433236cefd224d862fc6dc47bc26a5b6.tar.gz rspamd-76afba6b433236cefd224d862fc6dc47bc26a5b6.zip |
[Fix] Fix connecting to a unix socket in rspamadm statconvert
Issue: #1992
Closes: #1992
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_redis.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c index 9c5c3fde7..b845b6d49 100644 --- a/src/lua/lua_redis.c +++ b/src/lua/lua_redis.c @@ -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); |