aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-20 15:32:05 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-11-20 15:32:05 +0000
commit9bf58ab96ace3f7cde3e7cab9a2344a8130bb4f7 (patch)
tree326341a439024da7ecfefc4b6821206c12f588dd /src
parent22cab77cc47d08152d3608e560a56d910a54462c (diff)
downloadrspamd-9bf58ab96ace3f7cde3e7cab9a2344a8130bb4f7.tar.gz
rspamd-9bf58ab96ace3f7cde3e7cab9a2344a8130bb4f7.zip
[Feature] Set expire for dmarc reports
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/dmarc.lua17
1 files changed, 16 insertions, 1 deletions
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