Comparison

plugins/mod_register_limits.lua @ 8586:c3b87a37c100

mod_register_limits: Return reason for disallowing
author Kim Alvefur <zash@zash.se>
date Sat, 10 Mar 2018 02:28:29 +0100
parent 8585:046041a37c1e
child 8738:9f0dc1bbc83b
comparison
equal deleted inserted replaced
8585:046041a37c1e 8586:c3b87a37c100
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, event.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 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
67 log("debug", "Registration disallowed by whitelist"); 68 log("debug", "Registration disallowed by whitelist");
68 event.allowed = false; 69 event.allowed = false;
70 event.reason = "Your IP address is not whitelisted";
69 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
70 if not check_throttle(event.ip) then 72 if not check_throttle(event.ip) then
71 log("debug", "Registrations over limit for ip %s", ip or "?"); 73 log("debug", "Registrations over limit for ip %s", ip or "?");
72 event.allowed = false; 74 event.allowed = false;
75 event.reason = "Too many registrations from this IP address recently";
73 end 76 end
74 end 77 end
75 end); 78 end);