maxmind-geoip2 1.1.0 → 1.3.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/CHANGELOG.md +22 -0
- data/Gemfile.lock +114 -0
- data/README.dev.md +1 -1
- data/README.md +26 -6
- data/Rakefile +1 -0
- data/lib/maxmind/geoip2/client.rb +18 -9
- data/lib/maxmind/geoip2/model/anonymous_plus.rb +46 -0
- data/lib/maxmind/geoip2/model/city.rb +5 -6
- data/lib/maxmind/geoip2/model/connection_type.rb +3 -2
- data/lib/maxmind/geoip2/model/enterprise.rb +2 -3
- data/lib/maxmind/geoip2/model/insights.rb +3 -5
- data/lib/maxmind/geoip2/reader.rb +26 -1
- data/lib/maxmind/geoip2/record/location.rb +3 -3
- data/lib/maxmind/geoip2/record/traits.rb +40 -28
- data/lib/maxmind/geoip2/version.rb +8 -0
- data/maxmind-geoip2.gemspec +11 -6
- data/test/data/LICENSE-APACHE +202 -0
- data/test/data/LICENSE-MIT +17 -0
- data/test/data/MaxMind-DB-spec.md +1 -2
- data/test/data/README.md +8 -1
- data/test/data/cmd/write-test-data/main.go +68 -0
- data/test/data/go.mod +13 -0
- data/test/data/go.sum +16 -0
- data/test/data/pkg/writer/decoder.go +178 -0
- data/test/data/pkg/writer/geoip2.go +184 -0
- data/test/data/pkg/writer/ip.go +39 -0
- data/test/data/pkg/writer/maxmind.go +246 -0
- data/test/data/pkg/writer/nestedstructures.go +73 -0
- data/test/data/pkg/writer/writer.go +61 -0
- data/test/data/source-data/GeoIP-Anonymous-Plus-Test.json +175 -0
- data/test/data/source-data/GeoIP2-Anonymous-IP-Test.json +6 -0
- data/test/data/source-data/GeoIP2-City-Test.json +392 -5
- data/test/data/source-data/GeoIP2-Connection-Type-Test.json +15 -10
- data/test/data/source-data/GeoIP2-Country-Test.json +99 -25
- data/test/data/source-data/GeoIP2-Domain-Test.json +5 -0
- data/test/data/source-data/GeoIP2-Enterprise-Test.json +371 -6
- data/test/data/source-data/GeoIP2-IP-Risk-Test.json +31 -0
- data/test/data/source-data/GeoIP2-Precision-Enterprise-Sandbox-Test.json +296 -0
- data/test/data/source-data/GeoIP2-Precision-Enterprise-Test.json +1159 -175
- data/test/data/source-data/GeoIP2-Static-IP-Score-Test.json +15 -0
- data/test/data/source-data/GeoIP2-User-Count-Test.json +18 -0
- data/test/data/source-data/GeoLite2-City-Test.json +168 -3
- data/test/data/source-data/GeoLite2-Country-Test.json +92 -3
- data/test/data/test-data/GeoIP-Anonymous-Plus-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Anonymous-IP-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb +0 -0
- data/test/data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb +0 -0
- data/test/data/test-data/GeoIP2-City-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Connection-Type-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Country-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-DensityIncome-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Domain-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Enterprise-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-IP-Risk-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-ISP-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Precision-Enterprise-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-Static-IP-Score-Test.mmdb +0 -0
- data/test/data/test-data/GeoIP2-User-Count-Test.mmdb +0 -0
- data/test/data/test-data/GeoLite2-ASN-Test.mmdb +0 -0
- data/test/data/test-data/GeoLite2-City-Test.mmdb +0 -0
- data/test/data/test-data/GeoLite2-Country-Test.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-string-value-entries.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-decoder.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv4-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv4-28.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv4-32.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv6-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv6-28.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-ipv6-32.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-metadata-pointers.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-mixed-24.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-mixed-28.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-mixed-32.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-nested.mmdb +0 -0
- data/test/data/test-data/MaxMind-DB-test-pointer-decoder.mmdb +0 -0
- data/test/data/test-data/README.md +28 -12
- data/test/test_client.rb +18 -2
- data/test/test_reader.rb +42 -1
- metadata +25 -13
- data/test/data/LICENSE +0 -4
- data/test/data/perltidyrc +0 -12
- data/test/data/source-data/README +0 -15
- data/test/data/test-data/write-test-data.pl +0 -695
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d6ddb183c97df1041a902a1f2f98dec87e640b5907ae19b080bdd03c87bc03f
|
4
|
+
data.tar.gz: 8f0e58e55e605576bc4214e878c28aaab3bb6c0dbd065bb1281ac5f0db65e69e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c6d5e20fd3bef3aacde30acb0c22695c8a903626747db02b58067adcaeafd9d2673f9be8189fad8d6a53869028ff15bf9536ce66a435a2da6e86fb4126cf06b
|
7
|
+
data.tar.gz: 8c79484d19313833856f91deabceed833f2dae00fb1cd4993d57b973b1747541cf83122e07043c1b4925a2f291172195ab024988be39501a922a751c7808cde1
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.3.0 (2025-05-06)
|
4
|
+
|
5
|
+
* Support for the GeoIP Anonymous Plus database has been added. To do a
|
6
|
+
lookup in this database, use the `anonymous_plus` method on
|
7
|
+
`MaxMind::GeoIP2::Reader`.
|
8
|
+
* Ruby 3.0+ is now required. If you're using Ruby 2.5, 2.6, or 2.7, please
|
9
|
+
use version 1.2.0 of this gem.
|
10
|
+
* Deprecated `metro_code` on `MaxMind::GeoIP2::Record::Location`. The code
|
11
|
+
values are no longer being maintained.
|
12
|
+
|
13
|
+
## 1.2.0 (2023-12-04)
|
14
|
+
|
15
|
+
* `MaxMind::GeoIP2::Client` now validates the IP address before making a
|
16
|
+
request to the web service.
|
17
|
+
* `MaxMind::GeoIP2::Client` now includes the version of Ruby, the version
|
18
|
+
of the HTTP client library, and its own version in the User-Agent header.
|
19
|
+
* The `anycast?` method was added to `MaxMind::GeoIP2::Record::Traits`.
|
20
|
+
This returns `true` if the IP address belongs to an [anycast
|
21
|
+
network](https://en.wikipedia.org/wiki/Anycast). This is available for
|
22
|
+
the GeoIP2 Country, City Plus, and Insights web services and the GeoIP2
|
23
|
+
Country, City, and Enterprise databases.
|
24
|
+
|
3
25
|
## 1.1.0 (2021-11-18)
|
4
26
|
|
5
27
|
* Exceptions from this gem now inherit from `MaxMind::GeoIP2::Error`. IP
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
maxmind-geoip2 (1.3.0)
|
5
|
+
connection_pool (~> 2.2)
|
6
|
+
http (>= 4.3, < 6.0)
|
7
|
+
maxmind-db (~> 1.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.8.7)
|
13
|
+
public_suffix (>= 2.0.2, < 7.0)
|
14
|
+
ast (2.4.3)
|
15
|
+
base64 (0.2.0)
|
16
|
+
bigdecimal (3.1.9)
|
17
|
+
connection_pool (2.5.3)
|
18
|
+
crack (1.0.0)
|
19
|
+
bigdecimal
|
20
|
+
rexml
|
21
|
+
domain_name (0.6.20240107)
|
22
|
+
ffi (1.17.2)
|
23
|
+
ffi (1.17.2-aarch64-linux-gnu)
|
24
|
+
ffi (1.17.2-aarch64-linux-musl)
|
25
|
+
ffi (1.17.2-arm-linux-gnu)
|
26
|
+
ffi (1.17.2-arm-linux-musl)
|
27
|
+
ffi (1.17.2-arm64-darwin)
|
28
|
+
ffi (1.17.2-x86-linux-gnu)
|
29
|
+
ffi (1.17.2-x86-linux-musl)
|
30
|
+
ffi (1.17.2-x86_64-darwin)
|
31
|
+
ffi (1.17.2-x86_64-linux-gnu)
|
32
|
+
ffi (1.17.2-x86_64-linux-musl)
|
33
|
+
ffi-compiler (1.3.2)
|
34
|
+
ffi (>= 1.15.5)
|
35
|
+
rake
|
36
|
+
hashdiff (1.1.2)
|
37
|
+
http (5.2.0)
|
38
|
+
addressable (~> 2.8)
|
39
|
+
base64 (~> 0.1)
|
40
|
+
http-cookie (~> 1.0)
|
41
|
+
http-form_data (~> 2.2)
|
42
|
+
llhttp-ffi (~> 0.5.0)
|
43
|
+
http-cookie (1.0.8)
|
44
|
+
domain_name (~> 0.5)
|
45
|
+
http-form_data (2.3.0)
|
46
|
+
json (2.11.3)
|
47
|
+
language_server-protocol (3.17.0.4)
|
48
|
+
lint_roller (1.1.0)
|
49
|
+
llhttp-ffi (0.5.1)
|
50
|
+
ffi-compiler (~> 1.0)
|
51
|
+
rake (~> 13.0)
|
52
|
+
maxmind-db (1.3.2)
|
53
|
+
minitest (5.25.5)
|
54
|
+
parallel (1.27.0)
|
55
|
+
parser (3.3.8.0)
|
56
|
+
ast (~> 2.4.1)
|
57
|
+
racc
|
58
|
+
prism (1.4.0)
|
59
|
+
public_suffix (6.0.2)
|
60
|
+
racc (1.8.1)
|
61
|
+
rainbow (3.1.1)
|
62
|
+
rake (13.2.1)
|
63
|
+
regexp_parser (2.10.0)
|
64
|
+
rexml (3.4.1)
|
65
|
+
rubocop (1.75.5)
|
66
|
+
json (~> 2.3)
|
67
|
+
language_server-protocol (~> 3.17.0.2)
|
68
|
+
lint_roller (~> 1.1.0)
|
69
|
+
parallel (~> 1.10)
|
70
|
+
parser (>= 3.3.0.2)
|
71
|
+
rainbow (>= 2.2.2, < 4.0)
|
72
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
73
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
74
|
+
ruby-progressbar (~> 1.7)
|
75
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
76
|
+
rubocop-ast (1.44.1)
|
77
|
+
parser (>= 3.3.7.2)
|
78
|
+
prism (~> 1.4)
|
79
|
+
rubocop-performance (1.25.0)
|
80
|
+
lint_roller (~> 1.1)
|
81
|
+
rubocop (>= 1.75.0, < 2.0)
|
82
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
83
|
+
ruby-progressbar (1.13.0)
|
84
|
+
unicode-display_width (3.1.4)
|
85
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
86
|
+
unicode-emoji (4.0.4)
|
87
|
+
webmock (3.25.1)
|
88
|
+
addressable (>= 2.8.0)
|
89
|
+
crack (>= 0.3.2)
|
90
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
91
|
+
|
92
|
+
PLATFORMS
|
93
|
+
aarch64-linux-gnu
|
94
|
+
aarch64-linux-musl
|
95
|
+
arm-linux-gnu
|
96
|
+
arm-linux-musl
|
97
|
+
arm64-darwin
|
98
|
+
ruby
|
99
|
+
x86-linux-gnu
|
100
|
+
x86-linux-musl
|
101
|
+
x86_64-darwin
|
102
|
+
x86_64-linux-gnu
|
103
|
+
x86_64-linux-musl
|
104
|
+
|
105
|
+
DEPENDENCIES
|
106
|
+
maxmind-geoip2!
|
107
|
+
minitest
|
108
|
+
rake
|
109
|
+
rubocop
|
110
|
+
rubocop-performance
|
111
|
+
webmock
|
112
|
+
|
113
|
+
BUNDLED WITH
|
114
|
+
2.6.7
|
data/README.dev.md
CHANGED
data/README.md
CHANGED
@@ -133,6 +133,21 @@ record = reader.anonymous_ip('128.101.101.101')
|
|
133
133
|
puts "Anonymous" if record.is_anonymous
|
134
134
|
```
|
135
135
|
|
136
|
+
### Anonymous Plus Example
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
require 'maxmind/geoip2'
|
140
|
+
|
141
|
+
# This creates the Reader object which should be reused across lookups.
|
142
|
+
reader = MaxMind::GeoIP2::Reader.new(
|
143
|
+
database: '/usr/share/GeoIP/GeoIP-Anonymous-Plus.mmdb',
|
144
|
+
)
|
145
|
+
|
146
|
+
record = reader.anonymous_plus('128.101.101.101')
|
147
|
+
|
148
|
+
puts record.anonymizer_confidence # 30
|
149
|
+
```
|
150
|
+
|
136
151
|
### ASN Example
|
137
152
|
|
138
153
|
```ruby
|
@@ -228,14 +243,19 @@ client = MaxMind::GeoIP2::Client.new(
|
|
228
243
|
account_id: 42,
|
229
244
|
license_key: 'license_key',
|
230
245
|
|
231
|
-
# To use the GeoLite2 web service instead of GeoIP2
|
246
|
+
# To use the GeoLite2 web service instead of the GeoIP2 web service, set
|
232
247
|
# the host parameter to "geolite.info":
|
233
248
|
# host: 'geolite.info',
|
249
|
+
|
250
|
+
# To use the Sandbox GeoIP2 web service instead of the production GeoIP2
|
251
|
+
# web service, set the host parameter to "sandbox.maxmind.com":
|
252
|
+
# host: 'sandbox.maxmind.com',
|
234
253
|
)
|
235
254
|
|
236
255
|
# Replace "city" with the method corresponding to the web service that
|
237
256
|
# you are using, e.g., "country", "insights". Please note that Insights
|
238
|
-
# is only supported by GeoIP2
|
257
|
+
# is only supported by the GeoIP2 web service and not the GeoLite2 web
|
258
|
+
# service.
|
239
259
|
record = client.city('128.101.101.101')
|
240
260
|
|
241
261
|
puts record.country.iso_code # US
|
@@ -279,8 +299,8 @@ which can be populated vary between end points. In addition, while an end
|
|
279
299
|
point may offer a particular piece of data, MaxMind does not always have
|
280
300
|
every piece of data for any given IP address.
|
281
301
|
|
282
|
-
See the [GeoIP2
|
283
|
-
|
302
|
+
See the [GeoIP2 web service
|
303
|
+
documentation](https://dev.maxmind.com/geoip/docs/web-services?lang=en) for details on
|
284
304
|
what data each end point may return.
|
285
305
|
|
286
306
|
The only piece of data which is always returned is the `ip_address`
|
@@ -327,7 +347,7 @@ client API, please see [our support page](https://www.maxmind.com/en/support).
|
|
327
347
|
|
328
348
|
## Requirements
|
329
349
|
|
330
|
-
This code requires Ruby version
|
350
|
+
This code requires Ruby version 3.0 or higher.
|
331
351
|
|
332
352
|
## Contributing
|
333
353
|
|
@@ -340,7 +360,7 @@ This library uses [Semantic Versioning](https://semver.org/).
|
|
340
360
|
|
341
361
|
## Copyright and License
|
342
362
|
|
343
|
-
This software is Copyright (c) 2020-
|
363
|
+
This software is Copyright (c) 2020-2025 by MaxMind, Inc.
|
344
364
|
|
345
365
|
This is free software, licensed under the [Apache License, Version
|
346
366
|
2.0](LICENSE-APACHE) or the [MIT License](LICENSE-MIT), at your option.
|
data/Rakefile
CHANGED
@@ -4,15 +4,17 @@ require 'connection_pool'
|
|
4
4
|
require 'http'
|
5
5
|
require 'json'
|
6
6
|
require 'maxmind/geoip2/errors'
|
7
|
+
require 'maxmind/geoip2/version'
|
7
8
|
require 'maxmind/geoip2/model/city'
|
8
9
|
require 'maxmind/geoip2/model/country'
|
9
10
|
require 'maxmind/geoip2/model/insights'
|
11
|
+
require 'resolv'
|
10
12
|
|
11
13
|
module MaxMind
|
12
14
|
module GeoIP2
|
13
15
|
# This class provides a client API for all the
|
14
|
-
# {https://dev.maxmind.com/geoip/docs/web-services?lang=en GeoIP2
|
15
|
-
# services}. The services are Country, City, and Insights. Each service
|
16
|
+
# {https://dev.maxmind.com/geoip/docs/web-services?lang=en GeoIP2 web
|
17
|
+
# services}. The services are Country, City Plus, and Insights. Each service
|
16
18
|
# returns a different set of data about an IP address, with Country returning
|
17
19
|
# the least data and Insights the most.
|
18
20
|
#
|
@@ -58,7 +60,7 @@ module MaxMind
|
|
58
60
|
# rubocop:disable Metrics/CyclomaticComplexity
|
59
61
|
# rubocop:disable Metrics/PerceivedComplexity
|
60
62
|
|
61
|
-
# Create a Client that may be used to query a GeoIP2
|
63
|
+
# Create a Client that may be used to query a GeoIP2 web service.
|
62
64
|
#
|
63
65
|
# Once created, the Client is safe to use for lookups from multiple
|
64
66
|
# threads.
|
@@ -71,8 +73,10 @@ module MaxMind
|
|
71
73
|
# property from most preferred to least preferred.
|
72
74
|
#
|
73
75
|
# @param host [String] the host to use when querying the web service. Set
|
74
|
-
# this to "geolite.info" to use the GeoLite2 web service instead of
|
75
|
-
# GeoIP2
|
76
|
+
# this to "geolite.info" to use the GeoLite2 web service instead of the
|
77
|
+
# GeoIP2 web service. Set this to "sandbox.maxmind.com" to use the
|
78
|
+
# Sandbox environment. The sandbox allows you to experiment with the
|
79
|
+
# API without affecting your production data.
|
76
80
|
#
|
77
81
|
# @param timeout [Integer] the number of seconds to wait for a request
|
78
82
|
# before timing out. If 0, no timeout is set.
|
@@ -117,7 +121,7 @@ module MaxMind
|
|
117
121
|
# rubocop:enable Metrics/CyclomaticComplexity
|
118
122
|
# rubocop:enable Metrics/ParameterLists
|
119
123
|
|
120
|
-
# This method calls the City web service.
|
124
|
+
# This method calls the City Plus web service.
|
121
125
|
#
|
122
126
|
# @param ip_address [String] IPv4 or IPv6 address as a string. If no
|
123
127
|
# address is provided, the address that the web service is called from is
|
@@ -193,8 +197,8 @@ module MaxMind
|
|
193
197
|
|
194
198
|
# This method calls the Insights web service.
|
195
199
|
#
|
196
|
-
# Insights is only supported by the GeoIP2
|
197
|
-
#
|
200
|
+
# Insights is only supported by the GeoIP2 web service. The GeoLite2 web
|
201
|
+
# service does not support it.
|
198
202
|
#
|
199
203
|
# @param ip_address [String] IPv4 or IPv6 address as a string. If no
|
200
204
|
# address is provided, the address that the web service is called from is
|
@@ -234,6 +238,10 @@ module MaxMind
|
|
234
238
|
private
|
235
239
|
|
236
240
|
def response_for(endpoint, model_class, ip_address)
|
241
|
+
if ip_address != 'me' && ip_address !~ Resolv::AddressRegex
|
242
|
+
raise AddressInvalidError, "The value \"#{ip_address}\" is not a valid IP address"
|
243
|
+
end
|
244
|
+
|
237
245
|
record = get(endpoint, ip_address)
|
238
246
|
|
239
247
|
model_class.new(record, @locales)
|
@@ -243,8 +251,9 @@ module MaxMind
|
|
243
251
|
headers = HTTP.basic_auth(user: @account_id, pass: @license_key)
|
244
252
|
.headers(
|
245
253
|
accept: 'application/json',
|
246
|
-
user_agent:
|
254
|
+
user_agent: "MaxMind-GeoIP2-ruby/#{VERSION} ruby/#{RUBY_VERSION} http/#{HTTP::VERSION}"
|
247
255
|
)
|
256
|
+
|
248
257
|
timeout = @timeout > 0 ? headers.timeout(@timeout) : headers
|
249
258
|
|
250
259
|
proxy = timeout
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'maxmind/geoip2/model/anonymous_ip'
|
5
|
+
|
6
|
+
module MaxMind
|
7
|
+
module GeoIP2
|
8
|
+
module Model
|
9
|
+
# Model class for the Anonymous Plus database.
|
10
|
+
class AnonymousPlus < AnonymousIP
|
11
|
+
# A score ranging from 1 to 99 that is our percent confidence that the
|
12
|
+
# network is currently part of an actively used VPN service.
|
13
|
+
#
|
14
|
+
# @return [Integer, nil]
|
15
|
+
def anonymizer_confidence
|
16
|
+
get('anonymizer_confidence')
|
17
|
+
end
|
18
|
+
|
19
|
+
# The last day that the network was sighted in our analysis of
|
20
|
+
# anonymized networks. This value is parsed lazily.
|
21
|
+
#
|
22
|
+
# @return [Date, nil] A Date object representing the last seen date,
|
23
|
+
# or nil if the date is not available.
|
24
|
+
def network_last_seen
|
25
|
+
return @network_last_seen if defined?(@network_last_seen)
|
26
|
+
|
27
|
+
date_string = get('network_last_seen')
|
28
|
+
|
29
|
+
if !date_string
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
|
33
|
+
@network_last_seen = Date.parse(date_string)
|
34
|
+
end
|
35
|
+
|
36
|
+
# The name of the VPN provider (e.g., NordVPN, SurfShark, etc.)
|
37
|
+
# associated with the network.
|
38
|
+
#
|
39
|
+
# @return [String, nil]
|
40
|
+
def provider_name
|
41
|
+
get('provider_name')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -9,12 +9,11 @@ require 'maxmind/geoip2/record/subdivision'
|
|
9
9
|
module MaxMind
|
10
10
|
module GeoIP2
|
11
11
|
module Model
|
12
|
-
# Model class for the data returned by the GeoIP2 City web service
|
13
|
-
# database. It is also used for GeoLite2 City lookups.
|
12
|
+
# Model class for the data returned by the GeoIP2 City Plus web service
|
13
|
+
# and the City database. It is also used for GeoLite2 City lookups.
|
14
14
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# https://dev.maxmind.com/geoip/docs/web-services?lang=en for more details.
|
15
|
+
# See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
|
16
|
+
# details.
|
18
17
|
#
|
19
18
|
# See {MaxMind::GeoIP2::Model::Country} for inherited methods.
|
20
19
|
class City < Country
|
@@ -47,7 +46,7 @@ module MaxMind
|
|
47
46
|
|
48
47
|
# @!visibility private
|
49
48
|
def initialize(record, locales)
|
50
|
-
super
|
49
|
+
super
|
51
50
|
@city = MaxMind::GeoIP2::Record::City.new(record['city'], locales)
|
52
51
|
@location = MaxMind::GeoIP2::Record::Location.new(record['location'])
|
53
52
|
@postal = MaxMind::GeoIP2::Record::Postal.new(record['postal'])
|
@@ -7,8 +7,9 @@ module MaxMind
|
|
7
7
|
module Model
|
8
8
|
# Model class for the GeoIP2 Connection Type database.
|
9
9
|
class ConnectionType < Abstract
|
10
|
-
# The connection type may take the following values: "Dialup",
|
11
|
-
# "Corporate", "Cellular". Additional
|
10
|
+
# The connection type may take the following values: "Dialup",
|
11
|
+
# "Cable/DSL", "Corporate", "Cellular", and "Satellite". Additional
|
12
|
+
# values may be added in the future.
|
12
13
|
#
|
13
14
|
# @return [String, nil]
|
14
15
|
def connection_type
|
@@ -7,9 +7,8 @@ module MaxMind
|
|
7
7
|
module Model
|
8
8
|
# Model class for the data returned by GeoIP2 Enterprise database lookups.
|
9
9
|
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# https://dev.maxmind.com/geoip/docs/web-services?lang=en for more details.
|
10
|
+
# See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
|
11
|
+
# details.
|
13
12
|
#
|
14
13
|
# See {MaxMind::GeoIP2::Model::City} for inherited methods.
|
15
14
|
class Enterprise < City
|
@@ -5,12 +5,10 @@ require 'maxmind/geoip2/model/city'
|
|
5
5
|
module MaxMind
|
6
6
|
module GeoIP2
|
7
7
|
module Model
|
8
|
-
# Model class for the data returned by the GeoIP2
|
9
|
-
# service.
|
8
|
+
# Model class for the data returned by the GeoIP2 Insights web service.
|
10
9
|
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# https://dev.maxmind.com/geoip/docs/web-services?lang=en for more details.
|
10
|
+
# See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
|
11
|
+
# details.
|
14
12
|
class Insights < City
|
15
13
|
end
|
16
14
|
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'maxmind/db'
|
4
4
|
require 'maxmind/geoip2/errors'
|
5
5
|
require 'maxmind/geoip2/model/anonymous_ip'
|
6
|
+
require 'maxmind/geoip2/model/anonymous_plus'
|
6
7
|
require 'maxmind/geoip2/model/asn'
|
7
8
|
require 'maxmind/geoip2/model/city'
|
8
9
|
require 'maxmind/geoip2/model/connection_type'
|
@@ -86,7 +87,7 @@ module MaxMind
|
|
86
87
|
# rubocop:enable Metrics/CyclomaticComplexity
|
87
88
|
# rubocop:enable Metrics/PerceivedComplexity
|
88
89
|
|
89
|
-
# Look up the IP address in the database.
|
90
|
+
# Look up the IP address in the Anonymous IP database.
|
90
91
|
#
|
91
92
|
# @param ip_address [String] a string in the standard notation. It may be
|
92
93
|
# IPv4 or IPv6.
|
@@ -110,6 +111,30 @@ module MaxMind
|
|
110
111
|
)
|
111
112
|
end
|
112
113
|
|
114
|
+
# Look up the IP address in the Anonymous Plus database.
|
115
|
+
#
|
116
|
+
# @param ip_address [String] a string in the standard notation. It may be
|
117
|
+
# IPv4 or IPv6.
|
118
|
+
#
|
119
|
+
# @return [MaxMind::GeoIP2::Model::AnonymousPlus]
|
120
|
+
#
|
121
|
+
# @raise [ArgumentError] if used against a non-Anonymous Plus database
|
122
|
+
# or if you attempt to look up an IPv6 address in an IPv4 only database.
|
123
|
+
#
|
124
|
+
# @raise [AddressNotFoundError] if the IP address is not found in the
|
125
|
+
# database.
|
126
|
+
#
|
127
|
+
# @raise [MaxMind::DB::InvalidDatabaseError] if the database appears
|
128
|
+
# corrupt.
|
129
|
+
def anonymous_plus(ip_address)
|
130
|
+
flat_model_for(
|
131
|
+
Model::AnonymousPlus,
|
132
|
+
'anonymous_plus',
|
133
|
+
'GeoIP-Anonymous-Plus',
|
134
|
+
ip_address,
|
135
|
+
)
|
136
|
+
end
|
137
|
+
|
113
138
|
# Look up the IP address in an ASN database.
|
114
139
|
#
|
115
140
|
# @param ip_address [String] a string in the standard notation. It may be
|
@@ -46,11 +46,11 @@ module MaxMind
|
|
46
46
|
get('longitude')
|
47
47
|
end
|
48
48
|
|
49
|
-
# The metro code
|
50
|
-
#
|
51
|
-
# https://developers.google.com/adwords/api/docs/appendix/cities-DMAregions.
|
49
|
+
# The metro code is a no-longer-maintained code for targeting
|
50
|
+
# advertisements in Google.
|
52
51
|
#
|
53
52
|
# @return [Integer, nil]
|
53
|
+
# @deprecated Code values are no longer maintained.
|
54
54
|
def metro_code
|
55
55
|
get('metro_code')
|
56
56
|
end
|