Esempio n. 1
0
 /**
  * @return IP
  * @throws NoRemoteIPException
  */
 public function createRemoteIP()
 {
     if ($this->cloudflareDetector->isCloudflareRequest()) {
         return new IP($this->cloudflareDetector->getConnectingRequestIp());
     } else {
         return $this->fallback->createRemoteIP();
     }
 }
 public function testIsCloudflareRequestIntegrationTest()
 {
     $ipAddresses = new CloudflareIpAddresses();
     $ipAddressWithMask = reset($ipAddresses->getIpV4Addresses());
     $ipAddress = substr($ipAddressWithMask, 0, strpos($ipAddressWithMask, '/'));
     $server = ['HTTP_CF_CONNECTING_IP' => '22.33.44.55', 'REMOTE_ADDR' => $ipAddress, 'HTTP_CF_IPCOUNTRY' => 'US'];
     $cloudflareDetector = new CloudflareDetector($ipAddresses, new SuperglobalRequestAdapter($server));
     $this->assertTrue($cloudflareDetector->isCloudflareRequest());
     $this->assertEquals('22.33.44.55', $cloudflareDetector->getConnectingRequestIp());
     $this->assertEquals('US', $cloudflareDetector->getConnectingCountryCode());
 }