diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-20 14:04:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-09-20 14:05:38 +0100 |
commit | 5e99b30706d0913794fe951ee837d7ef100cdc17 (patch) | |
tree | 14e8cc60cbec7df7d21870870934bdd479b90cd6 | |
parent | a8bce892fe0f55a4917c54e2ee8a3c28d58a9488 (diff) | |
download | rspamd-5e99b30706d0913794fe951ee837d7ef100cdc17.tar.gz rspamd-5e99b30706d0913794fe951ee837d7ef100cdc17.zip |
[Minor] Allow port-less connections for lua_tcp
-rw-r--r-- | src/lua/lua_tcp.c | 11 |
1 files changed, 9 insertions, 2 deletions
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"); |