diff --git a/LICENSE.TXT b/LICENSE.TXT index 0bdc490..965a08b 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2016 - 2024 IP2Location.com +Copyright (c) 2016 - 2025 IP2Location.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index ee586d7..c7e9a96 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ To learn more about installation, usage, and code examples, please visit the dev | PUB | Public Proxies. These are services which make connection requests on a user's behalf. Proxy server software can be configured by the administrator to listen on some specified port. These differ from VPNs in that the proxies usually have limited functions compare to VPNs. | High | | WEB | Web Proxies. These are web services which make web requests on a user's behalf. These differ from VPNs or Public Proxies in that they are simple web-based proxies rather than operating at the IP address and other ports level. | High | | SES | Search Engine Robots. These are services which perform crawling or scraping to a website, such as, the search engine spider or bots engine. | Low | -| RES | Residential proxies. These services offer users proxy connections through residential ISP with or without consents of peers to share their idle resources. Only available with PX10 & PX11 | Medium | -| CPN | Consumer Privacy Network: These services ensure encrypted traffic from the user's browser by routing internet requests through relays, concealing the IP address, location, and browsing activity. Only available with PX11 | Low | -| EPN | Enterprise Private Network: Services like SASE or SD-WAN combine network security functions with wide-area networking (WAN) capabilities to meet the secure remote access needs of organizations. Only available with PX11 | Low | +| RES | Residential proxies. These services offer users proxy connections through residential ISP with or without consents of peers to share their idle resources. Only available with PX10 - PX12 | Medium | +| CPN | Consumer Privacy Network: These services ensure encrypted traffic from the user's browser by routing internet requests through relays, concealing the IP address, location, and browsing activity. Only available with PX11 & PX12 | Low | +| EPN | Enterprise Private Network: Services like SASE or SD-WAN combine network security functions with wide-area networking (WAN) capabilities to meet the secure remote access needs of organizations. Only available with PX11 & PX12 | Low | diff --git a/data/PX11.SAMPLE.BIN b/data/PX11.SAMPLE.BIN deleted file mode 100644 index dca12a8..0000000 Binary files a/data/PX11.SAMPLE.BIN and /dev/null differ diff --git a/data/PX12.SAMPLE.BIN b/data/PX12.SAMPLE.BIN new file mode 100644 index 0000000..249abe9 Binary files /dev/null and b/data/PX12.SAMPLE.BIN differ diff --git a/docs/source/code.md b/docs/source/code.md index 58fe104..0f5d160 100644 --- a/docs/source/code.md +++ b/docs/source/code.md @@ -9,7 +9,7 @@ Load the IP2Location BIN database. ``` ```{py:function} getPackageVersion() -Return the database's type, 1 to 10 respectively for PX1 to PX11. Please visit https://www.ip2location.com/databases/ip2proxy for details. +Return the database's type, 1 to 10 respectively for PX1 to PX12. Please visit https://www.ip2location.com/databases/ip2proxy for details. :return: Returns the package version. :rtype: string @@ -53,4 +53,5 @@ Retrieve geolocation information for an IP address. | threat | Security threat reported. | | proxyType | Type of proxy. | | provider | Name of VPN provider if available. | +| fraudScore | Potential risk score (0 - 99) associated with IP address. | ``` \ No newline at end of file diff --git a/docs/source/quickstart.md b/docs/source/quickstart.md index f6b6197..167f72a 100644 --- a/docs/source/quickstart.md +++ b/docs/source/quickstart.md @@ -29,7 +29,7 @@ You can query the geolocation information from the IP2Proxy BIN database as belo ```php require 'vendor/autoload.php'; -$db = new \IP2Proxy\Database('vendor/ip2location/ip2proxy-php/data/PX11.SAMPLE.BIN', \IP2PROXY\Database::FILE_IO); +$db = new \IP2Proxy\Database('vendor/ip2location/ip2proxy-php/data/PX12.SAMPLE.BIN', \IP2PROXY\Database::FILE_IO); $records = $db->lookup('1.0.0.8', \IP2PROXY\Database::ALL); @@ -42,7 +42,7 @@ echo '
State: ' . $records['regionName'] . '
'; echo 'City: ' . $records['cityName'] . '
'; /* - Type of proxy: VPN, TOR, DCH, PUB, WEB, RES (RES available in PX11 only) + Type of proxy: VPN, TOR, DCH, PUB, WEB, RES (RES available in PX11 & PX12 only) */ echo 'Proxy Type: ' . $records['proxyType'] . '
'; @@ -61,4 +61,5 @@ echo 'AS: ' . $records['as'] . '
'; echo 'Last Seen: ' . $records['lastSeen'] . '
'; echo 'Threat: ' . $records['threat'] . '
'; echo 'Provider: ' . $records['provider'] . '
'; +echo 'Fraud Score: ' . $records['fraudScore'] . '
'; ``` \ No newline at end of file diff --git a/examples/example.php b/examples/example.php index bf53a10..fa539b4 100644 --- a/examples/example.php +++ b/examples/example.php @@ -6,13 +6,13 @@ require 'vendor/autoload.php'; // Lookup by local BIN database -$db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2PROXY\Database::FILE_IO); +$db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2PROXY\Database::FILE_IO); echo 'Module Version: ' . $db->getModuleVersion() . \PHP_EOL . \PHP_EOL; echo 'Package: PX' . $db->getPackageVersion() . \PHP_EOL; echo 'Database Date: ' . $db->getDatabaseVersion() . \PHP_EOL; -echo '$records = $db->lookup(\'1.0.0.8\', \IP2PROXY\Database::ALL);' . \PHP_EOL; -$records = $db->lookup('1.0.0.8', \IP2PROXY\Database::ALL); +echo '$records = $db->lookup(\'23.90.12.224\', \IP2PROXY\Database::ALL);' . \PHP_EOL; +$records = $db->lookup('23.83.130.186', \IP2PROXY\Database::ALL); print_r($records); echo \PHP_EOL . \PHP_EOL; diff --git a/src/Database.php b/src/Database.php index 5dd5e6f..81fe26b 100644 --- a/src/Database.php +++ b/src/Database.php @@ -148,6 +148,13 @@ class Database */ public const PROVIDER = 14; + /** + * Fraud score. + * + * @var int + */ + public const FRAUD_SCORE = 15; + /** * Country name and code. * @@ -198,7 +205,7 @@ class Database * * @var string */ - private const VERSION = '4.1.1'; + private const VERSION = '4.2.0'; /** * Include the IP address of the looked up IP address. @@ -333,20 +340,21 @@ class Database * @var array */ private $columns = [ - self::COUNTRY_CODE => [8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], - self::COUNTRY_NAME => [8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], - self::REGION_NAME => [0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16], - self::CITY_NAME => [0, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20], - self::ISP => [0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24], - self::PROXY_TYPE => [0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8], - self::DOMAIN => [0, 0, 0, 0, 28, 28, 28, 28, 28, 28, 28], - self::USAGE_TYPE => [0, 0, 0, 0, 0, 32, 32, 32, 32, 32, 32], - self::ASN => [0, 0, 0, 0, 0, 0, 36, 36, 36, 36, 36], - self::_AS => [0, 0, 0, 0, 0, 0, 40, 40, 40, 40, 40], - self::LAST_SEEN => [0, 0, 0, 0, 0, 0, 0, 44, 44, 44, 44], - self::THREAT => [0, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48], - self::PROVIDER => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52], - ]; + self::COUNTRY_CODE => [8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], + self::COUNTRY_NAME => [8, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12], + self::REGION_NAME => [0, 0, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16], + self::CITY_NAME => [0, 0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20], + self::ISP => [0, 0, 0, 24, 24, 24, 24, 24, 24, 24, 24, 24], + self::PROXY_TYPE => [0, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8], + self::DOMAIN => [0, 0, 0, 0, 28, 28, 28, 28, 28, 28, 28, 28], + self::USAGE_TYPE => [0, 0, 0, 0, 0, 32, 32, 32, 32, 32, 32, 32], + self::ASN => [0, 0, 0, 0, 0, 0, 36, 36, 36, 36, 36, 36], + self::_AS => [0, 0, 0, 0, 0, 0, 40, 40, 40, 40, 40, 40], + self::LAST_SEEN => [0, 0, 0, 0, 0, 0, 0, 44, 44, 44, 44, 44], + self::THREAT => [0, 0, 0, 0, 0, 0, 0, 0, 48, 48, 48, 48], + self::PROVIDER => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 52, 52], + self::FRAUD_SCORE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 56], + ]; /** * Column name mapping. @@ -368,6 +376,7 @@ class Database self::LAST_SEEN => 'lastSeen', self::THREAT => 'threat', self::PROVIDER => 'provider', + self::FRAUD_SCORE => 'fraudScore', self::IP_ADDRESS => 'ipAddress', self::IP_VERSION => 'ipVersion', self::IP_NUMBER => 'ipNumber', @@ -380,6 +389,7 @@ class Database */ private $databases = [ // IPv4 databases + 'IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER-FRAUDSCORE', 'IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER', 'IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL', 'IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT', @@ -393,6 +403,7 @@ class Database 'IP2PROXY-IP-COUNTRY', // IPv6 databases + 'IPV6-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER-FRAUDSCORE', 'IPV6-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER', 'IPV6-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL', 'IPV6-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT', @@ -670,19 +681,19 @@ public function close() { switch ($this->mode) { case self::FILE_IO: - // free the file pointer - if ($this->resource !== false) { - fclose($this->resource); - $this->resource = false; - } - break; + // free the file pointer + if ($this->resource !== false) { + fclose($this->resource); + $this->resource = false; + } + break; case self::SHARED_MEMORY: - // detach from the memory segment - if ($this->resource !== false) { - shmop_close($this->resource); - $this->resource = false; - } - break; + // detach from the memory segment + if ($this->resource !== false) { + shmop_close($this->resource); + $this->resource = false; + } + break; } } @@ -766,6 +777,7 @@ public function lookup($ip, $fields = null, $asNamed = true) $ifields[] = self::LAST_SEEN; $ifields[] = self::THREAT; $ifields[] = self::PROVIDER; + $ifields[] = self::FRAUD_SCORE; $ifields[] = self::COUNTRY; $ifields[] = self::IP_ADDRESS; $ifields[] = self::IP_VERSION; @@ -790,6 +802,7 @@ public function lookup($ip, $fields = null, $asNamed = true) self::LAST_SEEN => false, self::THREAT => false, self::PROVIDER => false, + self::FRAUD_SCORE => false, self::COUNTRY => false, self::IP_ADDRESS => false, self::IP_VERSION => false, @@ -928,6 +941,13 @@ public function lookup($ip, $fields = null, $asNamed = true) } break; + case self::FRAUD_SCORE: + if (!$done[self::FRAUD_SCORE]) { + $results[self::FRAUD_SCORE] = $this->readFraudScore($pointer); + $done[self::FRAUD_SCORE] = true; + } + break; + case self::IP_ADDRESS: if (!$done[self::IP_ADDRESS]) { $results[self::IP_ADDRESS] = $ip; @@ -1063,12 +1083,12 @@ private function getMemoryLimit() } else { // Deal with shorthand bytes switch (strtoupper(substr($limit, -1))) { - case 'G': $value *= 1024; - // no break - case 'M': $value *= 1024; - // no break - case 'K': $value *= 1024; - } + case 'G': $value *= 1024; + // no break + case 'M': $value *= 1024; + // no break + case 'K': $value *= 1024; + } } $this->memoryLimit = $value; } @@ -1264,7 +1284,7 @@ private function bcBin2Dec($data) unpack('V', substr($data, 8, 4)), unpack('V', substr($data, 4, 4)), unpack('V', substr($data, 0, 4)), - ]; + ]; foreach ($parts as &$part) { if ($part[1] < 0) { @@ -1308,17 +1328,17 @@ private function expand($ipv6) private function read($pos, $len) { switch ($this->mode) { - case self::SHARED_MEMORY: - return shmop_read($this->resource, $pos, $len); + case self::SHARED_MEMORY: + return shmop_read($this->resource, $pos, $len); - case self::MEMORY_CACHE: - return $data = substr($this->buffer[$this->resource], $pos, $len); + case self::MEMORY_CACHE: + return $data = substr($this->buffer[$this->resource], $pos, $len); - default: - fseek($this->resource, $pos, \SEEK_SET); + default: + fseek($this->resource, $pos, \SEEK_SET); - return fread($this->resource, $len); - } + return fread($this->resource, $len); + } } // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1679,6 +1699,29 @@ private function readProvider($pointer) return $provider; } + /** + * High level function to fetch the Fraud score. + * + * @param int $pointer Position to read from, if false, return self::INVALID_IP_ADDRESS + * + * @return string + */ + private function readFraudScore($pointer) + { + if ($pointer === false) { + // Deal with invalid IPs + $fraudScore = self::INVALID_IP_ADDRESS; + } elseif ($this->columns[self::FRAUD_SCORE][$this->type] === 0) { + // If the field is not supported, return accordingly + $fraudScore = self::FIELD_NOT_SUPPORTED; + } else { + // Read the domain + $fraudScore = $this->readString($this->columns[self::FRAUD_SCORE][$this->type]); + } + + return $fraudScore; + } + // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Binary search and support functions ///////////////////////////////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1769,7 +1812,7 @@ private function binSearch($version, $ipNumber) case 1: $low = $mid + 1; break; - } + } } return false; diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php index 0a9ed72..64e1862 100644 --- a/tests/DatabaseTest.php +++ b/tests/DatabaseTest.php @@ -19,7 +19,7 @@ public function testInvalidDatabase() public function testInvalidIp() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); $records = $db->lookup('1.0.0.x', \IP2Proxy\Database::ALL); @@ -28,151 +28,144 @@ public function testInvalidIp() public function testIpv4CountryCode() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $records = $db->lookup('1.0.0.8', \IP2Proxy\Database::ALL); + $records = $db->lookup('23.83.130.186', \IP2Proxy\Database::ALL); $this->assertEquals('US', $records['countryCode']); } public function testIpv4CountryName() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $records = $db->lookup('1.0.0.8', \IP2Proxy\Database::ALL); + $records = $db->lookup('23.83.130.186', \IP2Proxy\Database::ALL); - $this->assertEquals( - 'United States of America', - $records['countryName'], - ); + $this->assertEquals('United States of America', $records['countryName']); } public function testLookupCountryCode() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('US', $db->lookup('1.0.0.8', \IP2Proxy\Database::COUNTRY_CODE)); + $this->assertEquals('US', $db->lookup('23.83.130.186', \IP2Proxy\Database::COUNTRY_CODE)); } public function testLookupCountryName() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('United States of America', $db->lookup('1.0.0.8', \IP2Proxy\Database::COUNTRY_NAME)); + $this->assertEquals('United States of America', $db->lookup('23.83.130.186', \IP2Proxy\Database::COUNTRY_NAME)); } public function testLookupRegionName() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('California', $db->lookup('1.0.0.8', \IP2Proxy\Database::REGION_NAME)); + $this->assertEquals('Arizona', $db->lookup('23.83.130.186', \IP2Proxy\Database::REGION_NAME)); } public function testLookupCityName() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('Los Angeles', $db->lookup('1.0.0.8', \IP2Proxy\Database::CITY_NAME)); + $this->assertEquals('Phoenix', $db->lookup('23.83.130.186', \IP2Proxy\Database::CITY_NAME)); } public function testLookupIsp() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('APNIC and CloudFlare DNS Resolver Project', $db->lookup('1.0.0.8', \IP2Proxy\Database::ISP)); + $this->assertEquals('Leaseweb USA Inc.', $db->lookup('23.83.130.186', \IP2Proxy\Database::ISP)); } public function testLookupIsProxy() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals(2, (string) $db->lookup('1.0.0.8', \IP2Proxy\Database::IS_PROXY)); + $this->assertEquals(1, (string) $db->lookup('23.83.130.186', \IP2Proxy\Database::IS_PROXY)); } public function testLookupProxyType() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('DCH', $db->lookup('1.0.0.8', \IP2Proxy\Database::PROXY_TYPE)); + $this->assertEquals('VPN', $db->lookup('23.83.130.186', \IP2Proxy\Database::PROXY_TYPE)); } public function testLookupDomain() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('cloudflare.com', $db->lookup('1.0.0.8', \IP2Proxy\Database::DOMAIN)); + $this->assertEquals('leaseweb.com', $db->lookup('23.83.130.186', \IP2Proxy\Database::DOMAIN)); } public function testLookupUsageType() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('CDN', $db->lookup('1.0.0.8', \IP2Proxy\Database::USAGE_TYPE)); + $this->assertEquals('DCH', $db->lookup('23.83.130.186', \IP2Proxy\Database::USAGE_TYPE)); } public function testLookupAsn() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('13335', $db->lookup('1.0.0.8', \IP2Proxy\Database::ASN)); + $this->assertEquals('19148', $db->lookup('23.83.130.186', \IP2Proxy\Database::ASN)); } public function testLookupAs() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('CLOUDFLARENET', $db->lookup('1.0.0.8', \IP2Proxy\Database::_AS)); + $this->assertEquals('Leaseweb USA Inc.', $db->lookup('23.83.130.186', \IP2Proxy\Database::_AS)); } public function testLookupLastSeen() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('22', $db->lookup('1.0.0.8', \IP2Proxy\Database::LAST_SEEN)); + $this->assertEquals('1', $db->lookup('23.83.130.186', \IP2Proxy\Database::LAST_SEEN)); } public function testLookupThreat() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('-', $db->lookup('1.0.0.8', \IP2Proxy\Database::THREAT)); + $this->assertEquals('SPAM', $db->lookup('23.83.130.186', \IP2Proxy\Database::THREAT)); } - public function testIpv6CountryCode() + public function testLookupProvider() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $records = $db->lookup('2c0f:ffa0::4', \IP2Proxy\Database::ALL); - - $this->assertEquals('UG', $records['countryCode']); + $this->assertEquals('HideMyAss', $db->lookup('23.83.130.186', \IP2Proxy\Database::PROVIDER)); } - public function testIpv6CountryName() + public function testLookupFraudScore() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - - $records = $db->lookup('2c0f:ffa0::4', \IP2Proxy\Database::ALL); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); - $this->assertEquals('Uganda', $records['countryName']); + $this->assertEquals('99', $db->lookup('23.83.130.186', \IP2Proxy\Database::FRAUD_SCORE)); } public function testPackageVersion() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); $this->assertMatchesRegularExpression('/^[0-9]+$/', (string) $db->getPackageVersion()); } public function testModuleVersion() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); $this->assertMatchesRegularExpression('/^[0-9]+\.[0-9]+\.[0-9]+$/', (string) $db->getModuleVersion()); } public function testDatabaseVersion() { - $db = new \IP2Proxy\Database('./data/PX11.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); + $db = new \IP2Proxy\Database('./data/PX12.SAMPLE.BIN', \IP2Proxy\Database::FILE_IO); $this->assertMatchesRegularExpression('/^[0-9]+\.[0-9]+\.[0-9]+$/', (string) $db->getDatabaseVersion()); } diff --git a/tests/WebServiceTest.php b/tests/WebServiceTest.php index bd0d98e..07195dc 100644 --- a/tests/WebServiceTest.php +++ b/tests/WebServiceTest.php @@ -30,7 +30,7 @@ public function testCountryCodeIpv4() $records = $ws->lookup('1.0.0.8'); $this->assertEquals( - 'US', + 'AU', $records['countryCode'], ); }