ip2proxy_ruby 3.4.0 → 3.5.1

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: e344a1f199333b229ab18e7a461caa60ab70d6a287e44915b27007be9f854970
4
- data.tar.gz: efdd3f09798abc2bd99a7d3a391c607e9436b71ff151c48c4836d7cbe6a7940d
3
+ metadata.gz: 48e91ed1c5f7655a4cf3118f0cb2794f4aae5f391a9a2910a75e178b29a4d484
4
+ data.tar.gz: bb8d4ec7adaa8dbd44f228d7bf544c4be5d05395faabca20ea79dbbf6fe35472
5
5
  SHA512:
6
- metadata.gz: dd25f8039cd727ddfb7ea5827fd90e115e89eb240cd15d7cdf33b222d3bb0c059c26d07bbd742a54f9001edde838394eda229ce7b62004fbf8c29dea661c9deb
7
- data.tar.gz: 7fb434d314ecdfda0762400463e372b216086e41c0139ed7ad5014452434580ecf5819e66bb0f0db854c9c2bb5a99828acd1e640f2010cac3496f57a26776452
6
+ metadata.gz: 263d523594651fd7b19e4064fdddf0d8869c8d369085dd1716960873f4fb05fce2d40dfb96e843cd4da22a01323eaa7822df82fea73b9a891e15177dfcc4cfcb
7
+ data.tar.gz: 1afd1cfbce8b9327c0a608c7d9bd3d220f35985579ff097936f794cf100dd81dd1e75823b580b158ce6d0309501f920c152daa525a066ebded7e2da4bcecb8c1
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', "~> 2.4.15"
5
+ gem 'bindata', "~> 3.0"
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016 - 2025 IP2Location ( support@ip2location.com )
1
+ Copyright (c) 2016-2026 IP2Location ( support@ip2location.com )
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
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
6
 
7
7
  For more details, please visit:
8
- [https://www.ip2location.com/ip2proxy/developers/ruby](https://www.ip2location.com/ip2proxy/developers/ruby)
8
+ [https://www.ip2location.com/documentation/ip2proxy-libraries/ruby](https://www.ip2location.com/documentation/ip2proxy-libraries/ruby)
9
9
 
10
10
  # Developer Documentation
11
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)
@@ -24,6 +24,7 @@ To learn more about installation, usage, and code examples, please visit the dev
24
24
  |RES|Residential Proxies [PX10+]|
25
25
  |CPN|Consumer Privacy Networks. [PX11+]|
26
26
  |EPN|Enterprise Private Networks. [PX11+]|
27
+ |AIC|AI Crawler. [PX12]|
27
28
 
28
29
  ### Usage Type
29
30
 
@@ -41,14 +42,16 @@ To learn more about installation, usage, and code examples, please visit the dev
41
42
  |DCH|Data Center/Web Hosting/Transit|
42
43
  |SES|Search Engine Spider|
43
44
  |RSV|Reserved|
45
+ |AIC|AI Crawler|
44
46
 
45
47
  ### Threat Type
46
48
 
47
49
  |Threat Type|Description|
48
50
  |---|---|
49
- |SPAM|Spammer|
51
+ |SPAM|Email and forum spammers|
50
52
  |SCANNER|Security Scanner or Attack|
51
53
  |BOTNET|Spyware or Malware|
54
+ |BOGON|Unassigned or illegitimate IP addresses announced via BGP|
52
55
 
53
56
  # Dependencies
54
57
 
data/example.rb CHANGED
@@ -1,47 +1,47 @@
1
- require 'ip2proxy_ruby'
2
-
3
- # open IP2Proxy BIN database for proxy lookup
4
- i2p = Ip2proxy.new.open("./data/PX12.SAMPLE.BIN")
5
-
6
- # get versioning information
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
-
11
- # individual proxy data check
12
- print 'Is Proxy: ' + i2p.is_proxy('1.2.3.4').to_s + "\n"
13
- print 'Proxy Type: ' + i2p.get_proxytype('1.2.3.4') + "\n"
14
- print 'Country Code: ' + i2p.get_country_short('1.2.3.4') + "\n"
15
- print 'Country Name: ' + i2p.get_country_long('1.2.3.4') + "\n"
16
- print 'Region Name: ' + i2p.get_region('1.2.3.4') + "\n"
17
- print 'City Name: ' + i2p.get_city('1.2.3.4') + "\n"
18
- print 'ISP: ' + i2p.get_isp('1.2.3.4') + "\n"
19
- print 'Domain: ' + i2p.get_domain('1.2.3.4') + "\n"
20
- print 'Usage Type: ' + i2p.get_usagetype('1.2.3.4') + "\n"
21
- print 'ASN: ' + i2p.get_asn('1.2.3.4') + "\n"
22
- print 'AS: ' + i2p.get_as('1.2.3.4') + "\n"
23
- print 'Last Seen: ' + i2p.get_last_seen('1.2.3.4') + "\n"
24
- print 'Threat: ' + i2p.get_threat('1.2.3.4') + "\n"
25
- print 'Provider: ' + i2p.get_provider('1.2.3.4') + "\n"
26
- print 'Fraud Score: ' + i2p.get_fraud_score('1.2.3.4') + "\n"
27
-
28
- # single function to get all proxy data returned in array
29
- record = i2p.get_all('1.2.3.4')
30
- print 'is Proxy: ' + record['is_proxy'].to_s + "\n"
31
- print 'Proxy Type: ' + record['proxy_type'] + "\n"
32
- print 'Country Code: ' + record['country_short'] + "\n"
33
- print 'Country Name: ' + record['country_long'] + "\n"
34
- print 'Region Name: ' + record['region'] + "\n"
35
- print 'City Name: ' + record['city'] + "\n"
36
- print 'ISP: ' + record['isp'] + "\n"
37
- print 'Domain: ' + record['domain'] + "\n"
38
- print 'Usage Type: ' + record['usagetype'] + "\n"
39
- print 'ASN: ' + record['asn'] + "\n"
40
- print 'AS: ' + record['as'] + "\n"
41
- print 'Last Seen: ' + record['last_seen'] + "\n"
42
- print 'Threat: ' + record['threat'] + "\n"
43
- print 'Provider: ' + record['provider'] + "\n"
44
- print 'Fraud Score: ' + record['fraud_score'] + "\n"
45
-
46
- # close IP2Proxy BIN database
1
+ require 'ip2proxy_ruby'
2
+
3
+ # open IP2Proxy BIN database for proxy lookup
4
+ i2p = Ip2proxy.new.open("./data/PX12.SAMPLE.BIN")
5
+
6
+ # get versioning information
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
+
11
+ # individual proxy data check
12
+ print 'Is Proxy: ' + i2p.is_proxy('1.2.3.4').to_s + "\n"
13
+ print 'Proxy Type: ' + i2p.get_proxytype('1.2.3.4') + "\n"
14
+ print 'Country Code: ' + i2p.get_country_short('1.2.3.4') + "\n"
15
+ print 'Country Name: ' + i2p.get_country_long('1.2.3.4') + "\n"
16
+ print 'Region Name: ' + i2p.get_region('1.2.3.4') + "\n"
17
+ print 'City Name: ' + i2p.get_city('1.2.3.4') + "\n"
18
+ print 'ISP: ' + i2p.get_isp('1.2.3.4') + "\n"
19
+ print 'Domain: ' + i2p.get_domain('1.2.3.4') + "\n"
20
+ print 'Usage Type: ' + i2p.get_usagetype('1.2.3.4') + "\n"
21
+ print 'ASN: ' + i2p.get_asn('1.2.3.4') + "\n"
22
+ print 'AS: ' + i2p.get_as('1.2.3.4') + "\n"
23
+ print 'Last Seen: ' + i2p.get_last_seen('1.2.3.4') + "\n"
24
+ print 'Threat: ' + i2p.get_threat('1.2.3.4') + "\n"
25
+ print 'Provider: ' + i2p.get_provider('1.2.3.4') + "\n"
26
+ print 'Fraud Score: ' + i2p.get_fraud_score('1.2.3.4') + "\n"
27
+
28
+ # single function to get all proxy data returned in array
29
+ record = i2p.get_all('1.2.3.4')
30
+ print 'is Proxy: ' + record['is_proxy'].to_s + "\n"
31
+ print 'Proxy Type: ' + record['proxy_type'] + "\n"
32
+ print 'Country Code: ' + record['country_short'] + "\n"
33
+ print 'Country Name: ' + record['country_long'] + "\n"
34
+ print 'Region Name: ' + record['region'] + "\n"
35
+ print 'City Name: ' + record['city'] + "\n"
36
+ print 'ISP: ' + record['isp'] + "\n"
37
+ print 'Domain: ' + record['domain'] + "\n"
38
+ print 'Usage Type: ' + record['usagetype'] + "\n"
39
+ print 'ASN: ' + record['asn'] + "\n"
40
+ print 'AS: ' + record['as'] + "\n"
41
+ print 'Last Seen: ' + record['last_seen'] + "\n"
42
+ print 'Threat: ' + record['threat'] + "\n"
43
+ print 'Provider: ' + record['provider'] + "\n"
44
+ print 'Fraud Score: ' + record['fraud_score'] + "\n"
45
+
46
+ # close IP2Proxy BIN database
47
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.4.0"
5
+ s.version = "3.5.1"
6
6
  s.authors = ["ip2location"]
7
7
  s.email = ["support@ip2location.com"]
8
8
 
@@ -37,33 +37,17 @@ Gem::Specification.new do |s|
37
37
  "rb/data/PX12.SAMPLE.BIN"
38
38
  ]
39
39
 
40
- if s.respond_to?(:metadata=)
41
- s.metadata = {
42
- "bug_tracker_uri" => "https://github.com/ip2location/ip2proxy-ruby/issues",
43
- "documentation_uri" => "https://www.rubydoc.info/gems/ip2proxy_ruby",
44
- "homepage_uri" => "https://www.ip2location.com",
45
- "source_code_uri" => "https://github.com/ip2location/ip2proxy-ruby",
46
- }
47
- end
40
+ s.metadata = {
41
+ "bug_tracker_uri" => "https://github.com/ip2location/ip2proxy-ruby/issues",
42
+ "documentation_uri" => "https://www.rubydoc.info/gems/ip2proxy_ruby",
43
+ "homepage_uri" => "https://www.ip2location.com",
44
+ "source_code_uri" => "https://github.com/ip2location/ip2proxy-ruby",
45
+ }
48
46
 
49
- if s.respond_to? :specification_version then
50
- s.specification_version = 4
47
+ s.required_ruby_version = ">= 3.0"
48
+ s.add_runtime_dependency "bindata", "~> 3.0"
49
+ s.add_development_dependency "rspec", "~> 3.13"
50
+ s.add_development_dependency "rdoc", ">= 6.3.1"
51
+ s.add_development_dependency "bundler", ">= 2.4"
51
52
 
52
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_runtime_dependency(%q<bindata>, ["~> 2.4.15"])
54
- s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
55
- s.add_development_dependency(%q<rdoc>, [">= 6.3.1"])
56
- s.add_development_dependency(%q<bundler>, [">= 1.2.0"])
57
- else
58
- s.add_dependency(%q<bindata>, ["~> 2.4.15"])
59
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
60
- s.add_dependency(%q<rdoc>, [">= 6.3.1"])
61
- s.add_dependency(%q<bundler>, [">= 1.2.0"])
62
- end
63
- else
64
- s.add_dependency(%q<bindata>, ["~> 2.4.15"])
65
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
66
- s.add_dependency(%q<rdoc>, [">= 6.3.1"])
67
- s.add_dependency(%q<bundler>, [">= 1.2.0"])
68
- end
69
53
  end
@@ -1,29 +1,29 @@
1
- class I2pDbConfig
2
- COLUMNS = {
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]
16
- }
17
-
18
- def self.setup_database(db_index)
19
- # strip all 0 value & downcase keys
20
- cols = COLUMNS.inject({}) {|memo, (key, value)|
21
- (memo[key.to_s.downcase.to_sym] = value[db_index] if value[db_index] > 0)
22
- memo
23
- }
24
- # order by value
25
- col_array = cols.sort_by {|key,value| value}
26
- end
27
-
28
- end
1
+ class I2pDbConfig
2
+ COLUMNS = {
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]
16
+ }
17
+
18
+ def self.setup_database(db_index)
19
+ # strip all 0 value & downcase keys
20
+ cols = COLUMNS.inject({}) {|memo, (key, value)|
21
+ (memo[key.to_s.downcase.to_sym] = value[db_index] if value[db_index] > 0)
22
+ memo
23
+ }
24
+ # order by value
25
+ col_array = cols.sort_by {|key,value| value}
26
+ end
27
+
28
+ end
29
29
 
@@ -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,19 @@
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
+ def read_and_return_value(io)
3
+ country_long = eval_parameter(:country_long)
4
+ raw_io = io.instance_variable_get(:@io)
5
+ initial_pos = raw_io.instance_variable_get(:@initial_pos)
6
+ if country_long
7
+ io.seek_to_abs_offset(raw_io.offset - 4)
8
+ end
9
+ addr = BinData::Uint32le.read(io)
10
+ old_offset = raw_io.offset
11
+ string_offset = country_long ? addr + 3 : addr
12
+ relative_offset = string_offset - initial_pos
13
+ io.seek_to_abs_offset(relative_offset)
14
+ length = BinData::Uint8.read(io)
15
+ result = BinData::String.new(:length => length).read(io)
16
+ io.seek_to_abs_offset(old_offset)
17
+ result
18
+ end
16
19
  end
@@ -1,20 +1,20 @@
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
- uint8 :productcode
18
- uint8 :licensecode
19
- uint32 :databasesize
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
+ uint8 :productcode
18
+ uint8 :licensecode
19
+ uint32 :databasesize
20
20
  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