diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-15 13:33:54 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-02-15 13:33:54 +0000 |
commit | df1dc9accfa88feed20fd70d63f9e1951e974f27 (patch) | |
tree | 40ff5677b8c81612634545721e505f87016403cb | |
parent | 6ede0320dd6c2e4a8941194e700cbc563c134ae9 (diff) | |
download | rspamd-df1dc9accfa88feed20fd70d63f9e1951e974f27.tar.gz rspamd-df1dc9accfa88feed20fd70d63f9e1951e974f27.zip |
[Minor] Dkim_signing: allow custom routine for getting dkim domain
-rw-r--r-- | lualib/lua_dkim_tools.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lualib/lua_dkim_tools.lua b/lualib/lua_dkim_tools.lua index e07f3db5b..ec2dbd306 100644 --- a/lualib/lua_dkim_tools.lua +++ b/lualib/lua_dkim_tools.lua @@ -204,6 +204,31 @@ local function prepare_dkim_signing(N, task, settings) dkim_domain = get_dkim_domain('use_domain_sign_inbound') lua_util.debugm(N, task, 'inbound: use domain(%s) for signature: %s', settings.use_domain_sign_inbound, dkim_domain) + elseif settings.use_domain_custom then + if type(settings.use_domain_custom) == 'string' then + -- Load custom function + local loadstring = loadstring or load + local ret, res_or_err = pcall(loadstring(settings.use_domain_custom)) + if ret then + if type(res_or_err) == 'function' then + settings.use_domain_custom = res_or_err + dkim_domain = settings.use_domain_custom(task) + lua_util.debugm(N, task, 'use custom domain for signing: %s', + dkim_domain) + else + logger.errx(task, 'cannot load dkim domain custom script: invalid type: %s, expected function', + type(res_or_err)) + settings.use_domain_custom = nil + end + else + logger.errx(task, 'cannot load dkim domain custom script: %s', res_or_err) + settings.use_domain_custom = nil + end + else + dkim_domain = settings.use_domain_custom(task) + lua_util.debugm(N, task, 'use custom domain for signing: %s', + dkim_domain) + end else dkim_domain = get_dkim_domain('use_domain') lua_util.debugm(N, task, 'use domain(%s) for signature: %s', |