From: Vsevolod Stakhov Date: Tue, 28 Jan 2020 18:57:40 +0000 (+0000) Subject: [Feature] Dkim_signing: Allow to sign via milter_headers X-Git-Tag: 2.3~30 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b5a80192d7db1ec7715b5845e6d165cb11d3b1ca;p=rspamd.git [Feature] Dkim_signing: Allow to sign via milter_headers --- 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