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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd1e0bbbfed7c2c8810a7673dedb3b2217e9b15f2ee66db8996b0193c1f29954
4
- data.tar.gz: 268884174492ad2fb1e359f499fb4f783f2ff0bcd07a075fb772d5dbbc80be45
3
+ metadata.gz: 30a6be5f8b9be3046d9450d970a996f61f07d49c35dc8ad44036f534457e8cb1
4
+ data.tar.gz: 7b2babc2892f5f6c29d5038ab86d23da675e7cd0acadac7bf035e2ab2f2fff39
5
5
  SHA512:
6
- metadata.gz: ee2149410b6e181dc04055c245b35a43e26f32fa67443a35d88415e04389d0fca830b0aefdc33973ae9538aa5744dcb050a6d79916d8d9e0833ae581412b63d0
7
- data.tar.gz: 9f6762d6926650eb3ef9b5b5dcb9ff1e36f342bb1f965612324a0c1a6c82f40890158d760d5d681c58ac8c76a98a6a6787fd98f432486b35bf6466d6f31a1f73
6
+ metadata.gz: 0304a809be3a8fc3e87265b2c93811a91aa6595d1ce535132db963d114a6ec4b9e2102dc2418f99d3812ada25cc18fff631065387e9b1aff3dad777ac1c598c8
7
+ data.tar.gz: 6faecc7b8ca06d0b0221fa926d587d45bd9e447f881f1b0e7a84e3873adb6a7af831ba9d37fe5105f6f7e46e82113e89f968735c30d401a67dafa6fcc4c85889
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2021 IP2Location ( support@ip2location.com )
1
+ Copyright (c) 2022 IP2Location ( support@ip2location.com )
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "ip2proxy_ruby"
5
- s.version = "3.2.1"
5
+ s.version = "3.3.0"
6
6
  s.authors = ["ip2location"]
7
7
  s.email = ["support@ip2location.com"]
8
8
 
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.2.1'
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 = read32(indexpos)
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 = ( base_addr + mid * (col_length + (v4 ? 0 : 12)))
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
- ip_from = v4 ? file.read(4).unpack('V').first : readipv6(file)
425
- file.seek(from_base + col_length + (v4 ? 0 : 12))
426
- ip_to = v4 ? file.read(4).unpack('V').first : readipv6(file)
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 read32(indexp)
462
+ def read32x2(indexp)
463
463
  file.seek(indexp - 1)
464
- return file.read(4).unpack('V').first
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(filer)
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, :read32, :readipv6
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.2.1'
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.2.1
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: 2021-12-07 00:00:00.000000000 Z
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
- rubyforge_project:
123
- rubygems_version: 2.7.6.2
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: []