]> source.dussan.org Git - rspamd.git/commitdiff
Add DIRECT_TO_MX rule to once_received plugin
authorSteve Freegard <steve@stevefreegard.com>
Fri, 24 Mar 2017 19:31:27 +0000 (19:31 +0000)
committerSteve Freegard <steve@stevefreegard.com>
Fri, 24 Mar 2017 19:31:27 +0000 (19:31 +0000)
conf/modules.d/once_received.conf
src/plugins/lua/once_received.lua

index 93080d5317fb0c8d3dcf43b62aeea176dcc7e8d3..233d662ef6acf40198c45f906a937401df453550 100644 (file)
@@ -19,6 +19,7 @@ once_received {
     bad_host = "dynamic";
     symbol_strict = "ONCE_RECEIVED_STRICT";
     symbol = "ONCE_RECEIVED";
+    symbol_mx = "DIRECT_TO_MX";
 
     .include(try=true,priority=5) "${DBDIR}/dynamic/once_received.conf"
     .include(try=true,priority=1,duplicate=merge) "$LOCAL_CONFDIR/local.d/once_received.conf"
index 00161159f62d3d6acdf1f641b1be02fb28d07c5d..e1eea2ca502fac1b5bac8cd8c66f93ac0481c916 100644 (file)
@@ -18,6 +18,7 @@ limitations under the License.
 
 local symbol = 'ONCE_RECEIVED'
 local symbol_rdns = 'RDNS_NONE'
+local symbol_mx = 'DIRECT_TO_MX'
 -- Symbol for strict checks
 local symbol_strict = nil
 local bad_hosts = {}
@@ -40,6 +41,12 @@ local function check_quantity_received (task)
       if recvh and #recvh <= 1 then
         task:insert_result(symbol, 1)
         task:insert_result(symbol_strict, 1)
+        -- Check for MUAs
+        local ua = task:get_header('User-Agent')
+        local xm = task:get_header('X-Mailer')
+        if (ua or xm) then
+          task:insert_result(symbol_mx, 1, (ua or xm))
+        end
       end
       task:insert_result(symbol_rdns, 1)
     else
@@ -169,6 +176,8 @@ if opts then
       elseif n == 'whitelist' then
         whitelist = rspamd_map_add('once_received', 'whitelist', 'radix',
           'once received whitelist')
+      elseif n == 'symbol_mx' then
+        symbol_mx = v
       end
     end
 
@@ -182,5 +191,10 @@ if opts then
       type = 'virtual',
       parent = id
     })
+    rspamd_config:register_symbol({
+      name = symbol_mx,
+      type = 'virtual',
+      parent = id
+    })
   end
 end