From e3f81b38fe352591c708512c1ea7b614905a236a Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 16 Jun 2018 16:08:58 +0100 Subject: [PATCH] [Minor] Add method to get tlds file --- src/lua/lua_config.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index 37d122402..4495135c2 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -710,6 +710,13 @@ LUA_FUNCTION_DEF (config, parse_rcl); */ LUA_FUNCTION_DEF (config, init_modules); +/*** + * @method rspamd_config:get_tld_path() + * Returns path to TLD file + * @return {string} path to tld file + */ +LUA_FUNCTION_DEF (config, get_tld_path); + static const struct luaL_reg configlib_m[] = { LUA_INTERFACE_DEF (config, get_module_opt), LUA_INTERFACE_DEF (config, get_mempool), @@ -771,6 +778,7 @@ static const struct luaL_reg configlib_m[] = { LUA_INTERFACE_DEF (config, load_ucl), LUA_INTERFACE_DEF (config, parse_rcl), LUA_INTERFACE_DEF (config, init_modules), + LUA_INTERFACE_DEF (config, get_tld_path), {"__tostring", rspamd_lua_class_tostring}, {"__newindex", lua_config_newindex}, {NULL, NULL} @@ -3411,6 +3419,21 @@ lua_config_init_modules (lua_State *L) return 1; } +static gint +lua_config_get_tld_path (lua_State *L) +{ + struct rspamd_config *cfg = lua_check_config (L, 1); + + if (cfg != NULL) { + lua_pushstring (L, cfg->tld_file); + } + else { + return luaL_error (L, "invalid arguments"); + } + + return 1; +} + static gint lua_monitored_alive (lua_State *L) { -- 2.39.5