Software / code / prosody
Comparison
plugins/mod_register.lua @ 7027:77d838ba91c6
mod_register: Support for blacklisting ips that are still over limit when they get pushed out of the cache
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 23 Dec 2015 09:00:03 +0100 |
| parent | 7026:f0dc5cc11d0e |
| child | 7037:5d52e4ee2ae1 |
comparison
equal
deleted
inserted
replaced
| 7026:f0dc5cc11d0e | 7027:77d838ba91c6 |
|---|---|
| 178 local blacklisted_ips = module:get_option_set("registration_blacklist", {})._items; | 178 local blacklisted_ips = module:get_option_set("registration_blacklist", {})._items; |
| 179 | 179 |
| 180 local throttle_max = module:get_option_number("registration_throttle_max", min_seconds_between_registrations and 1); | 180 local throttle_max = module:get_option_number("registration_throttle_max", min_seconds_between_registrations and 1); |
| 181 local throttle_period = module:get_option_number("registration_throttle_period", min_seconds_between_registrations); | 181 local throttle_period = module:get_option_number("registration_throttle_period", min_seconds_between_registrations); |
| 182 local throttle_cache_size = module:get_option_number("registration_throttle_cache_size", 100); | 182 local throttle_cache_size = module:get_option_number("registration_throttle_cache_size", 100); |
| 183 | 183 local blacklist_overflow = module_get_option_boolean("blacklist_on_registration_throttle_overload", false); |
| 184 local throttle_cache = new_cache(throttle_cache_size); | 184 |
| 185 local throttle_cache = new_cache(throttle_cache_size, blacklist_overflow and function (ip, throttle) | |
| 186 if not throttle:peek() then | |
| 187 module:log("info", "Adding ip %s to registration blacklist", ip); | |
| 188 blacklisted_ips[ip] = true; | |
| 189 end | |
| 190 end); | |
| 185 | 191 |
| 186 local function check_throttle(ip) | 192 local function check_throttle(ip) |
| 187 if not throttle_max then return true end | 193 if not throttle_max then return true end |
| 188 local throttle = throttle_cache:get(ip); | 194 local throttle = throttle_cache:get(ip); |
| 189 if not throttle then | 195 if not throttle then |