Browse Source

[Minor] Improve dkim signing debugging

tags/1.8.0
Vsevolod Stakhov 5 years ago
parent
commit
2383b6755d
2 changed files with 17 additions and 4 deletions
  1. 7
    0
      lualib/lua_dkim_tools.lua
  2. 10
    4
      src/plugins/lua/dkim_signing.lua

+ 7
- 0
lualib/lua_dkim_tools.lua View File

@@ -178,12 +178,15 @@ local function prepare_dkim_signing(N, task, settings)
lua_util.debugm(N, task, 'dkim unconfigured and fallback disabled')
return false,{}
end

lua_util.debugm(N, task, 'override selector and key to %s:%s', p.key, p.selector)
end

if not p.selector and settings.selector_map then
local data = settings.selector_map:get_key(dkim_domain)
if data then
p.selector = data
lua_util.debugm(N, task, 'override selector to "%s" using selector_map', p.selector)
elseif not settings.try_fallback then
lua_util.debugm(N, task, 'no selector for %s', dkim_domain)
return false,{}
@@ -194,6 +197,7 @@ local function prepare_dkim_signing(N, task, settings)
local data = settings.path_map:get_key(dkim_domain)
if data then
p.key = data
lua_util.debugm(N, task, 'override key to "%s" using path_map', p.key)
elseif not settings.try_fallback then
lua_util.debugm(N, task, 'no key for %s', dkim_domain)
return false,{}
@@ -203,12 +207,15 @@ local function prepare_dkim_signing(N, task, settings)
if not p.key then
if not settings.use_redis then
p.key = settings.path
lua_util.debugm(N, task, 'use default key "%s" from path', p.key)
end
end

if not p.selector then
p.selector = settings.selector
lua_util.debugm(N, task, 'use default selector "%s"', p.selector)
end

p.domain = dkim_domain

return true,p

+ 10
- 4
src/plugins/lua/dkim_signing.lua View File

@@ -106,6 +106,8 @@ local function dkim_signing_cb(task)
lua_util.debugm(N, task, "missing DKIM key for %s", rk)
else
p.rawkey = data
lua_util.debugm(N, task, 'found and parsed key for %s:%s in Redis',
p.domain, p.selector)
do_sign()
end
end
@@ -122,7 +124,8 @@ local function dkim_signing_cb(task)
end
end
if settings.selector_prefix then
rspamd_logger.infox(task, "Using selector prefix %s for domain %s", settings.selector_prefix, p.domain);
rspamd_logger.infox(task, "Using selector prefix '%s' for domain '%s'",
settings.selector_prefix, p.domain);
local function redis_selector_cb(err, data)
if err or type(data) ~= 'string' then
rspamd_logger.infox(task, "cannot make request to load DKIM selector for domain %s: %s", p.domain, err)
@@ -139,7 +142,7 @@ local function dkim_signing_cb(task)
{settings.selector_prefix, p.domain} -- arguments
)
if not rret then
rspamd_logger.infox(task, "cannot make request to load DKIM selector for %s", p.domain)
rspamd_logger.infox(task, "cannot make request to load DKIM selector for '%s'", p.domain)
end
else
if not p.selector then
@@ -154,13 +157,16 @@ local function dkim_signing_cb(task)
local exists,err = rspamd_util.file_exists(p.key)
if not exists then
if err and err == 'No such file or directory' then
lua_util.debugm(N, task, 'cannot read key from %s: %s', p.key, err)
lua_util.debugm(N, task, 'cannot read key from "%s": %s', p.key, err)
else
rspamd_logger.warnx(N, task, 'cannot read key from %s: %s', p.key, err)
rspamd_logger.warnx(N, task, 'cannot read key from "%s": %s', p.key, err)
end
return false
end

lua_util.debugm(N, task, 'key found at "%s", use selector "%s" for domain "%s"',
p.key, p.selector, p.domain)

do_sign()
else
rspamd_logger.infox(task, 'key path or dkim selector unconfigured; no signing')

Loading…
Cancel
Save