diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-15 14:26:21 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-02-15 14:26:21 +0000 |
commit | 4b7e987b91a8782d5558f24cbd6bda7a70a53da1 (patch) | |
tree | e9643e7c0f4b4561be34e9114c1e7e73ce73c969 /src/lua/lua_upstream.c | |
parent | c4a37ba40e2ee0b55df25fbd5e3b8b910f145168 (diff) | |
download | rspamd-4b7e987b91a8782d5558f24cbd6bda7a70a53da1.tar.gz rspamd-4b7e987b91a8782d5558f24cbd6bda7a70a53da1.zip |
[Minor] Allow to create upstream lists without rspamd_config
Diffstat (limited to 'src/lua/lua_upstream.c')
-rw-r--r-- | src/lua/lua_upstream.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/lua/lua_upstream.c b/src/lua/lua_upstream.c index 066183187..e67d60443 100644 --- a/src/lua/lua_upstream.c +++ b/src/lua/lua_upstream.c @@ -171,17 +171,27 @@ static gint lua_upstream_list_create (lua_State *L) { struct upstream_list *new = NULL, **pnew; - struct rspamd_config *cfg = lua_check_config (L, 1); + struct rspamd_config *cfg = NULL; const gchar *def; guint default_port = 0; + gint top; - def = luaL_checkstring (L, 2); - if (def && cfg) { - if (lua_gettop (L) >= 3) { - default_port = luaL_checknumber (L, 3); + + if (lua_type (L, 1) == LUA_TUSERDATA) { + cfg = lua_check_config (L, 1); + top = 2; + } + else { + top = 1; + } + + def = luaL_checkstring (L, top); + if (def) { + if (lua_gettop (L) >= top + 1) { + default_port = luaL_checknumber (L, top + 1); } - new = rspamd_upstreams_create (cfg->ups_ctx); + new = rspamd_upstreams_create (cfg ? cfg->ups_ctx : NULL); if (rspamd_upstreams_parse_line (new, def, default_port, NULL)) { pnew = lua_newuserdata (L, sizeof (struct upstream_list *)); |