Comparison

plugins/mod_register_limits.lua @ 10286:23b26a414d71

mod_register_ibr, mod_register_limits: Add support for custom error type and defined-condition.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 29 Sep 2019 15:26:18 +0200
parent 8740:5dc8f509496c
child 10364:66943afdd7f3
comparison
equal deleted inserted replaced
10285:bcf61e22f841 10286:23b26a414d71
62 log("warn", "IP not known; can't apply blacklist/whitelist"); 62 log("warn", "IP not known; can't apply blacklist/whitelist");
63 elseif ip_in_set(blacklisted_ips, 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 event.error_type = "auth";
68 event.error_condition = "forbidden";
67 elseif (whitelist_only and not ip_in_set(whitelisted_ips, ip)) then 69 elseif (whitelist_only and not ip_in_set(whitelisted_ips, ip)) then
68 log("debug", "Registration disallowed by whitelist"); 70 log("debug", "Registration disallowed by whitelist");
69 event.allowed = false; 71 event.allowed = false;
70 event.reason = "Your IP address is not whitelisted"; 72 event.reason = "Your IP address is not whitelisted";
73 event.error_type = "auth";
74 event.error_condition = "forbidden";
71 elseif throttle_max and not ip_in_set(whitelisted_ips, ip) then 75 elseif throttle_max and not ip_in_set(whitelisted_ips, ip) then
72 if not check_throttle(ip) then 76 if not check_throttle(ip) then
73 log("debug", "Registrations over limit for ip %s", ip or "?"); 77 log("debug", "Registrations over limit for ip %s", ip or "?");
74 event.allowed = false; 78 event.allowed = false;
75 event.reason = "Too many registrations from this IP address recently"; 79 event.reason = "Too many registrations from this IP address recently";
80 event.error_type = "wait";
81 event.error_condition = "policy-violation";
76 end 82 end
77 end 83 end
78 end); 84 end);