From f637f187e2995552cfdf2a60348fc61bdec0726f Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Sun, 9 Jul 2017 12:21:31 +0200 Subject: [PATCH] [Feature] Milter headers: support adding/removing arbitrary headers from config --- src/plugins/lua/milter_headers.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/plugins/lua/milter_headers.lua b/src/plugins/lua/milter_headers.lua index d5b4c4909..f3d698c24 100644 --- a/src/plugins/lua/milter_headers.lua +++ b/src/plugins/lua/milter_headers.lua @@ -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 -- 2.39.5