ip2proxy_ruby 3.2.1 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/LICENSE.txt +20 -20
- data/README.md +64 -98
- data/example.rb +1 -8
- data/ip2proxy_ruby.gemspec +4 -4
- data/lib/ip2proxy_ruby.rb +14 -12
- data/spec/ip2proxy_ruby_database_spec.rb +1 -1
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7574dfbc7f1fd1a881fe0e05f0d041a7272fb121e9be4c307aa41c0710e92a49
|
4
|
+
data.tar.gz: 5f0cdbe708bd355ed1910e8914e150b539109a49a1ee4dd2b25d556cd6d9bd69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 050c2a2e9c42bb4b601dd8e31bc8119781d3709dbddef7e1d63ab2c3b07f4ee53bdf4a8f11dd461bec0b7f4382d5f0dbd58ac378216b4c0bdcc332a5ad096c91
|
7
|
+
data.tar.gz: d8310cc6b583300425e6ef7e89a599858a07d13166ab9783873f42bbe2fe45fc62841fa828c6a19ef8956213043f76dc6c6c51f85ace8f02ff7568067364c738
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c)
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2016 - 2024 IP2Location ( support@ip2location.com )
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,98 +1,64 @@
|
|
1
|
-
[![Latest Stable Version](https://img.shields.io/gem/v/ip2proxy_ruby.svg)](https://rubygems.org/gems/ip2proxy_ruby)
|
2
|
-
[![Total Downloads](https://img.shields.io/gem/dt/ip2proxy_ruby.svg)](https://rubygems.org/gems/ip2proxy_ruby)
|
3
|
-
|
4
|
-
# IP2Proxy Ruby Library
|
5
|
-
This module allows user to reverse search of IP address to detect VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots, data center ranges
|
6
|
-
|
7
|
-
For more details, please visit:
|
8
|
-
[https://www.ip2location.com/ip2proxy/developers/ruby](https://www.ip2location.com/ip2proxy/developers/ruby)
|
9
|
-
|
10
|
-
#
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
|
19
|
-
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
|
31
|
-
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|---|---|
|
66
|
-
|COM|Commercial|
|
67
|
-
|ORG|Organization|
|
68
|
-
|GOV|Government|
|
69
|
-
|MIL|Military|
|
70
|
-
|EDU|University/College/School|
|
71
|
-
|LIB|Library|
|
72
|
-
|CDN|Content Delivery Network|
|
73
|
-
|ISP|Fixed Line ISP|
|
74
|
-
|MOB|Mobile ISP|
|
75
|
-
|DCH|Data Center/Web Hosting/Transit|
|
76
|
-
|SES|Search Engine Spider|
|
77
|
-
|RSV|Reserved|
|
78
|
-
|
79
|
-
### Threat Type
|
80
|
-
|
81
|
-
|Threat Type|Description|
|
82
|
-
|---|---|
|
83
|
-
|SPAM|Spammer|
|
84
|
-
|SCANNER|Security Scanner or Attack|
|
85
|
-
|BOTNET|Spyware or Malware|
|
86
|
-
|
87
|
-
# Dependencies
|
88
|
-
|
89
|
-
This library requires IP2Proxy BIN data file to function. You may download the BIN data file at
|
90
|
-
* IP2Proxy LITE BIN Data (Free): https://lite.ip2location.com
|
91
|
-
* IP2Proxy Commercial BIN Data (Comprehensive): https://www.ip2location.com/proxy-database
|
92
|
-
|
93
|
-
You can also sign up for [IP2Proxy Web Service](https://www.ip2location.com/web-service/ip2proxy) to lookup by IP2Proxy API.
|
94
|
-
|
95
|
-
# Support
|
96
|
-
|
97
|
-
Email: support@ip2location.com
|
98
|
-
URL: [https://www.ip2location.com](https://www.ip2location.com)
|
1
|
+
[![Latest Stable Version](https://img.shields.io/gem/v/ip2proxy_ruby.svg)](https://rubygems.org/gems/ip2proxy_ruby)
|
2
|
+
[![Total Downloads](https://img.shields.io/gem/dt/ip2proxy_ruby.svg)](https://rubygems.org/gems/ip2proxy_ruby)
|
3
|
+
|
4
|
+
# IP2Proxy Ruby Library
|
5
|
+
This module allows user to reverse search of IP address to detect VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots, data center ranges, residential proxies, consumer privacy networks, and enterprise private networks using IP2Proxy BIN database. Other information available includes proxy type, country, state, city, ISP, domain name, usage type, AS number, AS name, threats, last seen date and provider names. It lookup the proxy IP address from **IP2Proxy BIN Data** file or web service.
|
6
|
+
|
7
|
+
For more details, please visit:
|
8
|
+
[https://www.ip2location.com/ip2proxy/developers/ruby](https://www.ip2location.com/ip2proxy/developers/ruby)
|
9
|
+
|
10
|
+
# Developer Documentation
|
11
|
+
To learn more about installation, usage, and code examples, please visit the developer documentation at [https://ip2proxy-ruby.readthedocs.io/en/latest/index.html.](https://ip2proxy-ruby.readthedocs.io/en/latest/index.html)
|
12
|
+
|
13
|
+
|
14
|
+
### Proxy Type
|
15
|
+
|
16
|
+
|Proxy Type|Description|
|
17
|
+
|---|---|
|
18
|
+
|VPN|Anonymizing VPN services|
|
19
|
+
|TOR|Tor Exit Nodes|
|
20
|
+
|PUB|Public Proxies|
|
21
|
+
|WEB|Web Proxies|
|
22
|
+
|DCH|Hosting Providers/Data Center|
|
23
|
+
|SES|Search Engine Robots|
|
24
|
+
|RES|Residential Proxies [PX10+]|
|
25
|
+
|CPN|Consumer Privacy Networks. [PX11+]|
|
26
|
+
|EPN|Enterprise Private Networks. [PX11+]|
|
27
|
+
|
28
|
+
### Usage Type
|
29
|
+
|
30
|
+
|Usage Type|Description|
|
31
|
+
|---|---|
|
32
|
+
|COM|Commercial|
|
33
|
+
|ORG|Organization|
|
34
|
+
|GOV|Government|
|
35
|
+
|MIL|Military|
|
36
|
+
|EDU|University/College/School|
|
37
|
+
|LIB|Library|
|
38
|
+
|CDN|Content Delivery Network|
|
39
|
+
|ISP|Fixed Line ISP|
|
40
|
+
|MOB|Mobile ISP|
|
41
|
+
|DCH|Data Center/Web Hosting/Transit|
|
42
|
+
|SES|Search Engine Spider|
|
43
|
+
|RSV|Reserved|
|
44
|
+
|
45
|
+
### Threat Type
|
46
|
+
|
47
|
+
|Threat Type|Description|
|
48
|
+
|---|---|
|
49
|
+
|SPAM|Spammer|
|
50
|
+
|SCANNER|Security Scanner or Attack|
|
51
|
+
|BOTNET|Spyware or Malware|
|
52
|
+
|
53
|
+
# Dependencies
|
54
|
+
|
55
|
+
This library requires IP2Proxy BIN data file to function. You may download the BIN data file at
|
56
|
+
* IP2Proxy LITE BIN Data (Free): https://lite.ip2location.com
|
57
|
+
* IP2Proxy Commercial BIN Data (Comprehensive): https://www.ip2location.com/proxy-database
|
58
|
+
|
59
|
+
You can also sign up for [IP2Proxy Web Service](https://www.ip2location.com/web-service/ip2proxy) to lookup by IP2Proxy API.
|
60
|
+
|
61
|
+
# Support
|
62
|
+
|
63
|
+
Email: support@ip2location.com
|
64
|
+
URL: [https://www.ip2location.com](https://www.ip2location.com)
|
data/example.rb
CHANGED
@@ -42,11 +42,4 @@ print 'Threat: ' + record['threat'] + "\n"
|
|
42
42
|
print 'Provider: ' + record['provider'] + "\n"
|
43
43
|
|
44
44
|
# close IP2Proxy BIN database
|
45
|
-
i2p.close()
|
46
|
-
|
47
|
-
# Web Service
|
48
|
-
ws = Ip2proxyWebService.new('demo', 'PX11', true)
|
49
|
-
record = ws.lookup('1.2.3.4')
|
50
|
-
print record
|
51
|
-
print "\n"
|
52
|
-
print ws.get_credit()
|
45
|
+
i2p.close()
|
data/ip2proxy_ruby.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "ip2proxy_ruby"
|
5
|
-
s.version = "3.
|
5
|
+
s.version = "3.3.1"
|
6
6
|
s.authors = ["ip2location"]
|
7
7
|
s.email = ["support@ip2location.com"]
|
8
8
|
|
@@ -49,18 +49,18 @@ Gem::Specification.new do |s|
|
|
49
49
|
s.specification_version = 4
|
50
50
|
|
51
51
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
-
s.add_runtime_dependency(%q<bindata>, ["
|
52
|
+
s.add_runtime_dependency(%q<bindata>, ["~> 2.4.15"])
|
53
53
|
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
54
54
|
s.add_development_dependency(%q<rdoc>, [">= 6.3.1"])
|
55
55
|
s.add_development_dependency(%q<bundler>, [">= 1.2.0"])
|
56
56
|
else
|
57
|
-
s.add_dependency(%q<bindata>, ["
|
57
|
+
s.add_dependency(%q<bindata>, ["~> 2.4.15"])
|
58
58
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
59
59
|
s.add_dependency(%q<rdoc>, [">= 6.3.1"])
|
60
60
|
s.add_dependency(%q<bundler>, [">= 1.2.0"])
|
61
61
|
end
|
62
62
|
else
|
63
|
-
s.add_dependency(%q<bindata>, ["
|
63
|
+
s.add_dependency(%q<bindata>, ["~> 2.4.15"])
|
64
64
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
65
65
|
s.add_dependency(%q<rdoc>, [">= 6.3.1"])
|
66
66
|
s.add_dependency(%q<bundler>, [">= 1.2.0"])
|
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.1'
|
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.1'
|
110
110
|
end
|
111
111
|
|
112
112
|
it "work correctly with get_package_version" do
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
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.1
|
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: 2024-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.4.15
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.4.15
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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.5.6
|
123
|
+
signing_key:
|
125
124
|
specification_version: 4
|
126
125
|
summary: IP2Proxy Ruby library
|
127
126
|
test_files: []
|