Software / code / prosody
Comparison
plugins/mod_register_limits.lua @ 8738:9f0dc1bbc83b
mod_register_limits: Use existing local variable
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 10 Apr 2018 01:31:14 +0200 |
| parent | 8586:c3b87a37c100 |
| child | 8739:5fb525eb72a2 |
comparison
equal
deleted
inserted
replaced
| 8737:6d71845bf56f | 8738:9f0dc1bbc83b |
|---|---|
| 58 local session = event.session; | 58 local session = event.session; |
| 59 local ip = event.ip or session and session.ip; | 59 local ip = event.ip or session and session.ip; |
| 60 local log = session and session.log or module._log; | 60 local log = session and session.log or module._log; |
| 61 if not ip then | 61 if not ip then |
| 62 log("debug", "User's IP not known; can't apply blacklist/whitelist"); | 62 log("debug", "User's IP not known; can't apply blacklist/whitelist"); |
| 63 elseif ip_in_set(blacklisted_ips, event.ip) then | 63 elseif ip_in_set(blacklisted_ips, ip) then |
| 64 log("debug", "Registration disallowed by blacklist"); | 64 log("debug", "Registration disallowed by blacklist"); |
| 65 event.allowed = false; | 65 event.allowed = false; |
| 66 event.reason = "Your IP address is blacklisted"; | 66 event.reason = "Your IP address is blacklisted"; |
| 67 elseif (whitelist_only and not ip_in_set(whitelisted_ips, ip)) then | 67 elseif (whitelist_only and not ip_in_set(whitelisted_ips, ip)) then |
| 68 log("debug", "Registration disallowed by whitelist"); | 68 log("debug", "Registration disallowed by whitelist"); |
| 69 event.allowed = false; | 69 event.allowed = false; |
| 70 event.reason = "Your IP address is not whitelisted"; | 70 event.reason = "Your IP address is not whitelisted"; |
| 71 elseif throttle_max and not ip_in_set(whitelisted_ips, ip) then | 71 elseif throttle_max and not ip_in_set(whitelisted_ips, ip) then |
| 72 if not check_throttle(event.ip) then | 72 if not check_throttle(ip) then |
| 73 log("debug", "Registrations over limit for ip %s", ip or "?"); | 73 log("debug", "Registrations over limit for ip %s", ip or "?"); |
| 74 event.allowed = false; | 74 event.allowed = false; |
| 75 event.reason = "Too many registrations from this IP address recently"; | 75 event.reason = "Too many registrations from this IP address recently"; |
| 76 end | 76 end |
| 77 end | 77 end |