# HG changeset patch # User Kim Alvefur # Date 1450857603 -3600 # Node ID 77d838ba91c6b74ee7cea90e7f3775b042727354 # Parent f0dc5cc11d0e033e65dcb1cba0fd1f28f08afc83 mod_register: Support for blacklisting ips that are still over limit when they get pushed out of the cache diff -r f0dc5cc11d0e -r 77d838ba91c6 plugins/mod_register.lua --- a/plugins/mod_register.lua Wed Dec 23 08:58:34 2015 +0100 +++ b/plugins/mod_register.lua Wed Dec 23 09:00:03 2015 +0100 @@ -180,8 +180,14 @@ 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