ip2proxy_ruby 2.1.0 → 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.
- checksums.yaml +4 -4
- data/README.md +22 -10
- data/example.rb +2 -0
- data/ip2proxy_ruby.gemspec +2 -2
- data/lib/ip2proxy_ruby.rb +20 -1
- data/lib/ip2proxy_ruby/i2p_database_config.rb +11 -10
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a0f076da57bce1ce3df8766d07dde4855d90601d5e184b5bb1c15a099e8342f
|
4
|
+
data.tar.gz: 8c9ae8dcf68cf2d9447397299572bc82317bebca1d15bbd85124250306c664bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f546e8cc2e57db0130b996cc0b8d436b8897ea33a6c92f2346617d66475de8b89d651dbd472457ca691c8c71b6787e9138452c8dc07852ca3a0461f711c4774
|
7
|
+
data.tar.gz: 904aa801ab54f8b9c00ca38121ab3011e78fea24273d902ae2f6a57fb3b8e7f8a37858697ff75b94c9ed0efb06c50013f337082d942f01b13f0a5d92513e9623
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
# IP2Proxy Ruby Library
|
5
5
|
|
6
|
-
This module allows user to reverse search of IP address to detect VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots
|
6
|
+
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 and residential proxies using IP2Proxy BIN database. Other information available includes proxy type, country, state, city, ISP, domain name, usage type, AS number, AS name, threats and last seen date.
|
7
7
|
|
8
8
|
It lookup the proxy IP address from **IP2Proxy BIN Data** file. This data file can be downloaded at
|
9
9
|
|
@@ -22,12 +22,12 @@ Below are the methods supported in this module.
|
|
22
22
|
|---|---|
|
23
23
|
|open|Open the IP2Proxy BIN data with **File I/O** mode for lookup.|
|
24
24
|
|close|Close and clean up the file pointer.|
|
25
|
-
|get_package_version|Get the package version (1 to
|
25
|
+
|get_package_version|Get the package version (1 to 10 for PX1 to PX10 respectively).|
|
26
26
|
|get_module_version|Get the module version.|
|
27
27
|
|get_database_version|Get the database version.|
|
28
28
|
|is_proxy|Check whether if an IP address was a proxy. Please see [Proxy Type](#proxy-type) for details. Returned value:<ul><li>-1 : errors</li><li>0 : not a proxy</li><li>1 : a proxy</li><li>2 : a data center IP address</li></ul>|
|
29
29
|
|get_all|Return the proxy information in array.|
|
30
|
-
|get_proxytype|Return the proxy type. Please visit <a href="https://www.ip2location.com/
|
30
|
+
|get_proxytype|Return the proxy type. Please visit <a href="https://www.ip2location.com/database/px10-ip-proxytype-country-region-city-isp-domain-usagetype-asn-lastseen-threat-residential" target="_blank">IP2Location</a> for the list of proxy types supported|
|
31
31
|
|get_country_short|Return the ISO3166-1 country code (2-digits) of the proxy.|
|
32
32
|
|get_country_long|Return the ISO3166-1 country name of the proxy.|
|
33
33
|
|get_region|Return the ISO3166-2 region name of the proxy. Please visit <a href="https://www.ip2location.com/free/iso3166-2" target="_blank">ISO3166-2 Subdivision Code</a> for the information of ISO3166-2 supported|
|
@@ -38,6 +38,7 @@ Below are the methods supported in this module.
|
|
38
38
|
|get_asn|Return the autonomous system number (ASN) of proxy's IP address or domain name.|
|
39
39
|
|get_as|Return the autonomous system (AS) name of proxy's IP address or domain name.|
|
40
40
|
|get_last_seen|Return the last seen days ago value of proxy's IP address or domain name.|
|
41
|
+
|get_threat|Return the threat types reported to proxy's IP address or domain name. Please see [Threat Type](#threat-type) for details.|
|
41
42
|
|
42
43
|
## Usage
|
43
44
|
|
@@ -45,7 +46,7 @@ Below are the methods supported in this module.
|
|
45
46
|
require 'ip2proxy_ruby'
|
46
47
|
|
47
48
|
# open IP2Proxy BIN database for proxy lookup
|
48
|
-
i2p = Ip2proxy.new.open("./data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN.BIN")
|
49
|
+
i2p = Ip2proxy.new.open("./data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL.BIN")
|
49
50
|
|
50
51
|
# get versioning information
|
51
52
|
print 'Module Version: ' + i2p.get_module_version + "\n"
|
@@ -65,6 +66,7 @@ print 'Usage Type: ' + i2p.get_usagetype('1.2.3.4') + "\n"
|
|
65
66
|
print 'ASN: ' + i2p.get_asn('1.2.3.4') + "\n"
|
66
67
|
print 'AS: ' + i2p.get_as('1.2.3.4') + "\n"
|
67
68
|
print 'Last Seen: ' + i2p.get_last_seen('1.2.3.4') + "\n"
|
69
|
+
print 'Threat: ' + i2p.get_threat('1.2.3.4') + "\n"
|
68
70
|
|
69
71
|
# single function to get all proxy data returned in array
|
70
72
|
record = i2p.get_all('1.2.3.4')
|
@@ -80,6 +82,7 @@ print 'Usage Type: ' + record['usagetype'] + "\n"
|
|
80
82
|
print 'ASN: ' + record['asn'] + "\n"
|
81
83
|
print 'AS: ' + record['as'] + "\n"
|
82
84
|
print 'Last Seen: ' + record['last_seen'] + "\n"
|
85
|
+
print 'Threat: ' + record['threat'] + "\n"
|
83
86
|
|
84
87
|
# close IP2Proxy BIN database
|
85
88
|
i2p.close()
|
@@ -89,12 +92,13 @@ i2p.close()
|
|
89
92
|
|
90
93
|
|Proxy Type|Description|
|
91
94
|
|---|---|
|
92
|
-
|VPN|Anonymizing VPN services
|
93
|
-
|TOR|Tor Exit Nodes
|
94
|
-
|PUB|Public Proxies
|
95
|
-
|WEB|Web Proxies
|
96
|
-
|DCH|Hosting Providers/Data Center
|
97
|
-
|SES|Search Engine Robots
|
95
|
+
|VPN|Anonymizing VPN services|
|
96
|
+
|TOR|Tor Exit Nodes|
|
97
|
+
|PUB|Public Proxies|
|
98
|
+
|WEB|Web Proxies|
|
99
|
+
|DCH|Hosting Providers/Data Center|
|
100
|
+
|SES|Search Engine Robots|
|
101
|
+
|RES|Residential Proxies [PX10+]|
|
98
102
|
|
99
103
|
### Usage Type
|
100
104
|
|
@@ -113,6 +117,14 @@ i2p.close()
|
|
113
117
|
|SES|Search Engine Spider|
|
114
118
|
|RSV|Reserved|
|
115
119
|
|
120
|
+
### Threat Type
|
121
|
+
|
122
|
+
|Threat Type|Description|
|
123
|
+
|---|---|
|
124
|
+
|SPAM|Spammer|
|
125
|
+
|SCANNER|Security Scanner or Attack|
|
126
|
+
|BOTNET|Spyware or Malware|
|
127
|
+
|
116
128
|
## Support
|
117
129
|
|
118
130
|
Email: support@ip2location.com
|
data/example.rb
CHANGED
@@ -21,6 +21,7 @@ print 'Usage Type: ' + i2p.get_usagetype('1.2.3.4') + "\n"
|
|
21
21
|
print 'ASN: ' + i2p.get_asn('1.2.3.4') + "\n"
|
22
22
|
print 'AS: ' + i2p.get_as('1.2.3.4') + "\n"
|
23
23
|
print 'Last Seen: ' + i2p.get_last_seen('1.2.3.4') + "\n"
|
24
|
+
print 'Threat: ' + i2p.get_threat('1.2.3.4') + "\n"
|
24
25
|
|
25
26
|
# single function to get all proxy data returned in array
|
26
27
|
record = i2p.get_all('1.2.3.4')
|
@@ -36,6 +37,7 @@ print 'Usage Type: ' + record['usagetype'] + "\n"
|
|
36
37
|
print 'ASN: ' + record['asn'] + "\n"
|
37
38
|
print 'AS: ' + record['as'] + "\n"
|
38
39
|
print 'Last Seen: ' + record['last_seen'] + "\n"
|
40
|
+
print 'Threat: ' + record['threat'] + "\n"
|
39
41
|
|
40
42
|
# close IP2Proxy BIN database
|
41
43
|
i2p.close()
|
data/ip2proxy_ruby.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "ip2proxy_ruby"
|
5
|
-
s.version = "
|
5
|
+
s.version = "3.0.0"
|
6
6
|
s.authors = ["ip2location"]
|
7
7
|
s.email = ["support@ip2location.com"]
|
8
8
|
|
9
9
|
s.summary = "IP2Proxy Ruby library"
|
10
|
-
s.description = "The official IP2Proxy Ruby library to detect VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots
|
10
|
+
s.description = "The official IP2Proxy Ruby library to detect VPN servers, open proxies, web proxies, Tor exit nodes, search engine robots, data center ranges and residential proxies using IP2Proxy BIN database. Other information available includes proxy type, country, state, city, ISP, domain name, usage type, AS number, AS name, threats and last seen date."
|
11
11
|
s.homepage = "https://github.com/ip2location/ip2proxy-ruby"
|
12
12
|
s.licenses = ["MIT"]
|
13
13
|
s.require_paths = ["lib"]
|
data/lib/ip2proxy_ruby.rb
CHANGED
@@ -9,7 +9,7 @@ require_relative 'ip2proxy_ruby/ip2proxy_record'
|
|
9
9
|
class Ip2proxy
|
10
10
|
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
|
11
11
|
|
12
|
-
VERSION = '
|
12
|
+
VERSION = '3.0.0'
|
13
13
|
FIELD_NOT_SUPPORTED = 'NOT SUPPORTED'
|
14
14
|
INVALID_IP_ADDRESS = 'INVALID IP ADDRESS'
|
15
15
|
|
@@ -247,6 +247,21 @@ class Ip2proxy
|
|
247
247
|
return last_seen
|
248
248
|
end
|
249
249
|
|
250
|
+
def get_threat(ip)
|
251
|
+
valid = !(IPAddr.new(ip) rescue nil).nil?
|
252
|
+
if valid
|
253
|
+
rec = get_record(ip)
|
254
|
+
if !(rec.nil?)
|
255
|
+
threat = (defined?(rec.threat) && rec.threat != '') ? rec.threat : FIELD_NOT_SUPPORTED
|
256
|
+
else
|
257
|
+
threat = INVALID_IP_ADDRESS
|
258
|
+
end
|
259
|
+
else
|
260
|
+
threat = INVALID_IP_ADDRESS
|
261
|
+
end
|
262
|
+
return threat
|
263
|
+
end
|
264
|
+
|
250
265
|
def is_proxy(ip)
|
251
266
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
252
267
|
if valid
|
@@ -282,6 +297,7 @@ class Ip2proxy
|
|
282
297
|
asn = (defined?(rec.asn) && rec.asn != '') ? rec.asn : FIELD_NOT_SUPPORTED
|
283
298
|
as = (defined?(rec.as) && rec.as != '') ? rec.as : FIELD_NOT_SUPPORTED
|
284
299
|
last_seen = (defined?(rec.lastseen) && rec.lastseen != '') ? rec.lastseen : FIELD_NOT_SUPPORTED
|
300
|
+
threat = (defined?(rec.threat) && rec.threat != '') ? rec.threat : FIELD_NOT_SUPPORTED
|
285
301
|
if self.db_index == 1
|
286
302
|
isproxy = (rec.country_short == '-') ? 0 : 1
|
287
303
|
else
|
@@ -299,6 +315,7 @@ class Ip2proxy
|
|
299
315
|
asn = INVALID_IP_ADDRESS
|
300
316
|
as = INVALID_IP_ADDRESS
|
301
317
|
last_seen = INVALID_IP_ADDRESS
|
318
|
+
threat = INVALID_IP_ADDRESS
|
302
319
|
isproxy = -1
|
303
320
|
end
|
304
321
|
else
|
@@ -313,6 +330,7 @@ class Ip2proxy
|
|
313
330
|
asn = INVALID_IP_ADDRESS
|
314
331
|
as = INVALID_IP_ADDRESS
|
315
332
|
last_seen = INVALID_IP_ADDRESS
|
333
|
+
threat = INVALID_IP_ADDRESS
|
316
334
|
isproxy = -1
|
317
335
|
end
|
318
336
|
results = {}
|
@@ -328,6 +346,7 @@ class Ip2proxy
|
|
328
346
|
results['asn'] = asn
|
329
347
|
results['as'] = as
|
330
348
|
results['last_seen'] = last_seen
|
349
|
+
results['threat'] = threat
|
331
350
|
return results
|
332
351
|
end
|
333
352
|
|
@@ -1,15 +1,16 @@
|
|
1
1
|
class I2pDbConfig
|
2
2
|
COLUMNS = {
|
3
|
-
:COUNTRY => [0, 2, 3, 3, 3, 3, 3, 3, 3],
|
4
|
-
:REGION => [0, 0, 0, 4, 4, 4, 4, 4, 4],
|
5
|
-
:CITY => [0, 0, 0, 5, 5, 5, 5, 5, 5],
|
6
|
-
:ISP => [0, 0, 0, 0, 6, 6, 6, 6, 6],
|
7
|
-
:PROXYTYPE => [0, 0, 2, 2, 2, 2, 2, 2, 2],
|
8
|
-
:DOMAIN => [0, 0, 0, 0, 0, 7, 7, 7, 7],
|
9
|
-
:USAGETYPE => [0, 0, 0, 0, 0, 0, 8, 8, 8],
|
10
|
-
:ASN => [0, 0, 0, 0, 0, 0, 0, 9, 9],
|
11
|
-
:AS => [0, 0, 0, 0, 0, 0, 0, 10, 10],
|
12
|
-
:LASTSEEN => [0, 0, 0, 0, 0, 0, 0, 0, 11]
|
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]
|
13
14
|
}
|
14
15
|
|
15
16
|
def self.setup_database(db_index)
|
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:
|
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:
|
11
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -95,9 +95,10 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: The official IP2Proxy Ruby library to detect VPN servers, open proxies,
|
98
|
-
web proxies, Tor exit nodes, search engine robots
|
99
|
-
BIN database. Other information available includes proxy
|
100
|
-
ISP, domain name, usage type, AS number, AS name
|
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.
|
101
102
|
email:
|
102
103
|
- support@ip2location.com
|
103
104
|
executables: []
|
@@ -146,7 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
147
|
- !ruby/object:Gem::Version
|
147
148
|
version: '0'
|
148
149
|
requirements: []
|
149
|
-
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.7.6.2
|
150
152
|
signing_key:
|
151
153
|
specification_version: 4
|
152
154
|
summary: IP2Proxy Ruby library
|