aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-12-23 09:00:03 +0100
committerKim Alvefur <zash@zash.se>2015-12-23 09:00:03 +0100
commit8bef48f7a9b6041b3ff5c8704139d8bbbd6b614a (patch)
treeff7f1856409b197472676573f0841f0f80e55815
parentae05f1e162553a7477982a0b075463a77d809986 (diff)
downloadprosody-8bef48f7a9b6041b3ff5c8704139d8bbbd6b614a.tar.gz
prosody-8bef48f7a9b6041b3ff5c8704139d8bbbd6b614a.zip
mod_register: Support for blacklisting ips that are still over limit when they get pushed out of the cache
-rw-r--r--plugins/mod_register.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/mod_register.lua b/plugins/mod_register.lua
index ee196722..1961b276 100644
--- a/plugins/mod_register.lua
+++ b/plugins/mod_register.lua
@@ -180,8 +180,14 @@ local blacklisted_ips = module:get_option_set("registration_blacklist", {})._ite
local throttle_max = module:get_option_number("registration_throttle_max", min_seconds_between_registrations and 1);
local throttle_period = module:get_option_number("registration_throttle_period", min_seconds_between_registrations);
local throttle_cache_size = module:get_option_number("registration_throttle_cache_size", 100);
+local blacklist_overflow = module_get_option_boolean("blacklist_on_registration_throttle_overload", false);
-local throttle_cache = new_cache(throttle_cache_size);
+local throttle_cache = new_cache(throttle_cache_size, blacklist_overflow and function (ip, throttle)
+ if not throttle:peek() then
+ module:log("info", "Adding ip %s to registration blacklist", ip);
+ blacklisted_ips[ip] = true;
+ end
+end);
local function check_throttle(ip)
if not throttle_max then return true end