commit af66b62: [Minor] Register settings symbols

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jul 2 15:56:10 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-07-02 16:49:15 +0100
URL: https://github.com/rspamd/rspamd/commit/af66b629a1ddbc14b678ebbd2ba5925998d1b67d

[Minor] Register settings symbols

---
 src/plugins/lua/settings.lua | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index 084f51467..bfd11c439 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -836,9 +836,9 @@ local function process_settings_table(tbl, allow_ids, mempool)
         -- By De Morgan laws
         if inverse then s = ' || ' end
         -- Exclude aliases and join all checks by key
-        local expr_str = table.concat(fun.totable(fun.map(function(k, _)
-          return k end,
-            fun.filter(function(k, _) return not aliases[k] end, checks))), s)
+        local expr_str = table.concat(lua_util.keys(fun.filter(
+            function(k, _) return not aliases[k] end,
+            checks)), s)
 
         if inverse then
           expr_str = string.format('!(%s)', expr_str)
@@ -911,12 +911,24 @@ local function process_settings_table(tbl, allow_ids, mempool)
 
       if elt['id'] then
         out.id = lua_settings.register_settings_id(elt.id, out)
-        lua_util.debugm(N, rspamd_config, 'added settings id to "%s": %s -> %s',
+        lua_util.debugm(N, rspamd_config,
+            'added settings id to "%s": %s -> %s',
             name, elt.id, out.id)
       end
+
+      if elt.apply.symbols then
+        -- Register virtual symbols
+        for _,sym in ipairs(elt.apply.symbols) do
+          rspamd_config.register_symbol{
+            name = sym,
+            type = 'virtual,ghost',
+          }
+        end
+      end
     else
       if elt['id'] then
-        rspamd_logger.errx(rspamd_config, 'cannot set static IDs from dynamic settings, please read the docs')
+        rspamd_logger.errx(rspamd_config,
+            'cannot set static IDs from dynamic settings, please read the docs')
       end
     end
 


More information about the Commits mailing list