diff options
author | Andrew Lewis <nerf@judo.za.org> | 2017-08-30 13:23:12 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-08-30 13:23:12 +0200 |
commit | 8c045e1416977693b31c9ed086fcbb3b3b71aa8d (patch) | |
tree | 465cd3cd75f07eb7719bc58511f18179b041d17c /src/plugins/lua/ratelimit.lua | |
parent | 871443d92d23e90041784cd4c4bd15238c606f9b (diff) | |
download | rspamd-8c045e1416977693b31c9ed086fcbb3b3b71aa8d.tar.gz rspamd-8c045e1416977693b31c9ed086fcbb3b3b71aa8d.zip |
[Minor] Ratelimit: fix getting values from custom routines; silence logging
Diffstat (limited to 'src/plugins/lua/ratelimit.lua')
-rw-r--r-- | src/plugins/lua/ratelimit.lua | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index b05ed0114..b8d211ae7 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -182,7 +182,7 @@ local function load_scripts(cfg, ev_base) end local limit_parser -local function parse_string_limit(lim) +local function parse_string_limit(lim, no_error) local function parse_time_suffix(s) if s == 's' then return 1 @@ -238,7 +238,9 @@ local function parse_string_limit(lim) return t[2], t[1] end - rspamd_logger.errx(rspamd_config, 'bad limit: %s', lim) + if not no_error then + rspamd_logger.errx(rspamd_config, 'bad limit: %s', lim) + end return nil end @@ -534,7 +536,7 @@ local function ratelimit_cb(task) local res = custom_keywords[settings[k]]['get_limit'](task) if type(res) == 'string' then res = {res} end for _, r in ipairs(res) do - local plim, size = parse_string_limit(r) + local plim, size = parse_string_limit(r, true) if plim then table.insert(args, {{plim, size}, rk}) else @@ -555,11 +557,11 @@ local function ratelimit_cb(task) local res = custom_keywords[settings[k]]['get_limit'](task) if type(res) == 'string' then res = {res} end for _, r in ipairs(res) do - local plim, size = parse_string_limit(r) + local plim, size = parse_string_limit(r, true) if plim then table.insert(args, {{plim, size}, rate_key}) else - local rkey = string.match(settings[k], 'redis:(.*)') + local rkey = string.match(r, 'redis:(.*)') if rkey then table.insert(redis_keys, rkey) redis_keys_rev[#redis_keys] = rate_key |