diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-01-27 09:05:40 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-01-27 09:05:40 +0000 |
commit | 6b1f319e218555610ada97755c97a8a8d32f436f (patch) | |
tree | 5a1e78679fa04a56b8a96388d15534f49d6eb918 /src/plugins | |
parent | 23c76ecda7d9d9807e57d5e509d9f0d2a669ef5b (diff) | |
download | rspamd-6b1f319e218555610ada97755c97a8a8d32f436f.tar.gz rspamd-6b1f319e218555610ada97755c97a8a8d32f436f.zip |
[Feature] Add extraction type for `from` maps
Attribute name: `extract_from`. Possible values:
* `default` - try smtp, if not exists try mime
* `mime` - check mime only
* `smtp` - check smtp only
* `both` - try to match both
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/multimap.lua | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 53b273227..191a87273 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -887,12 +887,36 @@ local function multimap_callback(task, rule) end end, from = function() - if task:has_from('smtp') then - local from = task:get_from('smtp') - match_addr(rule, from) - elseif task:has_from('mime') then + local extract_from = rule.extract_from or 'default' + + if extract_from == 'mime' then local from = task:get_from('mime') - match_addr(rule, from) + if from then + match_addr(rule, from) + end + elseif extract_from == 'smtp' then + local from = task:get_from('smtp') + if from then + match_addr(rule, from) + end + elseif extract_from == 'both' then + local from = task:get_from('smtp') + if from then + match_addr(rule, from) + end + from = task:get_from('mime') + if from then + match_addr(rule, from) + end + else + -- Default algorithm + if task:has_from('smtp') then + local from = task:get_from('smtp') + match_addr(rule, from) + elseif task:has_from('mime') then + local from = task:get_from('mime') + match_addr(rule, from) + end end end, helo = function() |