]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add method to get tlds file
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 16 Jun 2018 15:08:58 +0000 (16:08 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 16 Jun 2018 15:08:58 +0000 (16:08 +0100)
src/lua/lua_config.c

index 37d122402c886a2b1f04d953fbe7d9168cf2adb1..4495135c2110155990109b0a4d606ba305ac02b4 100644 (file)
@@ -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)
 {