ip2location_ruby 8.6.0 → 8.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +24 -24
- data/LICENSE.txt +1 -1
- data/README.md +3 -90
- data/VERSION +1 -1
- data/example.rb +4 -1
- data/ip2location_ruby.gemspec +2 -2
- data/lib/ip2location_ruby/database_config.rb +26 -23
- data/lib/ip2location_ruby/i2l_float_data.rb +2 -2
- data/lib/ip2location_ruby/i2l_ip_data.rb +3 -3
- data/lib/ip2location_ruby.rb +92 -26
- data/rb/data/IP2LOCATION-LITE-DB1.IPV6.BIN +0 -0
- data/spec/ip2location_ruby_database_spec.rb +18 -0
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b86068ea70a1da30468fab1bbd5407f81cd48c9438ce187358c86612794c027d
|
4
|
+
data.tar.gz: 29d1d716f253f9c2ff4a64701733cc2a7c64ea8a8b18492e6c172ae74be53d1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a68a0213618700b4c52af2c1a406b3ada8650de49f519f17152dacc8dc537ef46105cd5f6029f76e1920873579a9b0828f4a8d5932d758566051f7c5d8e8b843
|
7
|
+
data.tar.gz: 77ffe92c332344206f1d62dffeeb6898eb9bf90277a9aa161c95987128fe85c531a84fd5c7b32cb933d8d6da4a20187c4c0a4902dfbfeeeace401f875ca54f7e
|
data/Gemfile.lock
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
bindata (2.4.10)
|
5
|
-
diff-lcs (1.1.3)
|
6
|
-
json (>= 2.3.0)
|
7
|
-
rdoc (>= 6.3.1)
|
8
|
-
json (~> 1.4)
|
9
|
-
rspec (2.8.0)
|
10
|
-
rspec-core (~> 2.8.0)
|
11
|
-
rspec-expectations (~> 2.8.0)
|
12
|
-
rspec-mocks (~> 2.8.0)
|
13
|
-
rspec-core (2.8.0)
|
14
|
-
rspec-expectations (2.8.0)
|
15
|
-
diff-lcs (~> 1.1.2)
|
16
|
-
rspec-mocks (2.8.0)
|
17
|
-
|
18
|
-
PLATFORMS
|
19
|
-
ruby
|
20
|
-
|
21
|
-
DEPENDENCIES
|
22
|
-
bindata
|
23
|
-
bundler (>= 1.2.0)
|
24
|
-
rdoc (>= 6.3.1)
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
bindata (2.4.10)
|
5
|
+
diff-lcs (1.1.3)
|
6
|
+
json (>= 2.3.0)
|
7
|
+
rdoc (>= 6.3.1)
|
8
|
+
json (~> 1.4)
|
9
|
+
rspec (2.8.0)
|
10
|
+
rspec-core (~> 2.8.0)
|
11
|
+
rspec-expectations (~> 2.8.0)
|
12
|
+
rspec-mocks (~> 2.8.0)
|
13
|
+
rspec-core (2.8.0)
|
14
|
+
rspec-expectations (2.8.0)
|
15
|
+
diff-lcs (~> 1.1.2)
|
16
|
+
rspec-mocks (2.8.0)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
|
21
|
+
DEPENDENCIES
|
22
|
+
bindata
|
23
|
+
bundler (>= 1.2.0)
|
24
|
+
rdoc (>= 6.3.1)
|
25
25
|
rspec (~> 2.8.0)
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -2,102 +2,15 @@
|
|
2
2
|
[![Total Downloads](https://img.shields.io/gem/dt/ip2location_ruby.svg)](https://rubygems.org/gems/ip2location_ruby)
|
3
3
|
|
4
4
|
# IP2Location Ruby Library
|
5
|
-
This is IP2Location Ruby library that enables the user to find the country, region or state, city, latitude and longitude,
|
5
|
+
This is IP2Location Ruby library that enables the user to find the country, region or state, district, city, latitude and longitude, ZIP/Postal code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type, IAB category and ASN from IP address using IP2Location database. The library reads the geo location information from **IP2Location BIN data** file or web service.
|
6
6
|
|
7
7
|
Supported IPv4 and IPv6 address.
|
8
8
|
|
9
9
|
For more details, please visit:
|
10
10
|
[https://www.ip2location.com/developers/ruby](https://www.ip2location.com/developers/ruby)
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
```
|
16
|
-
gem install ip2location_ruby
|
17
|
-
```
|
18
|
-
|
19
|
-
# Usage
|
20
|
-
You can check the **example.rb** file to learn more about usage.
|
21
|
-
|
22
|
-
## BIN Database
|
23
|
-
An outdated BIN database was provided in the library for your testing. You are recommended to visit the [links](#dependencies) to download the latest BIN database and save it in the ```rb``` folder.
|
24
|
-
|
25
|
-
Below is the description of the functions available in the **BIN Database** lookup.
|
26
|
-
|
27
|
-
| Function Name | Description |
|
28
|
-
|---|---|
|
29
|
-
| open | Open the IP2Location BIN data for lookup. |
|
30
|
-
| close | Close and clean up the file pointer. |
|
31
|
-
| get_package_version | Get the package version (1 to 25 for DB1 to DB25 respectively). |
|
32
|
-
| get_module_version | Get the module version. |
|
33
|
-
| get_database_version | Get the database version. |
|
34
|
-
| get_last_error_message | Return the last error message. |
|
35
|
-
| get_all | Return the geolocation information in array. |
|
36
|
-
| get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. |
|
37
|
-
| get_country_long | Return the ISO3166-1 country name of the IP address. |
|
38
|
-
| get_region | Return the ISO3166-2 region name of the IP address. Please visit [ISO3166-2 Subdivision Code](https://www.ip2location.com/free/iso3166-2) for the information of ISO3166-2 supported |
|
39
|
-
| get_city | Return the city name of the IP address. |
|
40
|
-
| get_latitude | Return the city latitude of the IP address. |
|
41
|
-
| get_longitude | Return the city longtitude of the IP address. |
|
42
|
-
| get_isp | Return the ISP name of the IP address. |
|
43
|
-
| get_domain | Return the domain name of IP address. |
|
44
|
-
| get_zipcode | Return the zipcode of the city. |
|
45
|
-
| get_timezone | Return the UTC time zone (with DST supported). |
|
46
|
-
| get_netspeed | Return the Internet connection type. |
|
47
|
-
| get_iddcode | Return the IDD prefix to call the city from another country. |
|
48
|
-
| get_areacode | Return the area code of the city. |
|
49
|
-
| get_weathercode | Return the nearest weather observation station code. |
|
50
|
-
| get_weathername | Return the nearest weather observation station name. |
|
51
|
-
| get_mcc | Return the Mobile Country Codes (MCC). |
|
52
|
-
| get_mnc | Return the Mobile Network Code (MNC). |
|
53
|
-
| get_mobilebrand | Commercial brand associated with the mobile carrier. |
|
54
|
-
| get_elevation | Return average height of city above sea level in meters (m). |
|
55
|
-
| get_usagetype | Return the ISP's usage type of IP address. |
|
56
|
-
| get_addresstype | Returns the IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name. |
|
57
|
-
| get_category | Returns the IAB content taxonomy category of IP address or domain name. |
|
58
|
-
|
59
|
-
## Web Service
|
60
|
-
Below is the description of the functions available in the **Web Service** lookup.
|
61
|
-
|
62
|
-
| Function Name | Description |
|
63
|
-
|---|---|
|
64
|
-
| Constructor | Expect 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS25)</li></li><li>Use HTTPS or HTTP</li></ol> |
|
65
|
-
| lookup | Return the IP information in array.<ul><li>country_code</li><li>country_name</li><li>region_name</li><li>city_name</li><li>latitude</li><li>longitude</li><li>zip_code</li><li>time_zone</li><li>isp</li><li>domain</li><li>net_speed</li><li>idd_code</li><li>area_code</li><li>weather_station_code</li><li>weather_station_name</li><li>mcc</li><li>mnc</li><li>mobile_brand</li><li>elevation</li><li>usage_type</li><li>address_type</li><li>category</li><li>continent<ul><li>name</li><li>code</li><li>hemisphere</li><li>translations</li></ul></li><li>country<ul><li>name</li><li>alpha3_code</li><li>numeric_code</li><li>demonym</li><li>flag</li><li>capital</li><li>total_area</li><li>population</li><li>currency<ul><li>code</li><li>name</li><li>symbol</li></ul></li><li>language<ul><li>code</li><li>name</li></ul></li><li>idd_code</li><li>tld</li><li>translations</li></ul></li><li>region<ul><li>name</li><li>code</li><li>translations</li></ul></li><li>city<ul><li>name</li><li>translations</li></ul></li><li>geotargeting<ul><li>metro</li></ul></li><li>country_groupings</li><li>time_zone_info<ul><li>olson</li><li>current_time</li><li>gmt_offset</li><li>is_dst</li><li>sunrise</li><li>sunset</li></ul></li><ul> |
|
66
|
-
| get_credit | Return remaining credit of the web service account. |
|
67
|
-
|
68
|
-
## IpTools
|
69
|
-
Below is the description of the functions available in the **IpTools** class.
|
70
|
-
|
71
|
-
| Function Name | Description |
|
72
|
-
|---|---|
|
73
|
-
| is_ipv4 | Return either true or false. Verify if a string is a valid IPv4 address. |
|
74
|
-
| is_ipv6 | Return either true or false. Verify if a string is a valid IPv6 address. |
|
75
|
-
| ipv4_to_decimal | Translate IPv4 address from dotted-decimal address to decimal format. Return null on error. |
|
76
|
-
| decimal_to_ipv4 | Translate IPv4 address from decimal number to dotted-decimal address. Return null on error. |
|
77
|
-
| ipv6_to_decimal | Translate IPv6 address from hexadecimal address to decimal format. Return null on error. |
|
78
|
-
| decimal_to_ipv6 | Translate IPv6 address from decimal number into hexadecimal address. Return null on error. |
|
79
|
-
| ipv4_to_cidr | Convert IPv4 range into a list of IPv4 CIDR notation. |
|
80
|
-
| cidr_to_ipv4 | Convert IPv4 CIDR notation into a list of IPv4 addresses. |
|
81
|
-
| ipv6_to_cidr | Convert IPv6 range into a list of IPv6 CIDR notation. |
|
82
|
-
| cidr_to_ipv6 | Convert IPv6 CIDR notation into a list of IPv6 addresses. |
|
83
|
-
| compress_ipv6 | Compress a IPv6 to shorten the length. |
|
84
|
-
| expand_ipv6 | Expand a shorten IPv6 to full length. |
|
85
|
-
|
86
|
-
## Country
|
87
|
-
Below is the description of the functions available in the **Country** class.
|
88
|
-
|
89
|
-
| Function Name | Description |
|
90
|
-
|---|---|
|
91
|
-
| Constructor | Expect a IP2Location Country Information CSV file. This database is free for download at https://www.ip2location.com/free/country-information |
|
92
|
-
| get_country_info | Provide a ISO 3166 country code to get the country information in array. Will return a full list of countries information if country code not provided. Below is the information returned: <ul><li>country_code</li><li>country_alpha3_code</li><li>country_numeric_code</li><li>capital</li><li>country_demonym</li><li>total_area</li><li>population</li><li>idd_code</li><li>currency_code</li><li>currency_name</li><li>currency_symbol</li><li>lang_code</li><li>lang_name</li><li>cctld</li></ul> |
|
93
|
-
|
94
|
-
## Region
|
95
|
-
Below is the description of the functions available in the **Region** class.
|
96
|
-
|
97
|
-
| Function Name | Description |
|
98
|
-
|---|---|
|
99
|
-
| Constructor | Expect a IP2Location ISO 3166-2 Subdivision Code CSV file. This database is free for download at https://www.ip2location.com/free/iso3166-2 |
|
100
|
-
| get_region_code | Provide a ISO 3166 country code and the region name to get ISO 3166-2 subdivision code for the region. |
|
12
|
+
## Developer Documentation
|
13
|
+
To learn more about installation, usage, and code examples, please visit the developer documentation at [https://ip2location-ruby.readthedocs.io/en/latest/index.html.](https://ip2location-ruby.readthedocs.io/en/latest/index.html)
|
101
14
|
|
102
15
|
# Dependencies
|
103
16
|
This library requires IP2Location BIN data file to function. You may download the BIN data file at
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
8.
|
1
|
+
8.7.1
|
data/example.rb
CHANGED
@@ -29,6 +29,9 @@ puts record['elevation']
|
|
29
29
|
puts 'Usage Type: ' + record['usagetype']
|
30
30
|
puts 'Address Type: ' + record['addresstype']
|
31
31
|
puts 'Category: ' + record['category']
|
32
|
+
puts 'District: ' + record['district']
|
33
|
+
puts 'ASN: ' + record['asn']
|
34
|
+
puts 'AS: ' + record['as']
|
32
35
|
i2l.close()
|
33
36
|
|
34
37
|
# Web Service
|
@@ -58,4 +61,4 @@ puts country.get_country_info('US')
|
|
58
61
|
|
59
62
|
# Region Class
|
60
63
|
region = Ip2locationRegion.new('./data/IP2LOCATION-ISO3166-2.CSV')
|
61
|
-
puts region.get_region_code('US', 'California')
|
64
|
+
puts region.get_region_code('US', 'California')
|
data/ip2location_ruby.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "ip2location_ruby"
|
3
|
-
s.version = "8.
|
3
|
+
s.version = "8.7.1"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.require_paths = ["lib"]
|
7
7
|
s.authors = ["ip2location"]
|
8
8
|
s.email = ["support@ip2location.com"]
|
9
|
-
s.description = "The official IP2Location Ruby library to geolocate an IP address. You can lookup for country, region, city, latitude
|
9
|
+
s.description = "The official IP2Location Ruby library to geolocate an IP address. You can lookup for country, region, district, city, latitude and longitude, ZIP/Postal code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type, IAB category and ASN from an IP address. Supported both IPv4 and IPv6 lookup."
|
10
10
|
s.email = "support@ip2location.com"
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE.txt",
|
@@ -1,26 +1,29 @@
|
|
1
1
|
class DbConfig
|
2
2
|
COLUMNS = {
|
3
|
-
:COUNTRY => [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
4
|
-
:REGION => [0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
|
5
|
-
:CITY => [0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
6
|
-
:LATITUDE => [0, 0, 0, 0, 0, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
|
7
|
-
:LONGITUDE => [0, 0, 0, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
|
8
|
-
:ZIPCODE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, 7, 0, 7, 7],
|
9
|
-
:TIMEZONE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 7, 8, 8, 8, 7, 8, 0, 8, 8, 8, 0, 8, 8],
|
10
|
-
:ISP => [0, 0, 3, 0, 5, 0, 7, 5, 7, 0, 8, 0, 9, 0, 9, 0, 9, 0, 9, 7, 9, 0, 9, 7, 9, 9],
|
11
|
-
:DOMAIN => [0, 0, 0, 0, 0, 0, 0, 6, 8, 0, 9, 0, 10, 0, 10, 0, 10, 0, 10, 8, 10, 0, 10, 8, 10, 10],
|
12
|
-
:NETSPEED => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 11, 0, 11,8, 11, 0, 11, 0, 11, 0, 11, 11],
|
13
|
-
:IDDCODE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 12, 0, 12, 0, 12, 9, 12, 0, 12, 12],
|
14
|
-
:AREACODE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10 ,13 ,0, 13, 0, 13, 10, 13, 0, 13, 13],
|
15
|
-
:WEATHERSTATIONCODE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 14, 0, 14, 0, 14, 0, 14, 14],
|
16
|
-
:WEATHERSTATIONNAME => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 15, 0, 15, 0, 15, 0, 15, 15],
|
17
|
-
:MCC => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 16, 0, 16, 9, 16, 16],
|
18
|
-
:MNC => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,17, 0, 17, 10, 17, 17],
|
19
|
-
:MOBILEBRAND => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11,18, 0, 18, 11, 18, 18],
|
20
|
-
:ELEVATION => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 19, 0, 19, 19],
|
21
|
-
:USAGETYPE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 20, 20],
|
22
|
-
:ADDRESSTYPE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21],
|
23
|
-
:CATEGORY => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22]
|
3
|
+
:COUNTRY => [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
4
|
+
:REGION => [0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
|
5
|
+
:CITY => [0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
|
6
|
+
:LATITUDE => [0, 0, 0, 0, 0, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
|
7
|
+
:LONGITUDE => [0, 0, 0, 0, 0, 6, 6, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],
|
8
|
+
:ZIPCODE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 7, 7, 7, 0, 7, 0, 7, 7, 7, 0, 7, 7, 7],
|
9
|
+
:TIMEZONE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 8, 7, 8, 8, 8, 7, 8, 0, 8, 8, 8, 0, 8, 8, 8],
|
10
|
+
:ISP => [0, 0, 3, 0, 5, 0, 7, 5, 7, 0, 8, 0, 9, 0, 9, 0, 9, 0, 9, 7, 9, 0, 9, 7, 9, 9, 9],
|
11
|
+
:DOMAIN => [0, 0, 0, 0, 0, 0, 0, 6, 8, 0, 9, 0, 10, 0, 10, 0, 10, 0, 10, 8, 10, 0, 10, 8, 10, 10, 10],
|
12
|
+
:NETSPEED => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 11, 0, 11,8, 11, 0, 11, 0, 11, 0, 11, 11, 11],
|
13
|
+
:IDDCODE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 12, 0, 12, 0, 12, 9, 12, 0, 12, 12, 12],
|
14
|
+
:AREACODE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10 ,13 ,0, 13, 0, 13, 10, 13, 0, 13, 13, 13],
|
15
|
+
:WEATHERSTATIONCODE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 14, 0, 14, 0, 14, 0, 14, 14, 14],
|
16
|
+
:WEATHERSTATIONNAME => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 15, 0, 15, 0, 15, 0, 15, 15, 15],
|
17
|
+
:MCC => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 16, 0, 16, 9, 16, 16, 16],
|
18
|
+
:MNC => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10,17, 0, 17, 10, 17, 17, 17],
|
19
|
+
:MOBILEBRAND => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11,18, 0, 18, 11, 18, 18, 18],
|
20
|
+
:ELEVATION => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 11, 19, 0, 19, 19, 19],
|
21
|
+
:USAGETYPE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 20, 20, 20],
|
22
|
+
:ADDRESSTYPE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 21],
|
23
|
+
:CATEGORY => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 22],
|
24
|
+
:DISTRICT => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 23],
|
25
|
+
:ASN => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24],
|
26
|
+
:AS => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25]
|
24
27
|
}
|
25
28
|
|
26
29
|
def self.setup_database(db_index)
|
@@ -30,8 +33,8 @@ class DbConfig
|
|
30
33
|
memo
|
31
34
|
}
|
32
35
|
# order by value
|
33
|
-
|
36
|
+
cols.sort_by {|key,value| value}
|
34
37
|
end
|
35
38
|
|
36
39
|
end
|
37
|
-
|
40
|
+
|
@@ -2,9 +2,9 @@ class I2lIpData < BinData::BasePrimitive
|
|
2
2
|
def read_and_return_value(io)
|
3
3
|
iv = eval_parameter(:ip_version)
|
4
4
|
if iv == 4
|
5
|
-
|
5
|
+
BinData::Uint32le.read(io)
|
6
6
|
elsif iv == 6
|
7
|
-
|
7
|
+
BinData::Uint128le.read(io)
|
8
8
|
end
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
data/lib/ip2location_ruby.rb
CHANGED
@@ -14,7 +14,7 @@ require 'ip2location_ruby/ip2location_record'
|
|
14
14
|
class Ip2location
|
15
15
|
attr_accessor :record_class4, :record_class6, :v4, :file, :db_index, :count, :base_addr, :ipno, :count, :record, :database, :columns, :ip_version, :ipv4databasecount, :ipv4databaseaddr, :ipv4indexbaseaddr, :ipv6databasecount, :ipv6databaseaddr, :ipv6indexbaseaddr, :databaseyear, :databasemonth, :databaseday, :last_err_msg
|
16
16
|
|
17
|
-
VERSION = '8.
|
17
|
+
VERSION = '8.7.1'
|
18
18
|
FIELD_NOT_SUPPORTED = 'NOT SUPPORTED'
|
19
19
|
INVALID_IP_ADDRESS = 'INVALID IP ADDRESS'
|
20
20
|
INVALID_BIN_DATABASE = 'Incorrect IP2Location BIN file format. Please make sure that you are using the latest IP2Location BIN file.'
|
@@ -29,7 +29,7 @@ class Ip2location
|
|
29
29
|
begin
|
30
30
|
self.file = File.open(File.expand_path url, 'rb')
|
31
31
|
rescue
|
32
|
-
self.last_err_msg = 'Ip2location.new.open() error in opening ' + url +'.'
|
32
|
+
self.last_err_msg = 'Ip2location.new.open() error in opening ' + url + '.'
|
33
33
|
abort('Ip2location.new.open() error in opening ' + url + '. No such file in the /your_ip2location_ruby_library_path/rb/ folder.')
|
34
34
|
else
|
35
35
|
end
|
@@ -119,7 +119,7 @@ class Ip2location
|
|
119
119
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
120
120
|
if valid
|
121
121
|
rec = get_record(ip)
|
122
|
-
if
|
122
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
123
123
|
country_short = IPV6_ADDRESS_IN_IPV4_BIN
|
124
124
|
country_long = IPV6_ADDRESS_IN_IPV4_BIN
|
125
125
|
region = IPV6_ADDRESS_IN_IPV4_BIN
|
@@ -142,6 +142,9 @@ class Ip2location
|
|
142
142
|
usagetype = IPV6_ADDRESS_IN_IPV4_BIN
|
143
143
|
addresstype = IPV6_ADDRESS_IN_IPV4_BIN
|
144
144
|
category = IPV6_ADDRESS_IN_IPV4_BIN
|
145
|
+
district = IPV6_ADDRESS_IN_IPV4_BIN
|
146
|
+
asn = IPV6_ADDRESS_IN_IPV4_BIN
|
147
|
+
as = IPV6_ADDRESS_IN_IPV4_BIN
|
145
148
|
elsif !(rec.nil?)
|
146
149
|
country_short = (defined?(rec.country_short) && rec.country_short != '') ? rec.country_short : FIELD_NOT_SUPPORTED
|
147
150
|
country_long = (defined?(rec.country_long) && rec.country_long != '') ? rec.country_long : FIELD_NOT_SUPPORTED
|
@@ -165,6 +168,9 @@ class Ip2location
|
|
165
168
|
usagetype = (defined?(rec.usagetype) && rec.usagetype != '') ? rec.usagetype : FIELD_NOT_SUPPORTED
|
166
169
|
addresstype = (defined?(rec.addresstype) && rec.addresstype != '') ? rec.addresstype : FIELD_NOT_SUPPORTED
|
167
170
|
category = (defined?(rec.category) && rec.category != '') ? rec.category : FIELD_NOT_SUPPORTED
|
171
|
+
district = (defined?(rec.district) && rec.district != '') ? rec.district : FIELD_NOT_SUPPORTED
|
172
|
+
asn = (defined?(rec.asn) && rec.asn != '') ? rec.asn : FIELD_NOT_SUPPORTED
|
173
|
+
as = (defined?(rec.as) && rec.as != '') ? rec.as : FIELD_NOT_SUPPORTED
|
168
174
|
else
|
169
175
|
country_short = INVALID_IP_ADDRESS
|
170
176
|
country_long = INVALID_IP_ADDRESS
|
@@ -188,6 +194,9 @@ class Ip2location
|
|
188
194
|
usagetype = INVALID_IP_ADDRESS
|
189
195
|
addresstype = INVALID_IP_ADDRESS
|
190
196
|
category = INVALID_IP_ADDRESS
|
197
|
+
district = INVALID_IP_ADDRESS
|
198
|
+
asn = INVALID_IP_ADDRESS
|
199
|
+
as = INVALID_IP_ADDRESS
|
191
200
|
end
|
192
201
|
else
|
193
202
|
country_short = INVALID_IP_ADDRESS
|
@@ -212,6 +221,9 @@ class Ip2location
|
|
212
221
|
usagetype = INVALID_IP_ADDRESS
|
213
222
|
addresstype = INVALID_IP_ADDRESS
|
214
223
|
category = INVALID_IP_ADDRESS
|
224
|
+
district = INVALID_IP_ADDRESS
|
225
|
+
asn = INVALID_IP_ADDRESS
|
226
|
+
as = INVALID_IP_ADDRESS
|
215
227
|
end
|
216
228
|
results = {}
|
217
229
|
results['country_short'] = country_short
|
@@ -236,6 +248,9 @@ class Ip2location
|
|
236
248
|
results['usagetype'] = usagetype
|
237
249
|
results['addresstype'] = addresstype
|
238
250
|
results['category'] = category
|
251
|
+
results['district'] = district
|
252
|
+
results['asn'] = asn
|
253
|
+
results['as'] = as
|
239
254
|
return results
|
240
255
|
end
|
241
256
|
|
@@ -243,7 +258,7 @@ class Ip2location
|
|
243
258
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
244
259
|
if valid
|
245
260
|
rec = get_record(ip)
|
246
|
-
if
|
261
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
247
262
|
country_short = IPV6_ADDRESS_IN_IPV4_BIN
|
248
263
|
elsif !(rec.nil?)
|
249
264
|
country_short = (defined?(rec.country_short) && rec.country_short != '') ? rec.country_short : FIELD_NOT_SUPPORTED
|
@@ -260,7 +275,7 @@ class Ip2location
|
|
260
275
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
261
276
|
if valid
|
262
277
|
rec = get_record(ip)
|
263
|
-
if
|
278
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
264
279
|
country_long = IPV6_ADDRESS_IN_IPV4_BIN
|
265
280
|
elsif !(rec.nil?)
|
266
281
|
country_long = (defined?(rec.country_long) && rec.country_long != '') ? rec.country_long : FIELD_NOT_SUPPORTED
|
@@ -277,7 +292,7 @@ class Ip2location
|
|
277
292
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
278
293
|
if valid
|
279
294
|
rec = get_record(ip)
|
280
|
-
if
|
295
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
281
296
|
region = IPV6_ADDRESS_IN_IPV4_BIN
|
282
297
|
elsif !(rec.nil?)
|
283
298
|
region = (defined?(rec.region) && rec.region != '') ? rec.region : FIELD_NOT_SUPPORTED
|
@@ -294,7 +309,7 @@ class Ip2location
|
|
294
309
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
295
310
|
if valid
|
296
311
|
rec = get_record(ip)
|
297
|
-
if
|
312
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
298
313
|
city = IPV6_ADDRESS_IN_IPV4_BIN
|
299
314
|
elsif !(rec.nil?)
|
300
315
|
city = (defined?(rec.city) && rec.city != '') ? rec.city : FIELD_NOT_SUPPORTED
|
@@ -311,7 +326,7 @@ class Ip2location
|
|
311
326
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
312
327
|
if valid
|
313
328
|
rec = get_record(ip)
|
314
|
-
if
|
329
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
315
330
|
latitude = IPV6_ADDRESS_IN_IPV4_BIN
|
316
331
|
elsif !(rec.nil?)
|
317
332
|
latitude = (defined?(rec.latitude) && rec.latitude != '') ? rec.latitude : FIELD_NOT_SUPPORTED
|
@@ -328,7 +343,7 @@ class Ip2location
|
|
328
343
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
329
344
|
if valid
|
330
345
|
rec = get_record(ip)
|
331
|
-
if
|
346
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
332
347
|
longitude = IPV6_ADDRESS_IN_IPV4_BIN
|
333
348
|
elsif !(rec.nil?)
|
334
349
|
longitude = (defined?(rec.longitude) && rec.longitude != '') ? rec.longitude : FIELD_NOT_SUPPORTED
|
@@ -345,7 +360,7 @@ class Ip2location
|
|
345
360
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
346
361
|
if valid
|
347
362
|
rec = get_record(ip)
|
348
|
-
if
|
363
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
349
364
|
isp = IPV6_ADDRESS_IN_IPV4_BIN
|
350
365
|
elsif !(rec.nil?)
|
351
366
|
isp = (defined?(rec.isp) && rec.isp != '') ? rec.isp : FIELD_NOT_SUPPORTED
|
@@ -362,7 +377,7 @@ class Ip2location
|
|
362
377
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
363
378
|
if valid
|
364
379
|
rec = get_record(ip)
|
365
|
-
if
|
380
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
366
381
|
domain = IPV6_ADDRESS_IN_IPV4_BIN
|
367
382
|
elsif !(rec.nil?)
|
368
383
|
domain = (defined?(rec.domain) && rec.domain != '') ? rec.domain : FIELD_NOT_SUPPORTED
|
@@ -379,7 +394,7 @@ class Ip2location
|
|
379
394
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
380
395
|
if valid
|
381
396
|
rec = get_record(ip)
|
382
|
-
if
|
397
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
383
398
|
zipcode = IPV6_ADDRESS_IN_IPV4_BIN
|
384
399
|
elsif !(rec.nil?)
|
385
400
|
zipcode = (defined?(rec.zipcode) && rec.zipcode != '') ? rec.zipcode : FIELD_NOT_SUPPORTED
|
@@ -396,7 +411,7 @@ class Ip2location
|
|
396
411
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
397
412
|
if valid
|
398
413
|
rec = get_record(ip)
|
399
|
-
if
|
414
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
400
415
|
timezone = IPV6_ADDRESS_IN_IPV4_BIN
|
401
416
|
elsif !(rec.nil?)
|
402
417
|
timezone = (defined?(rec.timezone) && rec.timezone != '') ? rec.timezone : FIELD_NOT_SUPPORTED
|
@@ -413,7 +428,7 @@ class Ip2location
|
|
413
428
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
414
429
|
if valid
|
415
430
|
rec = get_record(ip)
|
416
|
-
if
|
431
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
417
432
|
netspeed = IPV6_ADDRESS_IN_IPV4_BIN
|
418
433
|
elsif !(rec.nil?)
|
419
434
|
netspeed = (defined?(rec.netspeed) && rec.netspeed != '') ? rec.netspeed : FIELD_NOT_SUPPORTED
|
@@ -430,7 +445,7 @@ class Ip2location
|
|
430
445
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
431
446
|
if valid
|
432
447
|
rec = get_record(ip)
|
433
|
-
if
|
448
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
434
449
|
iddcode = IPV6_ADDRESS_IN_IPV4_BIN
|
435
450
|
elsif !(rec.nil?)
|
436
451
|
iddcode = (defined?(rec.iddcode) && rec.iddcode != '') ? rec.iddcode : FIELD_NOT_SUPPORTED
|
@@ -447,7 +462,7 @@ class Ip2location
|
|
447
462
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
448
463
|
if valid
|
449
464
|
rec = get_record(ip)
|
450
|
-
if
|
465
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
451
466
|
areacode = IPV6_ADDRESS_IN_IPV4_BIN
|
452
467
|
elsif !(rec.nil?)
|
453
468
|
areacode = (defined?(rec.areacode) && rec.areacode != '') ? rec.areacode : FIELD_NOT_SUPPORTED
|
@@ -464,7 +479,7 @@ class Ip2location
|
|
464
479
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
465
480
|
if valid
|
466
481
|
rec = get_record(ip)
|
467
|
-
if
|
482
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
468
483
|
weatherstationcode = IPV6_ADDRESS_IN_IPV4_BIN
|
469
484
|
elsif !(rec.nil?)
|
470
485
|
weatherstationcode = (defined?(rec.weatherstationcode) && rec.weatherstationcode != '') ? rec.weatherstationcode : FIELD_NOT_SUPPORTED
|
@@ -481,7 +496,7 @@ class Ip2location
|
|
481
496
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
482
497
|
if valid
|
483
498
|
rec = get_record(ip)
|
484
|
-
if
|
499
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
485
500
|
weatherstationname = IPV6_ADDRESS_IN_IPV4_BIN
|
486
501
|
elsif !(rec.nil?)
|
487
502
|
weatherstationname = (defined?(rec.weatherstationname) && rec.weatherstationname != '') ? rec.weatherstationname : FIELD_NOT_SUPPORTED
|
@@ -498,7 +513,7 @@ class Ip2location
|
|
498
513
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
499
514
|
if valid
|
500
515
|
rec = get_record(ip)
|
501
|
-
if
|
516
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
502
517
|
mcc = IPV6_ADDRESS_IN_IPV4_BIN
|
503
518
|
elsif !(rec.nil?)
|
504
519
|
mcc = (defined?(rec.mcc) && rec.mcc != '') ? rec.mcc : FIELD_NOT_SUPPORTED
|
@@ -515,7 +530,7 @@ class Ip2location
|
|
515
530
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
516
531
|
if valid
|
517
532
|
rec = get_record(ip)
|
518
|
-
if
|
533
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
519
534
|
mnc = IPV6_ADDRESS_IN_IPV4_BIN
|
520
535
|
elsif !(rec.nil?)
|
521
536
|
mnc = (defined?(rec.mnc) && rec.mnc != '') ? rec.mnc : FIELD_NOT_SUPPORTED
|
@@ -532,7 +547,7 @@ class Ip2location
|
|
532
547
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
533
548
|
if valid
|
534
549
|
rec = get_record(ip)
|
535
|
-
if
|
550
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
536
551
|
mobilebrand = IPV6_ADDRESS_IN_IPV4_BIN
|
537
552
|
elsif !(rec.nil?)
|
538
553
|
mobilebrand = (defined?(rec.mobilebrand) && rec.mobilebrand != '') ? rec.mobilebrand : FIELD_NOT_SUPPORTED
|
@@ -549,7 +564,7 @@ class Ip2location
|
|
549
564
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
550
565
|
if valid
|
551
566
|
rec = get_record(ip)
|
552
|
-
if
|
567
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
553
568
|
elevation = IPV6_ADDRESS_IN_IPV4_BIN
|
554
569
|
elsif !(rec.nil?)
|
555
570
|
elevation = (defined?(rec.elevation) && rec.elevation != '') ? rec.elevation : FIELD_NOT_SUPPORTED
|
@@ -566,7 +581,7 @@ class Ip2location
|
|
566
581
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
567
582
|
if valid
|
568
583
|
rec = get_record(ip)
|
569
|
-
if
|
584
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
570
585
|
usagetype = IPV6_ADDRESS_IN_IPV4_BIN
|
571
586
|
elsif !(rec.nil?)
|
572
587
|
usagetype = (defined?(rec.usagetype) && rec.usagetype != '') ? rec.usagetype : FIELD_NOT_SUPPORTED
|
@@ -583,7 +598,7 @@ class Ip2location
|
|
583
598
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
584
599
|
if valid
|
585
600
|
rec = get_record(ip)
|
586
|
-
if
|
601
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
587
602
|
addresstype = IPV6_ADDRESS_IN_IPV4_BIN
|
588
603
|
elsif !(rec.nil?)
|
589
604
|
addresstype = (defined?(rec.addresstype) && rec.addresstype != '') ? rec.addresstype : FIELD_NOT_SUPPORTED
|
@@ -600,7 +615,7 @@ class Ip2location
|
|
600
615
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
601
616
|
if valid
|
602
617
|
rec = get_record(ip)
|
603
|
-
if
|
618
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
604
619
|
category = IPV6_ADDRESS_IN_IPV4_BIN
|
605
620
|
elsif !(rec.nil?)
|
606
621
|
category = (defined?(rec.category) && rec.category != '') ? rec.category : FIELD_NOT_SUPPORTED
|
@@ -613,6 +628,57 @@ class Ip2location
|
|
613
628
|
return category
|
614
629
|
end
|
615
630
|
|
631
|
+
def get_district(ip)
|
632
|
+
valid = !(IPAddr.new(ip) rescue nil).nil?
|
633
|
+
if valid
|
634
|
+
rec = get_record(ip)
|
635
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
636
|
+
district = IPV6_ADDRESS_IN_IPV4_BIN
|
637
|
+
elsif !(rec.nil?)
|
638
|
+
district = (defined?(rec.district) && rec.district != '') ? rec.district : FIELD_NOT_SUPPORTED
|
639
|
+
else
|
640
|
+
district = INVALID_IP_ADDRESS
|
641
|
+
end
|
642
|
+
else
|
643
|
+
district = INVALID_IP_ADDRESS
|
644
|
+
end
|
645
|
+
return district
|
646
|
+
end
|
647
|
+
|
648
|
+
def get_asn(ip)
|
649
|
+
valid = !(IPAddr.new(ip) rescue nil).nil?
|
650
|
+
if valid
|
651
|
+
rec = get_record(ip)
|
652
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
653
|
+
asn = IPV6_ADDRESS_IN_IPV4_BIN
|
654
|
+
elsif !(rec.nil?)
|
655
|
+
asn = (defined?(rec.asn) && rec.asn != '') ? rec.asn : FIELD_NOT_SUPPORTED
|
656
|
+
else
|
657
|
+
asn = INVALID_IP_ADDRESS
|
658
|
+
end
|
659
|
+
else
|
660
|
+
asn = INVALID_IP_ADDRESS
|
661
|
+
end
|
662
|
+
return asn
|
663
|
+
end
|
664
|
+
|
665
|
+
def get_as(ip)
|
666
|
+
valid = !(IPAddr.new(ip) rescue nil).nil?
|
667
|
+
if valid
|
668
|
+
rec = get_record(ip)
|
669
|
+
if rec == IPV6_ADDRESS_IN_IPV4_BIN
|
670
|
+
as = IPV6_ADDRESS_IN_IPV4_BIN
|
671
|
+
elsif !(rec.nil?)
|
672
|
+
as = (defined?(rec.as) && rec.as != '') ? rec.as : FIELD_NOT_SUPPORTED
|
673
|
+
else
|
674
|
+
as = INVALID_IP_ADDRESS
|
675
|
+
end
|
676
|
+
else
|
677
|
+
as = INVALID_IP_ADDRESS
|
678
|
+
end
|
679
|
+
return as
|
680
|
+
end
|
681
|
+
|
616
682
|
def bsearch(low, high, ipnum, base_addr, col_length)
|
617
683
|
while low <= high do
|
618
684
|
mid = (low + high) >> 1
|
@@ -1088,4 +1154,4 @@ class Ip2locationRegion
|
|
1088
1154
|
end
|
1089
1155
|
end
|
1090
1156
|
end
|
1091
|
-
end
|
1157
|
+
end
|
Binary file
|
@@ -139,6 +139,24 @@ describe "Ip2location" do
|
|
139
139
|
expect(record).to eq 'NOT SUPPORTED'
|
140
140
|
end
|
141
141
|
|
142
|
+
it "work correctly with get_district" do
|
143
|
+
i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP2LOCATION-LITE-DB1.IPV6.BIN")
|
144
|
+
record = i2l.get_district('8.8.8.8')
|
145
|
+
expect(record).to eq 'NOT SUPPORTED'
|
146
|
+
end
|
147
|
+
|
148
|
+
it "work correctly with get_asn" do
|
149
|
+
i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP2LOCATION-LITE-DB1.IPV6.BIN")
|
150
|
+
record = i2l.get_asn('8.8.8.8')
|
151
|
+
expect(record).to eq 'NOT SUPPORTED'
|
152
|
+
end
|
153
|
+
|
154
|
+
it "work correctly with get_as" do
|
155
|
+
i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP2LOCATION-LITE-DB1.IPV6.BIN")
|
156
|
+
record = i2l.get_as('8.8.8.8')
|
157
|
+
expect(record).to eq 'NOT SUPPORTED'
|
158
|
+
end
|
159
|
+
|
142
160
|
it "work correctly with ipv6" do
|
143
161
|
i2l = Ip2location.new.open(File.dirname(__FILE__) + "/assets/IP2LOCATION-LITE-DB1.IPV6.BIN")
|
144
162
|
record = i2l.get_all('2001:4860:4860::8888')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ip2location_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.
|
4
|
+
version: 8.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ip2location
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -67,9 +67,11 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.2.0
|
69
69
|
description: The official IP2Location Ruby library to geolocate an IP address. You
|
70
|
-
can lookup for country, region, city, latitude
|
71
|
-
|
72
|
-
|
70
|
+
can lookup for country, region, district, city, latitude and longitude, ZIP/Postal
|
71
|
+
code, time zone, Internet Service Provider (ISP) or company name, domain name, net
|
72
|
+
speed, area code, weather station code, weather station name, mobile country code
|
73
|
+
(MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address
|
74
|
+
type, IAB category and ASN from an IP address. Supported both IPv4 and IPv6 lookup.
|
73
75
|
email: support@ip2location.com
|
74
76
|
executables: []
|
75
77
|
extensions: []
|