commit 35a0a7e: [Minor] Rbl: Add more logical aliases

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Sep 17 12:56:05 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-09-17 13:50:24 +0100
URL: https://github.com/rspamd/rspamd/commit/35a0a7e2e02a8b35da0d02f94522aa1294d4da9d (HEAD -> master)

[Minor] Rbl: Add more logical aliases

---
 src/plugins/lua/rbl.lua | 50 ++++++++++++++++++++++++++++---------------------
 1 file changed, 29 insertions(+), 21 deletions(-)

diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index f2a53de78..38c9224f4 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -957,33 +957,38 @@ if(opts['local_exclude_ip_map'] ~= nil) then
     'RBL exclusions map')
 end
 
+local return_codes_schema = ts.map_of(
+    ts.string / string.upper, -- Symbol name
+    (
+        ts.array_of(ts.string) +
+            (ts.string / function(s)
+              return { s }
+            end) -- List of IP patterns
+    )
+)
+local return_bits_schema = ts.map_of(
+    ts.string / string.upper, -- Symbol name
+    (
+        ts.array_of(ts.number + ts.string / tonumber) +
+            (ts.string / function(s)
+              return { tonumber(s) }
+            end) +
+            (ts.number / function(s)
+              return { s }
+            end)
+    )
+)
+
 local rule_schema = ts.shape({
   enabled = ts.boolean:is_optional(),
   disabled = ts.boolean:is_optional(),
   rbl = ts.string,
   selector = ts.string:is_optional(),
   symbol = ts.string:is_optional(),
-  returncodes = ts.map_of(
-      ts.string / string.upper, -- Symbol name
-      (
-          ts.array_of(ts.string) +
-              (ts.string / function(s)
-                return { s }
-              end) -- List of IP patterns
-      )
-  ):is_optional(),
-  returnbits = ts.map_of(
-      ts.string / string.upper, -- Symbol name
-      (
-          ts.array_of(ts.number + ts.string / tonumber) +
-              (ts.string / function(s)
-                return { tonumber(s) }
-              end) +
-              (ts.number / function(s)
-                return { s }
-              end)
-      )
-  ):is_optional(),
+  returncodes = return_codes_schema:is_optional(),
+  return_codes = return_codes_schema:is_optional(),
+  returnbits = return_bits_schema:is_optional(),
+  return_bits = return_bits_schema:is_optional(),
   whitelist_exception = (
       ts.array_of(ts.string) + (ts.string / function(s) return {s} end)
   ):is_optional(),
@@ -1020,6 +1025,9 @@ for key,rbl in pairs(opts.rbls or opts.rules) do
       rspamd_logger.errx(rspamd_config, 'invalid config for %s: %s, RBL is DISABLED',
           key, err)
     else
+      -- Aliases
+      if res.return_codes then res.returncodes = res.return_codes end
+      if res.return_bits then res.returnbits = res.return_bits end
       add_rbl(key, res, opts)
     end
   end -- rbl.enabled


More information about the Commits mailing list