diff options
Diffstat (limited to 'lualib/rspamadm/fuzzy_stat.lua')
-rw-r--r-- | lualib/rspamadm/fuzzy_stat.lua | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lualib/rspamadm/fuzzy_stat.lua b/lualib/rspamadm/fuzzy_stat.lua index ef8a5de08..b9af35e22 100644 --- a/lualib/rspamadm/fuzzy_stat.lua +++ b/lualib/rspamadm/fuzzy_stat.lua @@ -59,7 +59,23 @@ local function add_data(target, src) if type(v.extensions.name) == 'string' then target.name = v.extensions.name end + if type(v.extensions.email) == 'string' then + target.email = v.extensions.email + end + if type(v.extensions.ratelimit) == 'table' then + if not target.ratelimit then + target.ratelimit = {} + end + -- Passed as {burst = x, rate = y} + target.ratelimit.limit = v.extensions.ratelimit + end + end + elseif k == 'ratelimit' then + if not target.ratelimit then + target.ratelimit = {} end + -- Ratelimit is passed as {cur = count, last = time} + target.ratelimit.cur = v end end end @@ -301,7 +317,8 @@ return function(args, res) for _, key in ipairs(sorted_keys) do local key_stat = key.data if key_stat.name then - print(string.format('Key id: %s, name: %s', key.key, key_stat.name)) + print(string.format('Key id: %s, name: %s (email: %s)', key.key, key_stat.name, + key_stat.email or 'unknown')) else print(string.format('Key id: %s', key.key)) end @@ -332,6 +349,16 @@ return function(args, res) end end + if key_stat.ratelimit then + print('') + print('\tRatelimit stat:') + print(string.format('\tLimit: %s (%s leak rate)', + print_num(key_stat.ratelimit.limit.burst), print_num(key_stat.ratelimit.limit.rate))) + print(string.format('\tCurrent: %s (%s last)', + print_num(key_stat.ratelimit.cur), os.date('%c', key_stat.ratelimit.last))) + print('') + end + print('') end end |