local opts = rspamd_config:get_all_opt('greylist')
if opts then
+ if opts['message_func'] then
+ settings.message_func = assert(loadstring(opts['message_func']))()
+ end
for k,v in pairs(opts) do
- settings[k] = v
+ if k ~= 'message_func' then
+ settings[k] = v
+ end
end
if settings['whitelisted_ip'] then
whitelisted_ip = rspamd_config:add_radix_map(settings['whitelisted_ip'],
local ip_score_ham_multiplier = 1.1
local ip_score_spam_divisor = 1.1
+local message_func = function(task, limit_type, bucket, threshold)
+ return string.format('Ratelimit "%s" exceeded', limit_type)
+end
+
local rspamd_logger = require "rspamd_logger"
local rspamd_redis = require "rspamd_redis"
local upstream_list = require "rspamd_upstream_list"
'ratelimit "%s" exceeded: %s elements with %s limit',
rtype, bucket, threshold)
task:set_pre_result('soft reject',
- string.format('Ratelimit "%s" exceeded', rtype))
+ message_func(task, rtype, bucket, threshold))
end
end
end
user_keywords = opts['user_keywords']
end
+ if opts['message_func'] then
+ message_func = assert(loadstring(opts['message_func']))()
+ end
+
redis_params = rspamd_parse_redis_server('ratelimit')
if not redis_params then
rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')