$remoteAddr =
$request->server->
get('REMOTE_ADDR'
);
if (!
$remoteAddr || !IpUtils::
checkIp($remoteAddr,
$trustedProxies)) { $trustedHeaders =
[ 'FORWARDED' =>
$trustedHeaderSet & Request::HEADER_FORWARDED,
'X_FORWARDED_FOR' =>
$trustedHeaderSet & Request::HEADER_X_FORWARDED_FOR,
'X_FORWARDED_HOST' =>
$trustedHeaderSet & Request::HEADER_X_FORWARDED_HOST,
'X_FORWARDED_PROTO' =>
$trustedHeaderSet & Request::HEADER_X_FORWARDED_PROTO,
'X_FORWARDED_PORT' =>
$trustedHeaderSet & Request::HEADER_X_FORWARDED_PORT,
'X_FORWARDED_PREFIX' =>
$trustedHeaderSet & Request::HEADER_X_FORWARDED_PREFIX,
];
foreach (array_filter($trustedHeaders) as $name =>
$key) { $request->headers->
remove($name);
$request->server->
remove('HTTP_'.
$name);
} } // compute trusted values, taking any trusted proxies into account
$trustedIps =
[];
$trustedValues =
[];
foreach (array_reverse($request->
getClientIps()) as $ip) { $trustedIps[] =
$ip;
$trustedValues[] =
sprintf('for="%s"',
$ip);
}