]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Multimap: received filters for extracting TLDs from hostnames
authorAndrew Lewis <nerf@judo.za.org>
Mon, 19 Jun 2017 15:02:13 +0000 (17:02 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Mon, 19 Jun 2017 15:02:13 +0000 (17:02 +0200)
src/plugins/lua/multimap.lua

index e2bde2a3211dcf03492fa2d40ab2ee7e614d8f32..0e7da23e10f7dfe75f984629517fb069ecdc6527 100644 (file)
@@ -551,7 +551,12 @@ local function multimap_callback(task, rule)
   end
 
   local function match_received_header(r, pos, total, h)
+    local use_tld = false
     local filter = r['filter'] or 'real_ip'
+    if filter:match('^tld:') then
+      filter = filter:sub(5)
+      use_tld = true
+    end
     local v = h[filter]
     if v then
       local min_pos = tonumber(r['min_pos'])
@@ -590,6 +595,9 @@ local function multimap_callback(task, rule)
           match_rule(r, v)
         end
       else
+        if use_tld and type(v) == 'string' then
+          v = util.get_tld(v)
+        end
         match_rule(r, v)
       end
     end