diff options
author | Andrew Lewis <nerf@judo.za.org> | 2017-05-09 12:56:26 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-05-09 12:56:26 +0200 |
commit | f3d94b40188ca1f439c033ad807637807bc150e7 (patch) | |
tree | ea85242a2860bb855af68935669283dc337bb902 | |
parent | 81c94076a9c2b9f28ec98092f7574d9fce3da21d (diff) | |
parent | ab587d5b2ccabd9aa062bcb5a069f9acb6e64438 (diff) | |
download | rspamd-f3d94b40188ca1f439c033ad807637807bc150e7.tar.gz rspamd-f3d94b40188ca1f439c033ad807637807bc150e7.zip |
Merge branch 'andryyy-patch-5'
-rw-r--r-- | src/plugins/lua/dkim_signing.lua | 77 |
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 |