commit ab4ec23: [Minor] Allow to register symbols from settings explicitly

Vsevolod Stakhov vsevolod at rspamd.com
Sun Nov 27 23:14:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-11-27 21:54:17 +0000
URL: https://github.com/rspamd/rspamd/commit/ab4ec231e0a0bfbc9bd993be30b7c4ca220fcc2c

[Minor] Allow to register symbols from settings explicitly

---
 src/plugins/lua/settings.lua | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index 4eb9ac869..e86b7f6b2 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -1323,6 +1323,26 @@ elseif set_section and type(set_section) == "table" then
   -- Postponed settings init is needed to ensure that all symbols have been
   -- registered BEFORE settings plugin. Otherwise, we can have inconsistent settings expressions
   fun.each(function(_, elt)
+    if elt.register_symbols then
+      for k,v in pairs(elt.register_symbols) do
+        local rtb = {
+          type = 'virtual',
+          parent = module_sym_id,
+        }
+        if type(k) == 'number' and type(v) == 'string' then
+          rtb.name = v
+        elseif type(k) == 'string' then
+          rtb.name = k
+          if type(v) == 'table' then
+            for kk,vv in pairs(v) do
+              -- Enrich table wih extra values
+              rtb[kk] = vv
+            end
+          end
+        end
+        rspamd_config:register_symbol(rtb)
+      end
+    end
     if elt.apply and elt.apply.symbols then
       -- Register virtual symbols
       for k,v in pairs(elt.apply.symbols) do


More information about the Commits mailing list