ip2proxy_ruby 3.3.0 → 3.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30a6be5f8b9be3046d9450d970a996f61f07d49c35dc8ad44036f534457e8cb1
4
- data.tar.gz: 7b2babc2892f5f6c29d5038ab86d23da675e7cd0acadac7bf035e2ab2f2fff39
3
+ metadata.gz: e344a1f199333b229ab18e7a461caa60ab70d6a287e44915b27007be9f854970
4
+ data.tar.gz: efdd3f09798abc2bd99a7d3a391c607e9436b71ff151c48c4836d7cbe6a7940d
5
5
  SHA512:
6
- metadata.gz: 0304a809be3a8fc3e87265b2c93811a91aa6595d1ce535132db963d114a6ec4b9e2102dc2418f99d3812ada25cc18fff631065387e9b1aff3dad777ac1c598c8
7
- data.tar.gz: 6faecc7b8ca06d0b0221fa926d587d45bd9e447f881f1b0e7a84e3873adb6a7af831ba9d37fe5105f6f7e46e82113e89f968735c30d401a67dafa6fcc4c85889
6
+ metadata.gz: dd25f8039cd727ddfb7ea5827fd90e115e89eb240cd15d7cdf33b222d3bb0c059c26d07bbd742a54f9001edde838394eda229ce7b62004fbf8c29dea661c9deb
7
+ data.tar.gz: 7fb434d314ecdfda0762400463e372b216086e41c0139ed7ad5014452434580ecf5819e66bb0f0db854c9c2bb5a99828acd1e640f2010cac3496f57a26776452
data/Gemfile CHANGED
@@ -2,4 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in ip2proxy_ruby.gemspec
4
4
  gemspec
5
- gem 'bindata'
5
+ gem 'bindata', "~> 2.4.15"
data/LICENSE.txt CHANGED
@@ -1,20 +1,20 @@
1
- Copyright (c) 2022 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.
1
+ Copyright (c) 2016 - 2025 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 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, 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
- # Usage
11
- You can check the **example.rb** file to learn more about usage.
12
-
13
- ## BIN Database
14
- An outdated BIN database was provided in the library for your testing. You are recommended to visit the [links](#dependencies) to download the latest BIN database and save it in the ```rb``` folder.
15
-
16
- Below is the description of the functions available in the **BIN Database** lookup.
17
-
18
- |Method Name|Description|
19
- |---|---|
20
- |open|Open the IP2Proxy BIN data with **File I/O** mode for lookup.|
21
- |close|Close and clean up the file pointer.|
22
- |get_package_version|Get the package version (1 to 11 for PX1 to PX11 respectively).|
23
- |get_module_version|Get the module version.|
24
- |get_database_version|Get the database version.|
25
- |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>|
26
- |get_all|Return the proxy information in array.|
27
- |get_proxytype|Return the proxy type. Please visit <a href="https://www.ip2location.com/database/px11-ip-proxytype-country-region-city-isp-domain-usagetype-asn-lastseen-threat-residential-provider" target="_blank">IP2Location</a> for the list of proxy types supported|
28
- |get_country_short|Return the ISO3166-1 country code (2-digits) of the proxy.|
29
- |get_country_long|Return the ISO3166-1 country name of the proxy.|
30
- |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|
31
- |get_city|Return the city name of the proxy.|
32
- |get_isp|Return the ISP name of the proxy.|
33
- |get_domain|Return the domain name of proxy's IP address or domain name.|
34
- |get_usagetype|Return the ISP's usage type of proxy's IP address or domain name. Please see [Usage Type](#usage-type) for details.|
35
- |get_asn|Return the autonomous system number (ASN) of proxy's IP address or domain name.|
36
- |get_as|Return the autonomous system (AS) name of proxy's IP address or domain name.|
37
- |get_last_seen|Return the last seen days ago value of proxy's IP address or domain name.|
38
- |get_threat|Return the threat types reported to proxy's IP address or domain name. Please see [Threat Type](#threat-type) for details.|
39
- |get_provider|Returns the VPN service provider name if available.|
40
-
41
- ## Web Service
42
- Below is the description of the functions available in the **Web Service** lookup.
43
-
44
- | Function Name | Description |
45
- |---|---|
46
- | Constructor | Expect 3 input parameters:<ol><li>IP2Proxy API Key.</li><li>Package (PX1 - PX11)</li></li><li>Use HTTPS or HTTP</li></ol> |
47
- | lookup | Return the proxy information in array.<ul><li>countryCode</li><li>countryName</li><li>regionName</li><li>cityName</li><li>isp</li><li>domain</li><li>usageType</li><li>asn</li><li>as</li><li>lastSeen</li><li>threat</li><li>proxyType</li><li>isProxy</li><li>provider</li><ul> |
48
- | get_credit | Return remaining credit of the web service account. |
49
-
50
- ### Proxy Type
51
-
52
- |Proxy Type|Description|
53
- |---|---|
54
- |VPN|Anonymizing VPN services|
55
- |TOR|Tor Exit Nodes|
56
- |PUB|Public Proxies|
57
- |WEB|Web Proxies|
58
- |DCH|Hosting Providers/Data Center|
59
- |SES|Search Engine Robots|
60
- |RES|Residential Proxies [PX10+]|
61
-
62
- ### Usage Type
63
-
64
- |Usage Type|Description|
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
@@ -1,7 +1,7 @@
1
1
  require 'ip2proxy_ruby'
2
2
 
3
3
  # open IP2Proxy BIN database for proxy lookup
4
- i2p = Ip2proxy.new.open("./data/PX11.SAMPLE.BIN")
4
+ i2p = Ip2proxy.new.open("./data/PX12.SAMPLE.BIN")
5
5
 
6
6
  # get versioning information
7
7
  print 'Module Version: ' + i2p.get_module_version + "\n"
@@ -23,6 +23,7 @@ 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
24
  print 'Threat: ' + i2p.get_threat('1.2.3.4') + "\n"
25
25
  print 'Provider: ' + i2p.get_provider('1.2.3.4') + "\n"
26
+ print 'Fraud Score: ' + i2p.get_fraud_score('1.2.3.4') + "\n"
26
27
 
27
28
  # single function to get all proxy data returned in array
28
29
  record = i2p.get_all('1.2.3.4')
@@ -40,13 +41,7 @@ print 'AS: ' + record['as'] + "\n"
40
41
  print 'Last Seen: ' + record['last_seen'] + "\n"
41
42
  print 'Threat: ' + record['threat'] + "\n"
42
43
  print 'Provider: ' + record['provider'] + "\n"
44
+ print 'Fraud Score: ' + record['fraud_score'] + "\n"
43
45
 
44
46
  # 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()
47
+ i2p.close()
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "ip2proxy_ruby"
5
- s.version = "3.3.0"
5
+ s.version = "3.4.0"
6
6
  s.authors = ["ip2location"]
7
7
  s.email = ["support@ip2location.com"]
8
8
 
@@ -31,15 +31,16 @@ Gem::Specification.new do |s|
31
31
  "lib/ip2proxy_ruby/i2p_string_data.rb",
32
32
  "lib/ip2proxy_ruby/ip2proxy_config.rb",
33
33
  "lib/ip2proxy_ruby/ip2proxy_record.rb",
34
- "spec/assets/PX11.SAMPLE.BIN",
34
+ "spec/assets/PX12.SAMPLE.BIN",
35
35
  "spec/ip2proxy_ruby_database_spec.rb",
36
36
  "spec/spec_helper.rb",
37
- "rb/data/PX11.SAMPLE.BIN"
37
+ "rb/data/PX12.SAMPLE.BIN"
38
38
  ]
39
39
 
40
40
  if s.respond_to?(:metadata=)
41
41
  s.metadata = {
42
42
  "bug_tracker_uri" => "https://github.com/ip2location/ip2proxy-ruby/issues",
43
+ "documentation_uri" => "https://www.rubydoc.info/gems/ip2proxy_ruby",
43
44
  "homepage_uri" => "https://www.ip2location.com",
44
45
  "source_code_uri" => "https://github.com/ip2location/ip2proxy-ruby",
45
46
  }
@@ -49,18 +50,18 @@ Gem::Specification.new do |s|
49
50
  s.specification_version = 4
50
51
 
51
52
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
- s.add_runtime_dependency(%q<bindata>, [">= 0"])
53
+ s.add_runtime_dependency(%q<bindata>, ["~> 2.4.15"])
53
54
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
54
55
  s.add_development_dependency(%q<rdoc>, [">= 6.3.1"])
55
56
  s.add_development_dependency(%q<bundler>, [">= 1.2.0"])
56
57
  else
57
- s.add_dependency(%q<bindata>, [">= 0"])
58
+ s.add_dependency(%q<bindata>, ["~> 2.4.15"])
58
59
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
59
60
  s.add_dependency(%q<rdoc>, [">= 6.3.1"])
60
61
  s.add_dependency(%q<bundler>, [">= 1.2.0"])
61
62
  end
62
63
  else
63
- s.add_dependency(%q<bindata>, [">= 0"])
64
+ s.add_dependency(%q<bindata>, ["~> 2.4.15"])
64
65
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
65
66
  s.add_dependency(%q<rdoc>, [">= 6.3.1"])
66
67
  s.add_dependency(%q<bundler>, [">= 1.2.0"])
@@ -1,17 +1,18 @@
1
1
  class I2pDbConfig
2
2
  COLUMNS = {
3
- :COUNTRY => [0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
4
- :REGION => [0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4],
5
- :CITY => [0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5],
6
- :ISP => [0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6],
7
- :PROXYTYPE => [0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
8
- :DOMAIN => [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7],
9
- :USAGETYPE => [0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8],
10
- :ASN => [0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9],
11
- :AS => [0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10],
12
- :LASTSEEN => [0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11],
13
- :THREAT => [0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12],
14
- :PROVIDER => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13]
3
+ :COUNTRY => [0, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],
4
+ :REGION => [0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
5
+ :CITY => [0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],
6
+ :ISP => [0, 0, 0, 0, 6, 6, 6, 6, 6, 6, 6, 6, 6],
7
+ :PROXYTYPE => [0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
8
+ :DOMAIN => [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7],
9
+ :USAGETYPE => [0, 0, 0, 0, 0, 0, 8, 8, 8, 8, 8, 8, 8],
10
+ :ASN => [0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 9, 9],
11
+ :AS => [0, 0, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 10],
12
+ :LASTSEEN => [0, 0, 0, 0, 0, 0, 0, 0, 11, 11, 11, 11, 11],
13
+ :THREAT => [0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 12, 12, 12],
14
+ :PROVIDER => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 13],
15
+ :FRAUD_SCORE => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14]
15
16
  }
16
17
 
17
18
  def self.setup_database(db_index)
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.3.0'
14
+ VERSION = '3.4.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.'
@@ -322,6 +322,21 @@ class Ip2proxy
322
322
  return provider
323
323
  end
324
324
 
325
+ def get_fraud_score(ip)
326
+ valid = !(IPAddr.new(ip) rescue nil).nil?
327
+ if valid
328
+ rec = get_record(ip)
329
+ if !(rec.nil?)
330
+ fraud_score = (defined?(rec.fraud_score) && rec.fraud_score != '') ? rec.fraud_score : FIELD_NOT_SUPPORTED
331
+ else
332
+ fraud_score = INVALID_IP_ADDRESS
333
+ end
334
+ else
335
+ fraud_score = INVALID_IP_ADDRESS
336
+ end
337
+ return fraud_score
338
+ end
339
+
325
340
  def get_all(ip)
326
341
  valid = !(IPAddr.new(ip) rescue nil).nil?
327
342
  if valid
@@ -340,6 +355,7 @@ class Ip2proxy
340
355
  last_seen = (defined?(rec.lastseen) && rec.lastseen != '') ? rec.lastseen : FIELD_NOT_SUPPORTED
341
356
  threat = (defined?(rec.threat) && rec.threat != '') ? rec.threat : FIELD_NOT_SUPPORTED
342
357
  provider = (defined?(rec.provider) && rec.provider != '') ? rec.provider : FIELD_NOT_SUPPORTED
358
+ fraud_score = (defined?(rec.fraud_score) && rec.fraud_score != '') ? rec.fraud_score : FIELD_NOT_SUPPORTED
343
359
  if self.db_index == 1
344
360
  isproxy = (rec.country_short == '-') ? 0 : 1
345
361
  else
@@ -359,6 +375,7 @@ class Ip2proxy
359
375
  last_seen = INVALID_IP_ADDRESS
360
376
  threat = INVALID_IP_ADDRESS
361
377
  provider = INVALID_IP_ADDRESS
378
+ fraud_score = INVALID_IP_ADDRESS
362
379
  isproxy = -1
363
380
  end
364
381
  else
@@ -375,6 +392,7 @@ class Ip2proxy
375
392
  last_seen = INVALID_IP_ADDRESS
376
393
  threat = INVALID_IP_ADDRESS
377
394
  provider = INVALID_IP_ADDRESS
395
+ fraud_score = INVALID_IP_ADDRESS
378
396
  isproxy = -1
379
397
  end
380
398
  results = {}
@@ -392,6 +410,7 @@ class Ip2proxy
392
410
  results['last_seen'] = last_seen
393
411
  results['threat'] = threat
394
412
  results['provider'] = provider
413
+ results['fraud_score'] = fraud_score
395
414
  return results
396
415
  end
397
416
 
Binary file
Binary file
@@ -2,122 +2,128 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Ip2proxy" do
4
4
  it "work correctly with invalid ip" do
5
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
5
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
6
6
  record = i2p.get_all('1.0.0.x')
7
7
  expect(record['country_short']).to eq 'INVALID IP ADDRESS'
8
8
  end
9
9
 
10
10
  it "work correctly with get_all ipv4" do
11
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
11
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
12
12
  record = i2p.get_all('1.0.0.8')
13
- expect(record['country_short']).to eq 'US'
13
+ expect(record['country_short']).to eq '-'
14
14
  end
15
15
 
16
16
  it "work correctly with get_country_short" do
17
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
17
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
18
18
  record = i2p.get_country_short('1.0.0.8')
19
- expect(record).to eq 'US'
19
+ expect(record).to eq '-'
20
20
  end
21
21
 
22
22
  it "work correctly with get_country_long" do
23
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
23
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
24
24
  record = i2p.get_country_long('1.0.0.8')
25
- expect(record).to eq 'United States of America'
25
+ expect(record).to eq '-'
26
26
  end
27
27
 
28
28
  it "work correctly with get_region" do
29
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
29
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
30
30
  record = i2p.get_region('1.0.0.8')
31
- expect(record).to eq 'California'
31
+ expect(record).to eq '-'
32
32
  end
33
33
 
34
34
  it "work correctly with get_city" do
35
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
35
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
36
36
  record = i2p.get_city('1.0.0.8')
37
- expect(record).to eq 'Los Angeles'
37
+ expect(record).to eq '-'
38
38
  end
39
39
 
40
40
  it "work correctly with get_isp" do
41
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
41
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
42
42
  record = i2p.get_isp('1.0.0.8')
43
- expect(record).to eq 'APNIC and CloudFlare DNS Resolver Project'
43
+ expect(record).to eq '-'
44
44
  end
45
45
 
46
46
  it "work correctly with get_domain" do
47
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
47
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
48
48
  record = i2p.get_domain('1.0.0.8')
49
- expect(record).to eq 'cloudflare.com'
49
+ expect(record).to eq '-'
50
50
  end
51
51
 
52
52
  it "work correctly with get_usagetype" do
53
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
53
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
54
54
  record = i2p.get_usagetype('1.0.0.8')
55
- expect(record).to eq 'CDN'
55
+ expect(record).to eq '-'
56
56
  end
57
57
 
58
58
  it "work correctly with get_asn" do
59
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
59
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
60
60
  record = i2p.get_asn('1.0.0.8')
61
- expect(record).to eq '13335'
61
+ expect(record).to eq '-'
62
62
  end
63
63
 
64
64
  it "work correctly with get_as" do
65
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
65
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
66
66
  record = i2p.get_as('1.0.0.8')
67
- expect(record).to eq 'CLOUDFLARENET'
67
+ expect(record).to eq '-'
68
68
  end
69
69
 
70
70
  it "work correctly with get_last_seen" do
71
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
71
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
72
72
  record = i2p.get_last_seen('1.0.0.8')
73
- expect(record).to eq '22'
73
+ expect(record).to eq '-'
74
74
  end
75
75
 
76
76
  it "work correctly with get_threat" do
77
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
77
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
78
78
  record = i2p.get_threat('1.0.0.8')
79
79
  expect(record).to eq '-'
80
80
  end
81
81
 
82
82
  it "work correctly with is_proxy" do
83
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
83
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
84
84
  record = i2p.is_proxy('1.0.0.8')
85
- expect(record).to eq 2
85
+ expect(record).to eq 0
86
86
  end
87
87
 
88
88
  it "work correctly with get_proxytype" do
89
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
89
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
90
90
  record = i2p.get_proxytype('1.0.0.8')
91
- expect(record).to eq 'DCH'
91
+ expect(record).to eq '-'
92
92
  end
93
93
 
94
94
  it "work correctly with get_provider" do
95
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
95
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
96
96
  record = i2p.get_provider('1.0.0.8')
97
- expect(record).to eq 'CloudFlare'
97
+ expect(record).to eq '-'
98
+ end
99
+
100
+ it "work correctly with get_fraud_score" do
101
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
102
+ record = i2p.get_fraud_score('1.0.0.8')
103
+ expect(record).to eq '0'
98
104
  end
99
105
 
100
106
  it "work correctly with get_all ipv6" do
101
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
107
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
102
108
  record = i2p.get_all('2c0f:ffa0::4')
103
- expect(record['country_short']).to eq 'UG'
109
+ expect(record['country_short']).to eq '-'
104
110
  end
105
111
 
106
112
  it "work correctly with get_module_version" do
107
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
113
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
108
114
  record = i2p.get_module_version()
109
- expect(record).to eq '3.3.0'
115
+ expect(record).to eq '3.4.0'
110
116
  end
111
117
 
112
118
  it "work correctly with get_package_version" do
113
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
119
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
114
120
  record = i2p.get_package_version()
115
- expect(record).to eq '11'
121
+ expect(record).to eq '12'
116
122
  end
117
123
 
118
124
  it "work correctly with get_database_version" do
119
- i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX11.SAMPLE.BIN")
125
+ i2p = Ip2proxy.new.open(File.dirname(__FILE__) + "/assets/PX12.SAMPLE.BIN")
120
126
  record = i2p.get_database_version()
121
- expect(record).to eq '2021.5.28'
127
+ expect(record).to eq '2025.2.5'
122
128
  end
123
129
  end
metadata CHANGED
@@ -1,29 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip2proxy_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ip2location
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-06-21 00:00:00.000000000 Z
10
+ date: 2025-02-20 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: bindata
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - ">="
16
+ - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '0'
18
+ version: 2.4.15
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - ">="
23
+ - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '0'
25
+ version: 2.4.15
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: rspec
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -93,8 +92,8 @@ files:
93
92
  - lib/ip2proxy_ruby/i2p_string_data.rb
94
93
  - lib/ip2proxy_ruby/ip2proxy_config.rb
95
94
  - lib/ip2proxy_ruby/ip2proxy_record.rb
96
- - rb/data/PX11.SAMPLE.BIN
97
- - spec/assets/PX11.SAMPLE.BIN
95
+ - rb/data/PX12.SAMPLE.BIN
96
+ - spec/assets/PX12.SAMPLE.BIN
98
97
  - spec/ip2proxy_ruby_database_spec.rb
99
98
  - spec/spec_helper.rb
100
99
  homepage: https://github.com/ip2location/ip2proxy-ruby
@@ -102,9 +101,9 @@ licenses:
102
101
  - MIT
103
102
  metadata:
104
103
  bug_tracker_uri: https://github.com/ip2location/ip2proxy-ruby/issues
104
+ documentation_uri: https://www.rubydoc.info/gems/ip2proxy_ruby
105
105
  homepage_uri: https://www.ip2location.com
106
106
  source_code_uri: https://github.com/ip2location/ip2proxy-ruby
107
- post_install_message:
108
107
  rdoc_options: []
109
108
  require_paths:
110
109
  - lib
@@ -119,8 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
118
  - !ruby/object:Gem::Version
120
119
  version: '0'
121
120
  requirements: []
122
- rubygems_version: 3.2.33
123
- signing_key:
121
+ rubygems_version: 3.6.4
124
122
  specification_version: 4
125
123
  summary: IP2Proxy Ruby library
126
124
  test_files: []
Binary file
Binary file