dont ratelimit tor users

This commit is contained in:
2026-10-10 18:19:14 -04:00
parent ca1c804eba
commit 836521b8d7
+14 -2
View File
@@ -9,12 +9,23 @@ class bot_protection{
// ratelimit requests per IP // ratelimit requests per IP
if(config::RATELIMIT_IP_SOURCE === false){ if(config::RATELIMIT_IP_SOURCE === false){
$source = "r" . $_SERVER["REMOTE_ADDR"]; $source = $_SERVER["REMOTE_ADDR"];
}else{ }else{
$source = "r" . $_SERVER[explode(";", strtoupper(str_replace("-", "_", config::IP_SOURCE)))[0]]; $source = $_SERVER[explode(";", strtoupper(str_replace("-", "_", config::IP_SOURCE)))[0]];
} }
// check if its not a local IP. Probably local tor bridge, dont ratelimit
if(
filter_var(
$source,
FILTER_VALIDATE_IP,
FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
) !== false
){
$source = "r." . $source;
// counter // counter
// resets on every req // resets on every req
$counter = apcu_fetch($source); $counter = apcu_fetch($source);
@@ -78,6 +89,7 @@ class bot_protection{
die(); die();
} }
} }
}
// check if we want captcha // check if we want captcha
if(config::BOT_PROTECTION !== 1){ if(config::BOT_PROTECTION !== 1){