ip2proxy_ruby 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +1 -1
- data/ip2proxy_ruby.gemspec +1 -1
- data/lib/ip2proxy_ruby.rb +14 -12
- data/spec/ip2proxy_ruby_database_spec.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30a6be5f8b9be3046d9450d970a996f61f07d49c35dc8ad44036f534457e8cb1
|
4
|
+
data.tar.gz: 7b2babc2892f5f6c29d5038ab86d23da675e7cd0acadac7bf035e2ab2f2fff39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0304a809be3a8fc3e87265b2c93811a91aa6595d1ce535132db963d114a6ec4b9e2102dc2418f99d3812ada25cc18fff631065387e9b1aff3dad777ac1c598c8
|
7
|
+
data.tar.gz: 6faecc7b8ca06d0b0221fa926d587d45bd9e447f881f1b0e7a84e3873adb6a7af831ba9d37fe5105f6f7e46e82113e89f968735c30d401a67dafa6fcc4c85889
|
data/LICENSE.txt
CHANGED
data/ip2proxy_ruby.gemspec
CHANGED
data/lib/ip2proxy_ruby.rb
CHANGED
@@ -11,7 +11,7 @@ require_relative 'ip2proxy_ruby/ip2proxy_record'
|
|
11
11
|
class Ip2proxy
|
12
12
|
attr_accessor :record_class4, :record_class6, :v4, :file, :db_index, :count, :base_addr, :ipno, :record, :database, :columns, :ip_version, :ipv4databasecount, :ipv4databaseaddr, :ipv4indexbaseaddr, :ipv6databasecount, :ipv6databaseaddr, :ipv6indexbaseaddr, :databaseyear, :databasemonth, :databaseday, :last_err_msg
|
13
13
|
|
14
|
-
VERSION = '3.
|
14
|
+
VERSION = '3.3.0'
|
15
15
|
FIELD_NOT_SUPPORTED = 'NOT SUPPORTED'
|
16
16
|
INVALID_IP_ADDRESS = 'INVALID IP ADDRESS'
|
17
17
|
INVALID_BIN_DATABASE = 'Incorrect IP2Proxy BIN file format. Please make sure that you are using the latest IP2Proxy BIN file.'
|
@@ -101,8 +101,7 @@ class Ip2proxy
|
|
101
101
|
ipnum = realipno - 1
|
102
102
|
end
|
103
103
|
end
|
104
|
-
low =
|
105
|
-
high = read32(indexpos + 4)
|
104
|
+
low, high = read32x2(indexpos)
|
106
105
|
return self.record = bsearch(low, high, ipnum, self.base_addr, col_length)
|
107
106
|
else
|
108
107
|
return self.record = bsearch(0, self.count, ipnum, self.base_addr, col_length)
|
@@ -419,11 +418,12 @@ class Ip2proxy
|
|
419
418
|
end
|
420
419
|
|
421
420
|
def get_from_to(mid, base_addr, col_length)
|
422
|
-
from_base = (
|
421
|
+
from_base = (base_addr + mid * (col_length + (v4 ? 0 : 12)))
|
422
|
+
data_length = col_length + (v4 ? 4 : (12 + 16))
|
423
423
|
file.seek(from_base)
|
424
|
-
|
425
|
-
|
426
|
-
ip_to = v4 ?
|
424
|
+
data_read = file.read(data_length)
|
425
|
+
ip_from = v4 ? data_read[0..3].unpack('V').first : readipv6(data_read[0..15].unpack('V*'))
|
426
|
+
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*'))
|
427
427
|
[ip_from, ip_to]
|
428
428
|
end
|
429
429
|
|
@@ -459,17 +459,19 @@ class Ip2proxy
|
|
459
459
|
[ipv, ipnum]
|
460
460
|
end
|
461
461
|
|
462
|
-
def
|
462
|
+
def read32x2(indexp)
|
463
463
|
file.seek(indexp - 1)
|
464
|
-
|
464
|
+
data_read = file.read(8)
|
465
|
+
data1 = data_read[0..3].unpack('V').first
|
466
|
+
data2 = data_read[4..7].unpack('V').first
|
467
|
+
return [data1, data2]
|
465
468
|
end
|
466
469
|
|
467
|
-
def readipv6(
|
468
|
-
parts = filer.read(16).unpack('V*')
|
470
|
+
def readipv6(parts)
|
469
471
|
return parts[0] + parts[1] * 4294967296 + parts[2] * 4294967296**2 + parts[3] * 4294967296**3
|
470
472
|
end
|
471
473
|
|
472
|
-
private :get_record, :bsearch, :get_from_to, :
|
474
|
+
private :get_record, :bsearch, :get_from_to, :read32x2, :readipv6
|
473
475
|
|
474
476
|
end
|
475
477
|
|
@@ -106,7 +106,7 @@ describe "Ip2proxy" do
|
|
106
106
|
it "work correctly with get_module_version" do
|
107
107
|
i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
|
108
108
|
record = i2p.get_module_version()
|
109
|
-
expect(record).to eq '3.
|
109
|
+
expect(record).to eq '3.3.0'
|
110
110
|
end
|
111
111
|
|
112
112
|
it "work correctly with get_package_version" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ip2proxy_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ip2location
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -104,7 +104,7 @@ metadata:
|
|
104
104
|
bug_tracker_uri: https://github.com/ip2location/ip2proxy-ruby/issues
|
105
105
|
homepage_uri: https://www.ip2location.com
|
106
106
|
source_code_uri: https://github.com/ip2location/ip2proxy-ruby
|
107
|
-
post_install_message:
|
107
|
+
post_install_message:
|
108
108
|
rdoc_options: []
|
109
109
|
require_paths:
|
110
110
|
- lib
|
@@ -119,9 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
119
|
- !ruby/object:Gem::Version
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
|
-
|
123
|
-
|
124
|
-
signing_key:
|
122
|
+
rubygems_version: 3.2.33
|
123
|
+
signing_key:
|
125
124
|
specification_version: 4
|
126
125
|
summary: IP2Proxy Ruby library
|
127
126
|
test_files: []
|