/** * 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 matches a proxy we've configured * @since 1.24 * * @param string $ip * @return bool */ public static function isConfiguredProxy($ip) { global $wgSquidServers, $wgSquidServersNoPurge; // Quick check of known singular proxy servers $trusted = in_array($ip, $wgSquidServers); // Check against addresses and CIDR nets in the NoPurge list if (!$trusted) { if (!self::$proxyIpSet) { self::$proxyIpSet = new IPSet($wgSquidServersNoPurge); } $trusted = self::$proxyIpSet->match($ip); } return $trusted; }
/** * Determine if an IP address really is an IP address, and if it is public, * i.e. not RFC 1918 or similar * * @param string $ip * @return bool */ public static function isPublic($ip) { static $privateSet = null; if (!$privateSet) { $privateSet = new IPSet(['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '0.0.0.0/8', '127.0.0.0/8', 'fc00::/7', '0:0:0:0:0:0:0:1', '169.254.0.0/16', 'fe80::/10']); } return !$privateSet->match($ip); }