Esempio n. 1
0
 /**
  * Validates IPSet loading and matching code
  *
  * @covers IPSet
  * @dataProvider provideIPSets
  */
 public function testIPSet($desc, array $cfg, array $tests)
 {
     $ipset = new IPSet($cfg);
     foreach ($tests as $ip => $expected) {
         $result = $ipset->match($ip);
         $this->assertEquals($expected, $result, "Incorrect match() result for {$ip} in dataset {$desc}");
     }
 }
Esempio n. 2
0
 /**
  * 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;
 }