diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-26 13:36:04 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-26 13:36:04 +0000 |
commit | b8cab482167dfa41400671502bd66fe6e3ec0d05 (patch) | |
tree | e14660ae258db33b5d59bb7c70da43d018e65f7c | |
parent | ed4e6b2fb5610a39bce7aef67998001255df3b05 (diff) | |
download | rspamd-b8cab482167dfa41400671502bd66fe6e3ec0d05.tar.gz rspamd-b8cab482167dfa41400671502bd66fe6e3ec0d05.zip |
[Minor] Rbl: Allow to exclude certain checks to simplify local.d additions
Issue: #3655
-rw-r--r-- | lualib/plugins/rbl.lua | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/lualib/plugins/rbl.lua b/lualib/plugins/rbl.lua index 3bddf52ba..f3a2035d3 100644 --- a/lualib/plugins/rbl.lua +++ b/lualib/plugins/rbl.lua @@ -138,32 +138,39 @@ local rule_schema_tbl = { ts.array_of(ts.string) + (ts.string / function(s) return {s} end) ):is_optional(), checks = ts.array_of(ts.one_of(lua_util.keys(check_types))):is_optional(), + exclude_checks = ts.array_of(ts.one_of(lua_util.keys(check_types))):is_optional(), } local function convert_checks(rule) local rspamd_logger = require "rspamd_logger" if rule.checks then local all_connfilter = true + local exclude_checks = lua_util.list_to_hash(rule.exclude_checks or {}) for _,check in ipairs(rule.checks) do - local check_type = check_types[check] - if check_type.require_argument then - if not rule[check] then - rspamd_logger.errx(rspamd_config, 'rbl rule %s has check %s which requires an argument', - rule.symbol, check) - return nil + if not exclude_checks[check] then + local check_type = check_types[check] + if check_type.require_argument then + if not rule[check] then + rspamd_logger.errx(rspamd_config, 'rbl rule %s has check %s which requires an argument', + rule.symbol, check) + return nil + end end - end - rule[check] = check_type + rule[check] = check_type - if not check_type.connfilter then - all_connfilter = false - end + if not check_type.connfilter then + all_connfilter = false + end - if not check_type then - rspamd_logger.errx(rspamd_config, 'rbl rule %s has invalid check type: %s', - rule.symbol, check) - return nil + if not check_type then + rspamd_logger.errx(rspamd_config, 'rbl rule %s has invalid check type: %s', + rule.symbol, check) + return nil + end + else + rspamd_logger.infox(rspamd_config, 'disable check %s in %s: excluded explicitly', + check, rule.symbol) end end rule.connfilter = all_connfilter |