From 5e99b30706d0913794fe951ee837d7ef100cdc17 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 20 Sep 2016 14:04:16 +0100 Subject: [Minor] Allow port-less connections for lua_tcp --- src/lua/lua_tcp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/lua/lua_tcp.c') diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index 923980fe2..23140b79a 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -505,7 +505,7 @@ lua_tcp_arg_toiovec (lua_State *L, gint pos, rspamd_mempool_t *pool, * - `session`: events session (no task) * - `pool`: memory pool (no task) * - `host`: IP or name of the peer (required) - * - `port`: remote port to use (required) + * - `port`: remote port to use * - `data`: a table of strings or `rspamd_text` objects that contains data pieces * - `callback`: continuation function (required) * - `on_connect`: callback called on connection success @@ -540,7 +540,14 @@ lua_tcp_request (lua_State *L) lua_pushstring (L, "port"); lua_gettable (L, -2); - port = luaL_checknumber (L, -1); + if (lua_type (L, -1) == LUA_TNUMBER) { + port = luaL_checknumber (L, -1); + } + else { + /* We assume that it is a unix socket */ + port = 0; + } + lua_pop (L, 1); lua_pushstring (L, "callback"); -- cgit v1.2.3