Modify Request::getClientIp() to use IpUtils::checkIp()
Adds the ability to use CIDR notation in the trusted proxy list
This commit is contained in:
parent
79cadc437d
commit
ddc9e3892f
@ -688,7 +688,16 @@ class Request
|
||||
|
||||
$trustedProxies = !self::$trustedProxies ? array($ip) : self::$trustedProxies;
|
||||
$ip = $clientIps[0];
|
||||
$clientIps = array_values(array_diff($clientIps, $trustedProxies));
|
||||
|
||||
foreach ($clientIps as $key => $clientIp) {
|
||||
foreach ($trustedProxies as $trustedProxy) {
|
||||
if (IpUtils::checkIp($clientIp, $trustedProxy)) {
|
||||
unset($clientIps[$key]);
|
||||
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $clientIps ? array_reverse($clientIps) : array($ip);
|
||||
}
|
||||
|
Reference in New Issue
Block a user