diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-06-09 10:57:28 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-06-09 10:57:28 +0100 |
commit | f6390feadeb181f896b0bb5375109dc3c08b69e6 (patch) | |
tree | c1bd813cc84324684f3609b1277be755f6bcb762 /src/plugins/lua | |
parent | 9744413d49b6b0d2e6d0242f6f70aea3f1ef7f9a (diff) | |
download | rspamd-f6390feadeb181f896b0bb5375109dc3c08b69e6.tar.gz rspamd-f6390feadeb181f896b0bb5375109dc3c08b69e6.zip |
[Feature] Add top redirector targets rank
Diffstat (limited to 'src/plugins/lua')
-rw-r--r-- | src/plugins/lua/url_redirector.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/plugins/lua/url_redirector.lua b/src/plugins/lua/url_redirector.lua index 1c1c68808..8e1bb4f20 100644 --- a/src/plugins/lua/url_redirector.lua +++ b/src/plugins/lua/url_redirector.lua @@ -29,6 +29,8 @@ local settings = { check_ssl = false, -- check ssl certificates max_size = 10 * 1024, -- maximum body to process redirectors_only = true, -- follow merely redirectors + top_urls_key = 'rdr:top_urls', -- key for top urls + top_urls_count = 200, -- how many top urls to save } local rspamd_logger = require "rspamd_logger" @@ -43,7 +45,7 @@ local function cache_url(task, orig_url, url, key, param) rspamd_plugins.surbl.continue_process(url, param) end - local ret = rspamd_redis_make_request(task, + local ret,conn,_ = rspamd_redis_make_request(task, redis_params, -- connect params key, -- hash key true, -- is write @@ -53,6 +55,10 @@ local function cache_url(task, orig_url, url, key, param) ) if not ret then rspamd_logger.errx(task, 'cannot make redis request to cache results') + else + conn:add_cmd('ZINCRBY', {settings.top_urls_key, '1', url}) + conn:add_cmd('ZREMRANGEBYRANK', {settings.top_urls_key, '0', + tostring(settings.top_urls_count + 1)}) end end |