ip2proxy_ruby 3.3.1 → 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: 7574dfbc7f1fd1a881fe0e05f0d041a7272fb121e9be4c307aa41c0710e92a49
4
- data.tar.gz: 5f0cdbe708bd355ed1910e8914e150b539109a49a1ee4dd2b25d556cd6d9bd69
3
+ metadata.gz: e344a1f199333b229ab18e7a461caa60ab70d6a287e44915b27007be9f854970
4
+ data.tar.gz: efdd3f09798abc2bd99a7d3a391c607e9436b71ff151c48c4836d7cbe6a7940d
5
5
  SHA512:
6
- metadata.gz: 050c2a2e9c42bb4b601dd8e31bc8119781d3709dbddef7e1d63ab2c3b07f4ee53bdf4a8f11dd461bec0b7f4382d5f0dbd58ac378216b4c0bdcc332a5ad096c91
7
- data.tar.gz: d8310cc6b583300425e6ef7e89a599858a07d13166ab9783873f42bbe2fe45fc62841fa828c6a19ef8956213043f76dc6c6c51f85ace8f02ff7568067364c738
6
+ metadata.gz: dd25f8039cd727ddfb7ea5827fd90e115e89eb240cd15d7cdf33b222d3bb0c059c26d07bbd742a54f9001edde838394eda229ce7b62004fbf8c29dea661c9deb
7
+ data.tar.gz: 7fb434d314ecdfda0762400463e372b216086e41c0139ed7ad5014452434580ecf5819e66bb0f0db854c9c2bb5a99828acd1e640f2010cac3496f57a26776452
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016 - 2024 IP2Location ( support@ip2location.com )
1
+ Copyright (c) 2016 - 2025 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/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,6 +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
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.1"
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
  }
@@ -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.1'
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.1'
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,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip2proxy_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
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: 2024-03-08 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
@@ -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.5.6
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