]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Added check_authed and check_local for spamtrap 1882/head
authorChristian Roessner <c@roessner-network-solutions.com>
Thu, 26 Oct 2017 10:56:41 +0000 (12:56 +0200)
committerChristian Roessner <c@roessner-network-solutions.com>
Thu, 26 Oct 2017 10:56:41 +0000 (12:56 +0200)
conf/modules.d/spamtrap.conf
src/plugins/lua/spamtrap.lua

index e6b676a5dd08de1df6d46ec8c5b0c63bc971de03..07c28f9c5f91f3993c8de7831bdfb31fc97766d4 100644 (file)
@@ -40,6 +40,10 @@ spamtrap {
   #fuzy_weight = 10;
   # Redis key prefix
   #key_prefix = 'sptr_';
+  # Skip spamtrap checks for authorized users
+  #check_authed = false;
+  # Skip spamtrap checks for local networks
+  #check_local = false;
 
   # !!! Disabled by default !!!
   enabled = false;
index 33805b592b76348670f09fce21be2f4676d32036..af2523187de10036cb77d073efe42f5cbb934cf9 100644 (file)
@@ -29,14 +29,24 @@ local settings = {
   learn_spam = false,
   fuzzy_flag = 1,
   fuzzy_weight = 10.0,
-  key_prefix = 'sptr_'
+  key_prefix = 'sptr_',
+  check_authed = true,
+  check_local = true
 }
 
 local function spamtrap_cb(task)
   local rcpts = task:get_recipients('smtp')
+  local authed_user = task:get_user()
+  local ip_addr = task:get_ip()
   local called_for_domain = false
   local target
 
+  if ((not settings['check_authed'] and authed_user) or
+      (not settings['check_local'] and ip_addr and ip_addr:is_local())) then
+    rspamd_logger.infox(task, "skip spamtrap checks for local networks or authenticated user");
+    return
+  end
+
   local function do_action(rcpt)
     if settings['learn_fuzzy'] then
       rspamd_plugins.fuzzy_check.learn(task,