]> source.dussan.org Git - rspamd.git/commitdiff
Add ability to skip local and/or authenticated 1666/head
authorAndré Peters <andryyy@users.noreply.github.com>
Tue, 6 Jun 2017 06:42:10 +0000 (08:42 +0200)
committerGitHub <noreply@github.com>
Tue, 6 Jun 2017 06:42:10 +0000 (08:42 +0200)
Default behavior remains.

src/plugins/lua/milter_headers.lua

index 7447cd208f2234133ed8d50ce25dcd5883944854..6ad7957a46cb814a6e0b85d2a37b212dbcf11080 100644 (file)
@@ -29,6 +29,8 @@ local E = {}
 local HOSTNAME = util.get_hostname()
 
 local settings = {
+  skip_local = false,
+  skip_authenticated = false,
   routines = {
     ['x-spamd-result'] = {
       header = 'X-Spamd-Result',
@@ -105,6 +107,15 @@ local custom_routines = {}
 
 local function milter_headers(task)
 
+  if settings.skip_local then
+    local ip = task:get_ip()
+    if (ip and ip:is_local()) then return end
+  end
+
+  if settings.skip_authenticated then
+    if task:get_user() ~= nil then return end
+  end
+
   local routines, common, add, remove = {}, {}, {}, {}
 
   routines['x-spamd-result'] = function()
@@ -352,6 +363,12 @@ if opts['extended_spam_headers'] then
   activate_routine('x-rspamd-server')
   activate_routine('x-rspamd-queue-id')
 end
+if opts['skip_local'] then
+  settings.skip_local = true
+end
+if opts['skip_authenticated'] then
+  settings.skip_authenticated = true
+end
 for _, s in ipairs(opts['use']) do
   if not have_routine[s] then
     activate_routine(s)