diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-15 23:26:54 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-07-15 23:29:02 +0100 |
commit | e97e120cd2d57337401e9524807c7ec6eb35a2ac (patch) | |
tree | 278ce4e1333fae434e2da355a1b4b42af64d5b2a /src/plugins/lua/emails.lua | |
parent | 53042312ffe56d89ac896871a5906d05f41f532c (diff) | |
download | rspamd-e97e120cd2d57337401e9524807c7ec6eb35a2ac.tar.gz rspamd-e97e120cd2d57337401e9524807c7ec6eb35a2ac.zip |
[Feature] Add expected ip check for emails plugin
Diffstat (limited to 'src/plugins/lua/emails.lua')
-rw-r--r-- | src/plugins/lua/emails.lua | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/plugins/lua/emails.lua b/src/plugins/lua/emails.lua index 97378924f..aeb2bc7cd 100644 --- a/src/plugins/lua/emails.lua +++ b/src/plugins/lua/emails.lua @@ -47,10 +47,26 @@ local function check_email_rule(task, rule, addr) and err ~= 'no records with this name') then logger.errx(task, 'Error querying DNS: %1', err) elseif results then - if rule['hash'] then - task:insert_result(rule['symbol'], 1.0, {email, to_resolve}) + local expected_found = false + + if rule['expect_ip'] then + for _,result in pairs(results) do + local ipstr = result:to_string() + + if ipstr == rule['expect_ip'] then + expected_found = true + end + end else - task:insert_result(rule['symbol'], 1.0, email) + expected_found = true -- Accept any result + end + + if expected_found then + if rule['hash'] then + task:insert_result(rule['symbol'], 1.0, {email, to_resolve}) + else + task:insert_result(rule['symbol'], 1.0, email) + end end end |