summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndré Peters <andryyy@users.noreply.github.com>2017-05-08 19:05:00 +0200
committerGitHub <noreply@github.com>2017-05-08 19:05:00 +0200
commitab587d5b2ccabd9aa062bcb5a069f9acb6e64438 (patch)
treeea85242a2860bb855af68935669283dc337bb902 /src
parent81c94076a9c2b9f28ec98092f7574d9fce3da21d (diff)
downloadrspamd-ab587d5b2ccabd9aa062bcb5a069f9acb6e64438.tar.gz
rspamd-ab587d5b2ccabd9aa062bcb5a069f9acb6e64438.zip
Add ability to read selector from Redis
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/dkim_signing.lua77
1 files changed, 50 insertions, 27 deletions
diff --git a/src/plugins/lua/dkim_signing.lua b/src/plugins/lua/dkim_signing.lua
index 08fe0972d..b76a73acb 100644
--- a/src/plugins/lua/dkim_signing.lua
+++ b/src/plugins/lua/dkim_signing.lua
@@ -185,36 +185,59 @@ local function dkim_signing_cb(task)
end
if settings.use_redis then
- if not p.selector then
- rspamd_logger.errx(task, 'No selector specified')
- return false
- end
- p.key = nil
- local rk = string.format('%s.%s', p.selector, p.domain)
-
- local function redis_key_cb(err, data)
- if err or type(data) ~= 'string' then
- rspamd_logger.infox(rspamd_config, "cannot make request to load DKIM key for %s: %s",
- rk, err)
- else
- p.rawkey = data
- if rspamd_plugins.dkim.sign(task, p) then
- task:insert_result(settings.symbol, 1.0)
+ local function try_redis_key(selector)
+ p.key = nil
+ p.selector = selector
+ local rk = string.format('%s.%s', p.selector, p.domain)
+ local function redis_key_cb(err, data)
+ if err or type(data) ~= 'string' then
+ rspamd_logger.infox(rspamd_config, "cannot make request to load DKIM key for %s: %s",
+ rk, err)
+ else
+ p.rawkey = data
+ if rspamd_plugins.dkim.sign(task, p) then
+ task:insert_result(settings.symbol, 1.0)
+ end
end
end
+ local ret = rspamd_redis_make_request(task,
+ redis_params, -- connect params
+ rk, -- hash key
+ false, -- is write
+ redis_key_cb, --callback
+ 'HGET', -- command
+ {settings.key_prefix, rk} -- arguments
+ )
+ if not ret then
+ rspamd_logger.infox(rspamd_config, "cannot make request to load DKIM key for %s", rk)
+ end
end
-
- local ret = rspamd_redis_make_request(task,
- redis_params, -- connect params
- rk, -- hash key
- false, -- is write
- redis_key_cb, --callback
- 'HGET', -- command
- {settings.key_prefix, rk} -- arguments
- )
-
- if not ret then
- rspamd_logger.infox(rspamd_config, "cannot make request to load DKIM key for %s", rk)
+ if settings.selector_prefix then
+ rspamd_logger.infox(rspamd_config, "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(rspamd_config, "cannot make request to load DKIM selector for domain %s: %s", p.domain, err)
+ else
+ try_redis_key(data)
+ end
+ end
+ local ret = rspamd_redis_make_request(task,
+ redis_params, -- connect params
+ p.domain, -- hash key
+ false, -- is write
+ redis_selector_cb, --callback
+ 'HGET', -- command
+ {settings.selector_prefix, p.domain} -- arguments
+ )
+ if not ret then
+ rspamd_logger.infox(rspamd_config, "cannot make request to load DKIM selector for %s", p.domain)
+ end
+ else
+ if not p.selector then
+ rspamd_logger.errx(task, 'No selector specified')
+ return false
+ end
+ try_redis_key(p.selector)
end
else
if (p.key and p.selector) then