diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-12-12 14:59:24 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-12-12 14:59:24 +0000 |
commit | 70076b2ebb592b46fc7b9de912d60e1560fcc0f8 (patch) | |
tree | 9ff265fa84f66556899afc840aedfda73f49cdb9 /src | |
parent | 5b78c367b9cf45c1f32c30ec2e6783fc4c380e63 (diff) | |
download | rspamd-70076b2ebb592b46fc7b9de912d60e1560fcc0f8.tar.gz rspamd-70076b2ebb592b46fc7b9de912d60e1560fcc0f8.zip |
[Feature] Settings: Allow to inverse conditions
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/lua/settings.lua | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index 62fd63ec7..a6ce955c1 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -214,7 +214,6 @@ local function check_settings(task) if ip:is_local() then matched[#matched + 1] = 'local' res = true - break else return nil end @@ -414,18 +413,19 @@ local function check_settings(task) local rule = check_specific_setting(s.name, s.rule, ip, client_ip, from, rcpt, user, uname, hostname, matched) - if rule then + -- Can use xor here but more complicated for reading + if (rule and not s.rule.inverse) or (not rule and s.rule.inverse) then rspamd_logger.infox(task, "<%s> apply settings according to rule %s (%s matched)", task:get_message_id(), s.name, table.concat(matched, ',')) - if rule['apply'] then - apply_settings(task, rule['apply']) + if s.rule['apply'] then + apply_settings(task, s.rule['apply']) applied = true end - if rule['symbols'] then + if s.rule['symbols'] then -- Add symbols, specified in the settings fun.each(function(val) task:insert_result(val, 1.0) - end, rule['symbols']) + end, s.rule['symbols']) end end end @@ -601,6 +601,9 @@ local function process_settings_table(tbl) if elt['local'] then out['local'] = true end + if elt['inverse'] then + out['inverse'] = true + end if elt['request_header'] then local rho = {} for k, v in pairs(elt['request_header']) do |