ip2location_ruby 8.4.0 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/ip2location_ruby.gemspec +1 -1
- data/lib/ip2location_ruby.rb +16 -14
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7f7cc867aa07b3595ae89b5f5fa55fab2b210236b106fa8ad10ccb5b9dd15b1
|
|
4
|
+
data.tar.gz: 36b720b84b89cfaad323c1d695e1b5408eca69476197cdb7911cdb614856c5e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a84781d5ab63cee79729be08a0ebdc1f3866630b8f00e4aea983e654c2cf55fd66370d8006666c76880621231fd91d9ddf3f19c2efdd0d7b7fde9428f630935
|
|
7
|
+
data.tar.gz: d6e40740c7fa84c5410239e93f54502e197a19dcc8c00b8a1d30bec76660a35bb9dfe78bced75ae7b4b3c15e29ad9f7e339a1b817e4b28cc4aff99caaf58f624
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
8.
|
|
1
|
+
8.5.0
|
data/ip2location_ruby.gemspec
CHANGED
data/lib/ip2location_ruby.rb
CHANGED
|
@@ -13,7 +13,7 @@ require 'ip2location_ruby/ip2location_record'
|
|
|
13
13
|
class Ip2location
|
|
14
14
|
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
|
|
15
15
|
|
|
16
|
-
VERSION = '8.
|
|
16
|
+
VERSION = '8.5.0'
|
|
17
17
|
FIELD_NOT_SUPPORTED = 'NOT SUPPORTED'
|
|
18
18
|
INVALID_IP_ADDRESS = 'INVALID IP ADDRESS'
|
|
19
19
|
INVALID_BIN_DATABASE = 'Incorrect IP2Location BIN file format. Please make sure that you are using the latest IP2Location BIN file.'
|
|
@@ -88,7 +88,7 @@ class Ip2location
|
|
|
88
88
|
if ip_version == 6 && self.ipv6databasecount == 0
|
|
89
89
|
return IPV6_ADDRESS_IN_IPV4_BIN
|
|
90
90
|
end
|
|
91
|
-
col_length = columns * 4
|
|
91
|
+
col_length = self.columns * 4
|
|
92
92
|
if ipv4indexbaseaddr > 0 || ipv6indexbaseaddr > 0
|
|
93
93
|
indexpos = 0
|
|
94
94
|
case ip_version
|
|
@@ -107,8 +107,7 @@ class Ip2location
|
|
|
107
107
|
ipnum = realipno - 1
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
|
-
low =
|
|
111
|
-
high = read32(indexpos + 4)
|
|
110
|
+
low, high = read32x2(indexpos)
|
|
112
111
|
return self.record = bsearch(low, high, ipnum, self.base_addr, col_length)
|
|
113
112
|
else
|
|
114
113
|
return self.record = bsearch(0, self.count, ipnum, self.base_addr, col_length)
|
|
@@ -618,7 +617,7 @@ class Ip2location
|
|
|
618
617
|
mid = (low + high) >> 1
|
|
619
618
|
ip_from, ip_to = get_from_to(mid, base_addr, col_length)
|
|
620
619
|
if ipnum >= ip_from && ipnum < ip_to
|
|
621
|
-
from_base = (
|
|
620
|
+
from_base = (base_addr + mid * (col_length + (self.v4 ? 0 : 12)))
|
|
622
621
|
file.seek(from_base)
|
|
623
622
|
if v4
|
|
624
623
|
return self.record_class4.read(file)
|
|
@@ -636,11 +635,12 @@ class Ip2location
|
|
|
636
635
|
end
|
|
637
636
|
|
|
638
637
|
def get_from_to(mid, base_addr, col_length)
|
|
639
|
-
from_base = (
|
|
638
|
+
from_base = (base_addr + mid * (col_length + (v4 ? 0 : 12)))
|
|
639
|
+
data_length = col_length + (v4 ? 4 : (12 + 16))
|
|
640
640
|
file.seek(from_base)
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
ip_to = v4 ?
|
|
641
|
+
data_read = file.read(data_length)
|
|
642
|
+
ip_from = v4 ? data_read[0..3].unpack('V').first : readipv6(data_read[0..15].unpack('V*'))
|
|
643
|
+
ip_to = v4 ? data_read[(data_length - 4)..(data_length - 1)].unpack('V').first : readipv6(data_read[(data_length - 16)..(data_length - 1)].unpack('V*'))
|
|
644
644
|
[ip_from, ip_to]
|
|
645
645
|
end
|
|
646
646
|
|
|
@@ -676,17 +676,19 @@ class Ip2location
|
|
|
676
676
|
[ipv, ipnum]
|
|
677
677
|
end
|
|
678
678
|
|
|
679
|
-
def
|
|
679
|
+
def read32x2(indexp)
|
|
680
680
|
file.seek(indexp - 1)
|
|
681
|
-
|
|
681
|
+
data_read = file.read(8)
|
|
682
|
+
data1 = data_read[0..3].unpack('V').first
|
|
683
|
+
data2 = data_read[4..7].unpack('V').first
|
|
684
|
+
return [data1, data2]
|
|
682
685
|
end
|
|
683
686
|
|
|
684
|
-
def readipv6(
|
|
685
|
-
parts = filer.read(16).unpack('V*')
|
|
687
|
+
def readipv6(parts)
|
|
686
688
|
return parts[0] + parts[1] * 4294967296 + parts[2] * 4294967296**2 + parts[3] * 4294967296**3
|
|
687
689
|
end
|
|
688
690
|
|
|
689
|
-
private :get_record, :bsearch, :get_from_to, :
|
|
691
|
+
private :get_record, :bsearch, :get_from_to, :read32x2, :readipv6
|
|
690
692
|
end
|
|
691
693
|
|
|
692
694
|
class Ip2locationWebService
|
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.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ip2location
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-06-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bindata
|