]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Milter headers: support adding/removing arbitrary headers from config
authorAndrew Lewis <nerf@judo.za.org>
Sun, 9 Jul 2017 10:21:31 +0000 (12:21 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Sun, 9 Jul 2017 10:22:16 +0000 (12:22 +0200)
src/plugins/lua/milter_headers.lua

index dcf8e9ffdf81ca08f88ff6d8a04aa29567fd572c..52cd874a67ab8b412a24add5c027a5376268740a 100644 (file)
@@ -35,6 +35,13 @@ local settings = {
   authenticated_headers = {},
   extended_headers_rcpt = {},
   routines = {
+    ['remove-headers'] = {
+      headers = {},
+    },
+    ['add-headers'] = {
+      headers = {},
+      remove = 1,
+    },
     ['remove-header'] = {
       remove = 1,
     },
@@ -201,6 +208,21 @@ local function milter_headers(task)
     end
   end
 
+  routines['remove-headers'] = function()
+    if skip_wanted('remove-headers') then return end
+    for h, r in pairs(settings.routines['remove-headers'].headers) do
+      remove[h] = r
+    end
+  end
+
+  routines['add-headers'] = function()
+    if skip_wanted('add-headers') then return end
+    for h, r in pairs(settings.routines['add-headers'].headers) do
+      add[h] = r
+      remove[h] = settings.routines['add-headers'].remove
+    end
+  end
+
   routines['x-rspamd-server'] = function()
     if skip_wanted('x-rspamd-server') then return end
     if settings.routines['x-rspamd-server'].remove then