ip2proxy_ruby 1.0.2 → 1.0.3
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 +5 -5
- data/LICENSE.txt +1 -1
- data/README.md +71 -47
- data/example.rb +11 -11
- data/ip2proxy_ruby.gemspec +1 -1
- data/lib/ip2proxy_ruby.rb +12 -12
- data/spec/ip2proxy_ruby_spec.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2c78484a2688f93868d5de9ada23bf1b9ce0b8ede672310e841269c3e55dcb4a
|
4
|
+
data.tar.gz: 8984b09192407fb219ea0e3e68f5324fc69456150eefaaeb087db8b14cbb05be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 754614eeca4b9db1c69956460f277132d95bc872dc083eb732b44dcc05b6866aa67e160d216d0853ed58fe30d08e9b2e7be219870be4914e3712ce7cbfb9c7af
|
7
|
+
data.tar.gz: da8b691e0b4ff992f544a865d720e5c3b25fdac0ca712e069b27ec626f6c3dbbe46eb2979508b7d5239f8a6dc0e643d1c1b1eb3ae4f9fcf4c15b2d970aba461b
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,47 +1,71 @@
|
|
1
|
-
# IP2Proxy Ruby Library
|
2
|
-
|
3
|
-
This
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
i2p.
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
1
|
+
# IP2Proxy Ruby Library
|
2
|
+
|
3
|
+
This module allows user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits. It lookup the proxy IP address from **IP2Proxy BIN Data** file. This data file can be downloaded at
|
4
|
+
|
5
|
+
* Free IP2Proxy BIN Data: https://lite.ip2location.com
|
6
|
+
* Commercial IP2Proxy BIN Data: https://www.ip2location.com/proxy-database
|
7
|
+
|
8
|
+
|
9
|
+
For more details, please visit:
|
10
|
+
[https://www.ip2location.com/ip2proxy/developers/ruby](https://www.ip2location.com/ip2proxy/developers/ruby)
|
11
|
+
|
12
|
+
## Methods
|
13
|
+
|
14
|
+
Below are the methods supported in this module.
|
15
|
+
|
16
|
+
|Method Name|Description|
|
17
|
+
|---|---|
|
18
|
+
|open|Open the IP2Proxy BIN data with **File I/O** mode for lookup.|
|
19
|
+
|close|Close and clean up the file pointer.|
|
20
|
+
|get_package_version|Get the package version (1 to 4 for PX1 to PX4 respectively).|
|
21
|
+
|get_module_version|Get the module version.|
|
22
|
+
|get_database_version|Get the database version.|
|
23
|
+
|is_proxy|Check whether if an IP address was a proxy. 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>|
|
24
|
+
|get_all|Return the proxy information in array.|
|
25
|
+
|get_proxytype|Return the proxy type. Please visit <a href="https://www.ip2location.com/databases/px4-ip-proxytype-country-region-city-isp" target="_blank">IP2Location</a> for the list of proxy types supported|
|
26
|
+
|get_country_short|Return the ISO3166-1 country code (2-digits) of the proxy.|
|
27
|
+
|get_country_long|Return the ISO3166-1 country name of the proxy.|
|
28
|
+
|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|
|
29
|
+
|get_city|Return the city name of the proxy.|
|
30
|
+
|get_isp|Return the ISP name of the proxy.|
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
```
|
35
|
+
require 'ip2proxy_ruby'
|
36
|
+
|
37
|
+
# open IP2Proxy BIN database for proxy lookup
|
38
|
+
i2p = Ip2proxy.new.open("./data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
|
39
|
+
|
40
|
+
# get versioning information
|
41
|
+
print 'Module Version: ' + i2p.get_module_version + "\n"
|
42
|
+
print 'Package Version: ' + i2p.get_package_version + "\n"
|
43
|
+
print 'Database Version: ' + i2p.get_database_version + "\n"
|
44
|
+
|
45
|
+
# individual proxy data check
|
46
|
+
print 'Is Proxy: ' + i2p.is_proxy('4.0.0.47').to_s + "\n"
|
47
|
+
print 'Proxy Type: ' + i2p.get_proxytype('4.0.0.47') + "\n"
|
48
|
+
print 'Country Code: ' + i2p.get_country_short('4.0.0.47') + "\n"
|
49
|
+
print 'Country Name: ' + i2p.get_country_long('4.0.0.47') + "\n"
|
50
|
+
print 'Region Name: ' + i2p.get_region('4.0.0.47') + "\n"
|
51
|
+
print 'City Name: ' + i2p.get_city('4.0.0.47') + "\n"
|
52
|
+
print 'ISP: ' + i2p.get_isp('4.0.0.47') + "\n"
|
53
|
+
|
54
|
+
# single function to get all proxy data returned in array
|
55
|
+
record = i2p.get_all('4.0.0.47')
|
56
|
+
print 'is Proxy: ' + record['is_proxy'].to_s + "\n"
|
57
|
+
print 'Proxy Type: ' + record['proxy_type'] + "\n"
|
58
|
+
print 'Country Code: ' + record['country_short'] + "\n"
|
59
|
+
print 'Country Name: ' + record['country_long'] + "\n"
|
60
|
+
print 'Region Name: ' + record['region'] + "\n"
|
61
|
+
print 'City Name: ' + record['city'] + "\n"
|
62
|
+
print 'ISP: ' + record['isp'] + "\n"
|
63
|
+
|
64
|
+
# close IP2Proxy BIN database
|
65
|
+
i2p.close()
|
66
|
+
```
|
67
|
+
|
68
|
+
## Support
|
69
|
+
|
70
|
+
Email: support@ip2location.com
|
71
|
+
URL: [https://www.ip2location.com](https://www.ip2location.com)
|
data/example.rb
CHANGED
@@ -4,21 +4,21 @@ require 'ip2proxy_ruby'
|
|
4
4
|
i2p = Ip2proxy.new.open("./data/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
|
5
5
|
|
6
6
|
# get versioning information
|
7
|
-
print 'Module Version: ' + i2p.
|
8
|
-
print 'Package Version: ' + i2p.
|
9
|
-
print 'Database Version: ' + i2p.
|
7
|
+
print 'Module Version: ' + i2p.get_module_version + "\n"
|
8
|
+
print 'Package Version: ' + i2p.get_package_version + "\n"
|
9
|
+
print 'Database Version: ' + i2p.get_database_version + "\n"
|
10
10
|
|
11
11
|
# individual proxy data check
|
12
|
-
print 'Is Proxy: ' + i2p.
|
13
|
-
print 'Proxy Type: ' + i2p.
|
14
|
-
print 'Country Code: ' + i2p.
|
15
|
-
print 'Country Name: ' + i2p.
|
16
|
-
print 'Region Name: ' + i2p.
|
17
|
-
print 'City Name: ' + i2p.
|
18
|
-
print 'ISP: ' + i2p.
|
12
|
+
print 'Is Proxy: ' + i2p.is_proxy('4.0.0.47').to_s + "\n"
|
13
|
+
print 'Proxy Type: ' + i2p.get_proxytype('4.0.0.47') + "\n"
|
14
|
+
print 'Country Code: ' + i2p.get_country_short('4.0.0.47') + "\n"
|
15
|
+
print 'Country Name: ' + i2p.get_country_long('4.0.0.47') + "\n"
|
16
|
+
print 'Region Name: ' + i2p.get_region('4.0.0.47') + "\n"
|
17
|
+
print 'City Name: ' + i2p.get_city('4.0.0.47') + "\n"
|
18
|
+
print 'ISP: ' + i2p.get_isp('4.0.0.47') + "\n"
|
19
19
|
|
20
20
|
# single function to get all proxy data returned in array
|
21
|
-
record = i2p.
|
21
|
+
record = i2p.get_all('4.0.0.47')
|
22
22
|
print 'is Proxy: ' + record['is_proxy'].to_s + "\n"
|
23
23
|
print 'Proxy Type: ' + record['proxy_type'] + "\n"
|
24
24
|
print 'Country Code: ' + record['country_short'] + "\n"
|
data/ip2proxy_ruby.gemspec
CHANGED
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 = '1.0.
|
12
|
+
VERSION = '1.0.3'
|
13
13
|
FIELD_NOT_SUPPORTED = 'NOT SUPPORTED'
|
14
14
|
INVALID_IP_ADDRESS = 'INVALID IP ADDRESS'
|
15
15
|
|
@@ -37,15 +37,15 @@ class Ip2proxy
|
|
37
37
|
self.file.close
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
40
|
+
def get_module_version()
|
41
41
|
return VERSION
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def get_package_version()
|
45
45
|
return (self.db_index).to_s
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def get_database_version()
|
49
49
|
return (self.databaseyear).to_s + "." + (self.databasemonth).to_s + "." + (self.databaseday).to_s
|
50
50
|
end
|
51
51
|
|
@@ -77,7 +77,7 @@ class Ip2proxy
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
def
|
80
|
+
def get_country_short(ip)
|
81
81
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
82
82
|
if valid
|
83
83
|
rec = get_record(ip)
|
@@ -92,7 +92,7 @@ class Ip2proxy
|
|
92
92
|
return country_short
|
93
93
|
end
|
94
94
|
|
95
|
-
def
|
95
|
+
def get_country_long(ip)
|
96
96
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
97
97
|
if valid
|
98
98
|
rec = get_record(ip)
|
@@ -107,7 +107,7 @@ class Ip2proxy
|
|
107
107
|
return country_long
|
108
108
|
end
|
109
109
|
|
110
|
-
def
|
110
|
+
def get_region(ip)
|
111
111
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
112
112
|
if valid
|
113
113
|
rec = get_record(ip)
|
@@ -122,7 +122,7 @@ class Ip2proxy
|
|
122
122
|
return region
|
123
123
|
end
|
124
124
|
|
125
|
-
def
|
125
|
+
def get_city(ip)
|
126
126
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
127
127
|
if valid
|
128
128
|
rec = get_record(ip)
|
@@ -137,7 +137,7 @@ class Ip2proxy
|
|
137
137
|
return city
|
138
138
|
end
|
139
139
|
|
140
|
-
def
|
140
|
+
def get_isp(ip)
|
141
141
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
142
142
|
if valid
|
143
143
|
rec = get_record(ip)
|
@@ -152,7 +152,7 @@ class Ip2proxy
|
|
152
152
|
return isp
|
153
153
|
end
|
154
154
|
|
155
|
-
def
|
155
|
+
def get_proxytype(ip)
|
156
156
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
157
157
|
if valid
|
158
158
|
rec = get_record(ip)
|
@@ -167,7 +167,7 @@ class Ip2proxy
|
|
167
167
|
return proxytype
|
168
168
|
end
|
169
169
|
|
170
|
-
def
|
170
|
+
def is_proxy(ip)
|
171
171
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
172
172
|
if valid
|
173
173
|
rec = get_record(ip)
|
@@ -186,7 +186,7 @@ class Ip2proxy
|
|
186
186
|
return isproxy
|
187
187
|
end
|
188
188
|
|
189
|
-
def
|
189
|
+
def get_all(ip)
|
190
190
|
valid = !(IPAddr.new(ip) rescue nil).nil?
|
191
191
|
if valid
|
192
192
|
rec = get_record(ip)
|
data/spec/ip2proxy_ruby_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe "Ip2proxy" do
|
4
4
|
it "work correctly with ipv4" do
|
5
5
|
i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
|
6
|
-
record = i2p.
|
6
|
+
record = i2p.get_all('1.0.241.135')
|
7
7
|
record.should_not be_nil
|
8
8
|
record['is_proxy'].should == 1
|
9
9
|
i2p.close()
|
@@ -11,7 +11,7 @@ describe "Ip2proxy" do
|
|
11
11
|
|
12
12
|
it "work correctly with ipv6" do
|
13
13
|
i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP.SAMPLE.BIN")
|
14
|
-
record = i2p.
|
14
|
+
record = i2p.get_all('2001::')
|
15
15
|
record.should_not be_nil
|
16
16
|
record['is_proxy'].should == 0
|
17
17
|
i2p.close()
|
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.
|
4
|
+
version: 1.0.3
|
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: 2018-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
version: '0'
|
143
143
|
requirements: []
|
144
144
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.
|
145
|
+
rubygems_version: 2.7.7
|
146
146
|
signing_key:
|
147
147
|
specification_version: 4
|
148
148
|
summary: IP2Proxy Ruby library
|