]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Add expected ip check for emails plugin
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 15 Jul 2017 22:26:54 +0000 (23:26 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 15 Jul 2017 22:29:02 +0000 (23:29 +0100)
src/plugins/lua/emails.lua

index 97378924fce2c07d23eea32ed3ba018538c88a80..aeb2bc7cdfe8f179d16cc174227e4387ab9de471 100644 (file)
@@ -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