From: Vsevolod Stakhov Date: Sun, 20 Nov 2016 15:32:05 +0000 (+0000) Subject: [Feature] Set expire for dmarc reports X-Git-Tag: 1.4.0~6 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9bf58ab96ace3f7cde3e7cab9a2344a8130bb4f7;p=rspamd.git [Feature] Set expire for dmarc reports --- diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua index 400882755..58d186106 100644 --- a/src/plugins/lua/dmarc.lua +++ b/src/plugins/lua/dmarc.lua @@ -49,6 +49,8 @@ local dmarc_symbols = { -- Default port for redis upstreams local redis_params = nil local dmarc_redis_key_prefix = "dmarc_" +-- 2 days +local dmarc_redis_key_expire = 60 * 60 * 24 * 2 local dmarc_reporting = false local dmarc_actions = {} @@ -330,7 +332,7 @@ local function dmarc_callback(task) local report_data = dmarc_report(task, spf_ok, dkim_ok, disposition) if report_data then - rspamd_redis_make_request(task, + local ret,conn,upstream = rspamd_redis_make_request(task, redis_params, -- connect params from[1]['domain'], -- hash key true, -- is write @@ -338,6 +340,11 @@ local function dmarc_callback(task) 'LPUSH', -- command {redis_key, report_data} -- arguments ) + if ret and conn then + conn:add_cmd('EXPIRE', { + redis_key, tostring(dmarc_redis_key_expire) + }) + end end end @@ -393,6 +400,14 @@ if opts['key_prefix'] then dmarc_redis_key_prefix = opts['key_prefix'] end +if opts['expire'] then + dmarc_redis_key_expire = opts['expire'] +end + +if opts['key_expire'] then + dmarc_redis_key_expire = opts['key_expire'] +end + -- Check spf and dkim sections for changed symbols local function check_mopt(var, m_opts, name) if m_opts[name] then