]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow port-less connections for lua_tcp
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 20 Sep 2016 13:04:16 +0000 (14:04 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 20 Sep 2016 13:05:38 +0000 (14:05 +0100)
src/lua/lua_tcp.c

index 923980fe2fe86e8c29806156b91f99c05006926c..23140b79a9c1a90eeb344075cdd47b9780757c33 100644 (file)
@@ -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");