From 8c045e1416977693b31c9ed086fcbb3b3b71aa8d Mon Sep 17 00:00:00 2001 From: Andrew Lewis Date: Wed, 30 Aug 2017 13:23:12 +0200 Subject: [Minor] Ratelimit: fix getting values from custom routines; silence logging --- src/plugins/lua/ratelimit.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src') 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 -- cgit v1.2.3