ip2proxy_ruby 1.0.2 → 3.0.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.
@@ -1,21 +1,27 @@
1
- class I2pDbConfig
2
- COLUMNS = {
3
- :COUNTRY => [0, 2, 3, 3, 3],
4
- :REGION => [0, 0, 0, 4, 4],
5
- :CITY => [0, 0, 0, 5, 5],
6
- :ISP => [0, 0, 0, 0, 6],
7
- :PROXYTYPE => [0, 0, 2, 2, 2]
8
- }
9
-
10
- def self.setup_database(db_index)
11
- # strip all 0 value & downcase keys
12
- cols = COLUMNS.inject({}) {|memo, (key, value)|
13
- (memo[key.to_s.downcase.to_sym] = value[db_index] if value[db_index] > 0)
14
- memo
15
- }
16
- # order by value
17
- col_array = cols.sort_by {|key,value| value}
18
- end
19
-
20
- end
1
+ class I2pDbConfig
2
+ COLUMNS = {
3
+ :COUNTRY => [0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
4
+ :REGION => [0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4],
5
+ :CITY => [0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5],
6
+ :ISP => [0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6],
7
+ :PROXYTYPE => [0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2],
8
+ :DOMAIN => [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7],
9
+ :USAGETYPE => [0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8],
10
+ :ASN => [0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9],
11
+ :AS => [0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10],
12
+ :LASTSEEN => [0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11],
13
+ :THREAT => [0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12]
14
+ }
15
+
16
+ def self.setup_database(db_index)
17
+ # strip all 0 value & downcase keys
18
+ cols = COLUMNS.inject({}) {|memo, (key, value)|
19
+ (memo[key.to_s.downcase.to_sym] = value[db_index] if value[db_index] > 0)
20
+ memo
21
+ }
22
+ # order by value
23
+ col_array = cols.sort_by {|key,value| value}
24
+ end
25
+
26
+ end
21
27
 
@@ -1,10 +1,10 @@
1
- class I2pIpData < BinData::BasePrimitive
2
- def read_and_return_value(io)
3
- iv = eval_parameter(:ip_version)
4
- if iv == 4
5
- addr = BinData::Uint32le.read(io)
6
- elsif iv == 6
7
- addr = BinData::Uint128le.read(io)
8
- end
9
- end
1
+ class I2pIpData < BinData::BasePrimitive
2
+ def read_and_return_value(io)
3
+ iv = eval_parameter(:ip_version)
4
+ if iv == 4
5
+ addr = BinData::Uint32le.read(io)
6
+ elsif iv == 6
7
+ addr = BinData::Uint128le.read(io)
8
+ end
9
+ end
10
10
  end
@@ -1,16 +1,16 @@
1
- class I2pStringData < BinData::BasePrimitive
2
-
3
- def read_and_return_value(io)
4
- country_long = eval_parameter(:country_long)
5
- io.seekbytes(-4) if country_long
6
- file = io.instance_variable_get('@raw_io')
7
- addr = BinData::Uint32le.read(io)
8
- old_offset = file.tell
9
- country_long ? file.seek(addr + 3) : file.seek(addr)
10
- length = BinData::Uint8.read(file)
11
- res = BinData::String.new(:length => length).read(file)
12
- file.seek(old_offset)
13
- res
14
- end
15
-
1
+ class I2pStringData < BinData::BasePrimitive
2
+
3
+ def read_and_return_value(io)
4
+ country_long = eval_parameter(:country_long)
5
+ io.seekbytes(-4) if country_long
6
+ file = io.instance_variable_get('@raw_io')
7
+ addr = BinData::Uint32le.read(io)
8
+ old_offset = file.tell
9
+ country_long ? file.seek(addr + 3) : file.seek(addr)
10
+ length = BinData::Uint8.read(file)
11
+ res = BinData::String.new(:length => length).read(file)
12
+ file.seek(old_offset)
13
+ res
14
+ end
15
+
16
16
  end
@@ -1,17 +1,17 @@
1
- class Ip2proxyConfig < BinData::Record
2
- endian :little
3
- uint8 :databasetype
4
- uint8 :databasecolumn
5
- uint8 :databaseyear
6
- uint8 :databasemonth
7
- uint8 :databaseday
8
- # uint32 :databasecount
9
- # uint32 :databaseaddr
10
- # uint32 :ipversion
11
- uint32 :ipv4databasecount
12
- uint32 :ipv4databaseaddr
13
- uint32 :ipv6databasecount
14
- uint32 :ipv6databaseaddr
15
- uint32 :ipv4indexbaseaddr
16
- uint32 :ipv6indexbaseaddr
1
+ class Ip2proxyConfig < BinData::Record
2
+ endian :little
3
+ uint8 :databasetype
4
+ uint8 :databasecolumn
5
+ uint8 :databaseyear
6
+ uint8 :databasemonth
7
+ uint8 :databaseday
8
+ # uint32 :databasecount
9
+ # uint32 :databaseaddr
10
+ # uint32 :ipversion
11
+ uint32 :ipv4databasecount
12
+ uint32 :ipv4databaseaddr
13
+ uint32 :ipv6databasecount
14
+ uint32 :ipv6databaseaddr
15
+ uint32 :ipv4indexbaseaddr
16
+ uint32 :ipv6indexbaseaddr
17
17
  end
@@ -1,20 +1,20 @@
1
- class Ip2ProxyRecord
2
- def self.init(database, ip_version)
3
- cls = Class.new(BinData::Record)
4
- cls.class_eval {
5
- endian :little
6
- i2p_ip_data :ip_from, :ip_version => ip_version
7
- database.each do |col|
8
- if col.first == :country
9
- i2p_string_data :country_short
10
- i2p_string_data :country_long, :country_long => true
11
- else
12
- i2p_string_data col.first
13
- end
14
- end
15
-
16
- i2p_ip_data :ip_to, :ip_version => ip_version
17
- }
18
- cls
19
- end
1
+ class Ip2ProxyRecord
2
+ def self.init(database, ip_version)
3
+ cls = Class.new(BinData::Record)
4
+ cls.class_eval {
5
+ endian :little
6
+ i2p_ip_data :ip_from, :ip_version => ip_version
7
+ database.each do |col|
8
+ if col.first == :country
9
+ i2p_string_data :country_short
10
+ i2p_string_data :country_long, :country_long => true
11
+ else
12
+ i2p_string_data col.first
13
+ end
14
+ end
15
+
16
+ i2p_ip_data :ip_to, :ip_version => ip_version
17
+ }
18
+ cls
19
+ end
20
20
  end
@@ -1,20 +1,20 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Ip2proxy" do
4
- it "work correctly with ipv4" do
5
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
6
- record = i2p.getAll('1.0.241.135')
7
- record.should_not be_nil
8
- record['is_proxy'].should == 1
9
- i2p.close()
10
- end
11
-
12
- it "work correctly with ipv6" do
13
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
14
- record = i2p.getAll('2001::')
15
- record.should_not be_nil
16
- record['is_proxy'].should == 0
17
- i2p.close()
18
- end
19
-
20
- end
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Ip2proxy" do
4
+ it "work correctly with ipv4" do
5
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
6
+ record = i2p.get_all('1.0.241.135')
7
+ record.should_not be_nil
8
+ record['is_proxy'].should == 1
9
+ i2p.close()
10
+ end
11
+
12
+ it "work correctly with ipv6" do
13
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
14
+ record = i2p.get_all('2001::')
15
+ record.should_not be_nil
16
+ record['is_proxy'].should == 0
17
+ i2p.close()
18
+ end
19
+
20
+ end
@@ -1,13 +1,13 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'ip2proxy_ruby'
5
-
6
- # Requires supporting files with custom matchers and macros, etc,
7
- # in ./support/ and its subdirectories.
8
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
-
10
- RSpec.configure do |config|
11
-
12
- end
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'ip2proxy_ruby'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
13
13
  require 'awesome_print'
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: 1.0.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ip2location
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-10 00:00:00.000000000 Z
11
+ date: 2020-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -94,7 +94,11 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Ruby library for IP2Proxy
97
+ description: The official IP2Proxy Ruby library to detect VPN servers, open proxies,
98
+ web proxies, Tor exit nodes, search engine robots, data center ranges and residential
99
+ proxies using IP2Proxy BIN database. Other information available includes proxy
100
+ type, country, state, city, ISP, domain name, usage type, AS number, AS name, threats
101
+ and last seen date.
98
102
  email:
99
103
  - support@ip2location.com
100
104
  executables: []
@@ -106,7 +110,6 @@ files:
106
110
  - ".document"
107
111
  - ".gitignore"
108
112
  - Gemfile
109
- - Gemfile.lock
110
113
  - LICENSE.txt
111
114
  - README.md
112
115
  - Rakefile
@@ -118,14 +121,17 @@ files:
118
121
  - lib/ip2proxy_ruby/i2p_string_data.rb
119
122
  - lib/ip2proxy_ruby/ip2proxy_config.rb
120
123
  - lib/ip2proxy_ruby/ip2proxy_record.rb
121
- - rb/data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN
124
+ - rb/data/IP2PROXY-LITE-PX1.BIN
122
125
  - spec/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN
123
126
  - spec/ip2proxy_ruby_spec.rb
124
127
  - spec/spec_helper.rb
125
128
  homepage: https://github.com/ip2location/ip2proxy-ruby
126
129
  licenses:
127
130
  - MIT
128
- metadata: {}
131
+ metadata:
132
+ bug_tracker_uri: https://github.com/ip2location/ip2proxy-ruby/issues
133
+ homepage_uri: https://www.ip2location.com
134
+ source_code_uri: https://github.com/ip2location/ip2proxy-ruby
129
135
  post_install_message:
130
136
  rdoc_options: []
131
137
  require_paths:
@@ -142,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
148
  version: '0'
143
149
  requirements: []
144
150
  rubyforge_project:
145
- rubygems_version: 2.6.8
151
+ rubygems_version: 2.7.6.2
146
152
  signing_key:
147
153
  specification_version: 4
148
154
  summary: IP2Proxy Ruby library