proxyServers = $proxyServers; $this->proxyServersComplex = $proxyServersComplex; } /** * Checks if an IP matches a proxy we've configured * * @param string $ip * @return bool */ public function isConfiguredProxy( $ip ) { // Quick check of known singular proxy servers if ( in_array( $ip, $this->proxyServers ) ) { return true; } // Check against addresses and CIDR nets in the complex list if ( !$this->proxyIPSet ) { $this->proxyIPSet = new IPSet( $this->proxyServersComplex ); } return $this->proxyIPSet->match( $ip ); } /** * Checks if an IP is a trusted proxy provider. * Useful to tell if X-Forwarded-For data is possibly bogus. * CDN cache servers for the site are whitelisted. * * @param string $ip * @return bool */ public function isTrustedProxy( $ip ) { $trusted = $this->isConfiguredProxy( $ip ); Hooks::run( 'IsTrustedProxy', [ &$ip, &$trusted ] ); return $trusted; } }