]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Whitelist for emails module 2070/head
authorAndrew Lewis <nerf@judo.za.org>
Tue, 13 Mar 2018 09:46:21 +0000 (11:46 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Tue, 13 Mar 2018 09:46:21 +0000 (11:46 +0200)
src/plugins/lua/emails.lua

index 65e6b433e15c8236781e45d47d8d3fe00377d757..12e94a9323c5a15009f0f0b0aa302c77135cc1aa 100644 (file)
@@ -32,6 +32,13 @@ local N = "emails"
 
 -- Check rule for a single email
 local function check_email_rule(task, rule, addr)
+  if rule['whitelist'] then
+    if rule['whitelist']:get_key(addr.addr)
+      or rule['whitelist']:get_key(addr.domain) then
+        logger.debugm(N, task, "whitelisted address: %s", addr.addr)
+        return
+    end
+  end
   if rule['dnsbl'] then
     local email
     local to_resolve
@@ -175,6 +182,14 @@ if opts and type(opts) == 'table' then
       rule['delimiter'] = "@"
     end
 
+    if rule['whitelist'] then
+      rule['whitelist'] = rspamd_config:add_map({
+        url = rule['whitelist'],
+        description = string.format('Emails rule %s whitelist', rule['symbol']),
+        type = 'set'
+      })
+    end
+
     if rule['map'] then
       rule['name'] = rule['map']
       rule['map'] = rspamd_config:add_map({