diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-15 12:17:15 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-08-15 12:17:15 +0100 |
commit | 729f6d3df5c1fb31c5e6801ab30474d8e16004f1 (patch) | |
tree | a1dbd37c9ee3f375c35bc0426cd136af219ee288 | |
parent | c5da4b573a5348dbc5aaa68c0629021d38794d35 (diff) | |
download | rspamd-729f6d3df5c1fb31c5e6801ab30474d8e16004f1.tar.gz rspamd-729f6d3df5c1fb31c5e6801ab30474d8e16004f1.zip |
[Feature] Add more ratelimits: by digest, by attachments data, by filenames
-rw-r--r-- | src/plugins/lua/ratelimit.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index c6caf6d41..59f3c0522 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -335,6 +335,48 @@ local keywords = { return task:get_principal_recipient() end, }, + ['digest'] = { + ['get_value'] = function(task) + return task:get_digest() + end, + }, + ['attachments'] = { + ['get_value'] = function(task) + local parts = task:get_parts() or E + local digests = {} + + for _,p in ipairs(parts) do + if p:get_filename() then + table.insert(digests, p:get_digest()) + end + end + + if #digests > 0 then + return table.concat(digests, '') + end + + return nil + end, + }, + ['files'] = { + ['get_value'] = function(task) + local parts = task:get_parts() or E + local files = {} + + for _,p in ipairs(parts) do + local fname = p:get_filename() + if fname then + table.insert(files, fname) + end + end + + if #files > 0 then + return table.concat(files, ':') + end + + return nil + end, + }, } local function gen_rate_key(task, rtype, bucket) |