diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-06-15 23:25:57 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-06-15 23:26:15 +0100 |
commit | 4c63ac0b3fa585cbdf3d63b89830c8297279f30c (patch) | |
tree | 5d872f4972c4c7c5fd044f8c5032db4dbb336d62 | |
parent | 41ac6b23235a61532b04340dd651c1659fb4066b (diff) | |
download | rspamd-4c63ac0b3fa585cbdf3d63b89830c8297279f30c.tar.gz rspamd-4c63ac0b3fa585cbdf3d63b89830c8297279f30c.zip |
[Fix] Fix rspamc detection in greylist module
-rw-r--r-- | src/plugins/lua/greylist.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua index aeb5ca75f..292d1fcaa 100644 --- a/src/plugins/lua/greylist.lua +++ b/src/plugins/lua/greylist.lua @@ -206,7 +206,8 @@ local function greylist_check(task) end_time, type) task:insert_result(settings['symbol'], 0.0, 'greylisted', end_time) - if not task:get_queue_id() then return end -- Likely rspamc scan + local ua = task:get_request_header('User-Agent') or '' + if ua == 'rspamc' then return end -- Likely rspamc scan if settings.message_func then task:set_pre_result('soft reject', @@ -309,7 +310,10 @@ local function greylist_set(task) end end - local qid = task:get_queue_id() + local ua = task:get_request_header('User-Agent') or '' + local is_rspamc = false + if ua == 'rspamc' then is_rspamc = true end + if is_whitelisted then if action == 'greylist' then -- We are going to accept message @@ -322,7 +326,8 @@ local function greylist_set(task) is_whitelisted, rspamd_util.time_to_string(rspamd_util.get_time() + settings['expire'])) - if not qid then return end + if is_rspamc then return end + ret,conn,upstream = rspamd_redis_make_request(task, redis_params, -- connect params hash_key, -- hash key @@ -340,12 +345,13 @@ local function greylist_set(task) rspamd_logger.errx(task, 'got error while connecting to redis') end elseif do_greylisting or do_greylisting_required then + if is_rspamc then return end local t = tostring(toint(rspamd_util.get_time())) local end_time = rspamd_util.time_to_string(t + settings['timeout']) rspamd_logger.infox(task, 'greylisted until "%s", new record', end_time) task:insert_result(settings['symbol'], 0.0, 'greylisted', end_time, 'new record') - if not qid then return end + task:set_pre_result(settings['action'], settings['message']) task:set_flag('greylisted') -- Create new record @@ -385,7 +391,7 @@ local function greylist_set(task) end end task:set_metric_action('default', settings['action']) - if not qid then return end + if is_rspamc then return end task:set_pre_result(settings['action'], settings['message']) task:set_flag('greylisted') else |