diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-08-31 11:08:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-31 11:08:09 +0100 |
commit | ffbdb2535da524c09ee111aeff980000c71118ab (patch) | |
tree | e84717eca851b863cdacccc9e383134becd2e9ef /src/plugins | |
parent | c1795e08e52d65e6eb97bc4511948568265e135e (diff) | |
parent | 169892ea1cf03e4f82d4ebd6e005cfebca3e8b55 (diff) | |
download | rspamd-ffbdb2535da524c09ee111aeff980000c71118ab.tar.gz rspamd-ffbdb2535da524c09ee111aeff980000c71118ab.zip |
Merge pull request #917 from fatalbanana/rlimit
[Feature] Support excluding selected users from ratelimits
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/ratelimit.lua | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index e261a9275..b80a122f1 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -42,6 +42,7 @@ local bounce_senders = {'postmaster', 'mailer-daemon', '', 'null', 'fetchmail-da -- Do not check ratelimits for these recipients local whitelisted_rcpts = {'postmaster', 'mailer-daemon'} local whitelisted_ip +local whitelisted_user local max_rcpt = 5 local redis_params local ratelimit_symbol @@ -346,7 +347,11 @@ local function rate_test_set(task, func) -- Get user (authuser) local auser = task:get_user() if auser and settings['user'][1] > 0 then - table.insert(args, {settings['user'], make_rate_key ('user', {['user'] = auser}) }) + if whitelisted_user and whitelisted_user:get_key(auser) then + rspamd_logger.infox(task, 'skip ratelimit for whitelisted user') + else + table.insert(args, {settings['user'], make_rate_key ('user', {['user'] = auser}) }) + end end local asn if settings['asn'][1] > 0 then @@ -470,6 +475,10 @@ if opts then whitelisted_ip = rspamd_config:add_radix_map(opts['whitelisted_ip'], 'Ratelimit whitelist ip map') end + if opts['whitelisted_user'] then + whitelisted_user = rspamd_config:add_kv_map(opts['whitelisted_user'], 'Ratelimit whitelist user map') + end + if opts['symbol'] then -- We want symbol instead of pre-result ratelimit_symbol = opts['symbol'] |