From: Vsevolod Stakhov Date: Tue, 20 Sep 2016 13:04:16 +0000 (+0100) Subject: [Minor] Allow port-less connections for lua_tcp X-Git-Tag: 1.4.0~405 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5e99b30706d0913794fe951ee837d7ef100cdc17;p=rspamd.git [Minor] Allow port-less connections for lua_tcp --- 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");