commit b5a8019: [Feature] Dkim_signing: Allow to sign via milter_headers
Vsevolod Stakhov
vsevolod at highsecure.ru
Tue Jan 28 20:56:06 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-01-28 18:57:40 +0000
URL: https://github.com/rspamd/rspamd/commit/b5a80192d7db1ec7715b5845e6d165cb11d3b1ca
[Feature] Dkim_signing: Allow to sign via milter_headers
---
src/plugins/lua/dkim_signing.lua | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/src/plugins/lua/dkim_signing.lua b/src/plugins/lua/dkim_signing.lua
index 283aa5051..24dbd20d6 100644
--- a/src/plugins/lua/dkim_signing.lua
+++ b/src/plugins/lua/dkim_signing.lua
@@ -44,13 +44,30 @@ local settings = {
use_esld = true,
use_redis = false,
key_prefix = 'dkim_keys', -- default hash name
+ use_milter_headers = false, -- use milter headers instead of `dkim_signature`
}
local N = 'dkim_signing'
local redis_params
local sign_func = rspamd_plugins.dkim.sign
+local function insert_sign_results(task, ret, hdr)
+ if settings.use_milter_headers then
+ task:set_milter_reply({
+ add_headers = {
+ ['DKIM-Signature'] = {order = 1, value = hdr},
+ }
+ })
+ end
+ if ret then
+ task:insert_result(settings.symbol, 1.0)
+ end
+end
+
local function do_sign(task, p)
+ if settings.use_milter_headers then
+ p.no_cache = true -- Disable caching in rspamd_mempool
+ end
if settings.check_pubkey then
local resolve_name = p.selector .. "._domainkey." .. p.domain
task:get_resolver():resolve_txt({
@@ -69,18 +86,14 @@ local function do_sign(task, p)
p.domain, p.selector, err)
end
- local sret, _ = sign_func(task, p)
- if sret then
- task:insert_result(settings.symbol, 1.0)
- end
+ local sret, hdr = sign_func(task, p)
+ insert_sign_results(task, sret, hdr)
end,
forced = true
})
else
- local sret, _ = sign_func(task, p)
- if sret then
- task:insert_result(settings.symbol, 1.0)
- end
+ local sret, hdr = sign_func(task, p)
+ insert_sign_results(task, sret, hdr)
end
end
More information about the Commits
mailing list