maxmind-geoip2 1.2.0 → 1.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 +4 -4
- data/CHANGELOG.md +29 -0
- data/CLAUDE.md +390 -0
- data/Gemfile.lock +126 -0
- data/README.dev.md +1 -1
- data/README.md +17 -2
- data/Rakefile +2 -2
- data/lib/maxmind/geoip2/model/anonymous_plus.rb +46 -0
- data/lib/maxmind/geoip2/model/city.rb +1 -1
- data/lib/maxmind/geoip2/model/insights.rb +14 -0
- data/lib/maxmind/geoip2/reader.rb +26 -1
- data/lib/maxmind/geoip2/record/anonymizer.rb +105 -0
- data/lib/maxmind/geoip2/record/location.rb +3 -3
- data/lib/maxmind/geoip2/record/traits.rb +38 -1
- data/lib/maxmind/geoip2/version.rb +1 -1
- data/maxmind-geoip2.gemspec +8 -5
- 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/go.mod +1 -1
- data/test/data/pkg/writer/geoip2.go +7 -5
- data/test/data/pkg/writer/maxmind.go +2 -1
- data/test/data/pkg/writer/writer.go +4 -1
- 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 +73 -7
- data/test/data/source-data/GeoIP2-Country-Test.json +3 -28
- data/test/data/source-data/GeoIP2-Enterprise-Test.json +27 -8
- data/test/data/source-data/GeoIP2-IP-Risk-Test.json +31 -0
- data/test/data/source-data/GeoIP2-Precision-Enterprise-Test.json +585 -11
- data/test/data/source-data/GeoLite2-City-Test.json +0 -3
- data/test/data/source-data/GeoLite2-Country-Test.json +0 -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.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-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/test_client.rb +31 -6
- data/test/test_model_country.rb +13 -14
- data/test/test_model_names.rb +3 -0
- data/test/test_reader.rb +60 -23
- metadata +58 -11
- data/test/data/LICENSE +0 -4
- data/test/data/perltidyrc +0 -18
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'maxmind/geoip2/model/city'
|
|
4
|
+
require 'maxmind/geoip2/record/anonymizer'
|
|
4
5
|
|
|
5
6
|
module MaxMind
|
|
6
7
|
module GeoIP2
|
|
@@ -10,6 +11,19 @@ module MaxMind
|
|
|
10
11
|
# See https://dev.maxmind.com/geoip/docs/web-services?lang=en for more
|
|
11
12
|
# details.
|
|
12
13
|
class Insights < City
|
|
14
|
+
# Data indicating whether the IP address is part of an anonymizing
|
|
15
|
+
# network.
|
|
16
|
+
#
|
|
17
|
+
# @return [MaxMind::GeoIP2::Record::Anonymizer]
|
|
18
|
+
attr_reader :anonymizer
|
|
19
|
+
|
|
20
|
+
# @!visibility private
|
|
21
|
+
def initialize(record, locales)
|
|
22
|
+
super
|
|
23
|
+
@anonymizer = MaxMind::GeoIP2::Record::Anonymizer.new(
|
|
24
|
+
record['anonymizer'],
|
|
25
|
+
)
|
|
26
|
+
end
|
|
13
27
|
end
|
|
14
28
|
end
|
|
15
29
|
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
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'date'
|
|
4
|
+
require 'maxmind/geoip2/record/abstract'
|
|
5
|
+
|
|
6
|
+
module MaxMind
|
|
7
|
+
module GeoIP2
|
|
8
|
+
module Record
|
|
9
|
+
# Contains data indicating whether an IP address is part of an
|
|
10
|
+
# anonymizing network.
|
|
11
|
+
#
|
|
12
|
+
# This record is returned by the Insights web service.
|
|
13
|
+
class Anonymizer < Abstract
|
|
14
|
+
# A score ranging from 1 to 99 that represents our percent confidence
|
|
15
|
+
# that the network is currently part of an actively used VPN service.
|
|
16
|
+
# This property is only available from Insights.
|
|
17
|
+
#
|
|
18
|
+
# @return [Integer, nil]
|
|
19
|
+
def confidence
|
|
20
|
+
get('confidence')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# This is true if the IP address belongs to any sort of anonymous
|
|
24
|
+
# network. This property is only available from Insights.
|
|
25
|
+
#
|
|
26
|
+
# @return [Boolean]
|
|
27
|
+
def anonymous?
|
|
28
|
+
get('is_anonymous')
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# This is true if the IP address is registered to an anonymous VPN
|
|
32
|
+
# provider. If a VPN provider does not register subnets under names
|
|
33
|
+
# associated with them, we will likely only flag their IP ranges using
|
|
34
|
+
# the hosting_provider? property. This property is only available from
|
|
35
|
+
# Insights.
|
|
36
|
+
#
|
|
37
|
+
# @return [Boolean]
|
|
38
|
+
def anonymous_vpn?
|
|
39
|
+
get('is_anonymous_vpn')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# This is true if the IP address belongs to a hosting or VPN provider
|
|
43
|
+
# (see description of the anonymous_vpn? property). This property is
|
|
44
|
+
# only available from Insights.
|
|
45
|
+
#
|
|
46
|
+
# @return [Boolean]
|
|
47
|
+
def hosting_provider?
|
|
48
|
+
get('is_hosting_provider')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# This is true if the IP address belongs to a public proxy. This
|
|
52
|
+
# property is only available from Insights.
|
|
53
|
+
#
|
|
54
|
+
# @return [Boolean]
|
|
55
|
+
def public_proxy?
|
|
56
|
+
get('is_public_proxy')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# This is true if the IP address is on a suspected anonymizing network
|
|
60
|
+
# and belongs to a residential ISP. This property is only available from
|
|
61
|
+
# Insights.
|
|
62
|
+
#
|
|
63
|
+
# @return [Boolean]
|
|
64
|
+
def residential_proxy?
|
|
65
|
+
get('is_residential_proxy')
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# This is true if the IP address is a Tor exit node. This property is
|
|
69
|
+
# only available from Insights.
|
|
70
|
+
#
|
|
71
|
+
# @return [Boolean]
|
|
72
|
+
def tor_exit_node?
|
|
73
|
+
get('is_tor_exit_node')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# The last day that the network was sighted in our analysis of
|
|
77
|
+
# anonymized networks. This value is parsed lazily. This property is
|
|
78
|
+
# only available from Insights.
|
|
79
|
+
#
|
|
80
|
+
# @return [Date, nil] A Date object representing the last seen date,
|
|
81
|
+
# or nil if the date is not available.
|
|
82
|
+
def network_last_seen
|
|
83
|
+
return @network_last_seen if defined?(@network_last_seen)
|
|
84
|
+
|
|
85
|
+
date_string = get('network_last_seen')
|
|
86
|
+
|
|
87
|
+
if !date_string
|
|
88
|
+
return nil
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
@network_last_seen = Date.parse(date_string)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# The name of the VPN provider (e.g., NordVPN, SurfShark, etc.)
|
|
95
|
+
# associated with the network. This property is only available from
|
|
96
|
+
# Insights.
|
|
97
|
+
#
|
|
98
|
+
# @return [String, nil]
|
|
99
|
+
def provider_name
|
|
100
|
+
get('provider_name')
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -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
|
|
@@ -12,7 +12,7 @@ module MaxMind
|
|
|
12
12
|
class Traits < Abstract
|
|
13
13
|
# @!visibility private
|
|
14
14
|
def initialize(record)
|
|
15
|
-
super
|
|
15
|
+
super
|
|
16
16
|
if record && !record.key?('network') && record.key?('ip_address') &&
|
|
17
17
|
record.key?('prefix_length')
|
|
18
18
|
ip = IPAddr.new(record['ip_address']).mask(record['prefix_length'])
|
|
@@ -76,7 +76,11 @@ module MaxMind
|
|
|
76
76
|
# This is true if the IP address belongs to any sort of anonymous network.
|
|
77
77
|
# This property is only available from Insights.
|
|
78
78
|
#
|
|
79
|
+
# This method is deprecated as of version 1.4.0. Use the anonymizer object
|
|
80
|
+
# from the Insights response instead.
|
|
81
|
+
#
|
|
79
82
|
# @return [Boolean]
|
|
83
|
+
# @deprecated since 1.4.0
|
|
80
84
|
def anonymous?
|
|
81
85
|
get('is_anonymous')
|
|
82
86
|
end
|
|
@@ -86,7 +90,11 @@ module MaxMind
|
|
|
86
90
|
# associated with them, we will likely only flag their IP ranges using the
|
|
87
91
|
# hosting_provider? property. This property is only available from Insights.
|
|
88
92
|
#
|
|
93
|
+
# This method is deprecated as of version 1.4.0. Use the anonymizer object
|
|
94
|
+
# from the Insights response instead.
|
|
95
|
+
#
|
|
89
96
|
# @return [Boolean]
|
|
97
|
+
# @deprecated since 1.4.0
|
|
90
98
|
def anonymous_vpn?
|
|
91
99
|
get('is_anonymous_vpn')
|
|
92
100
|
end
|
|
@@ -107,7 +115,11 @@ module MaxMind
|
|
|
107
115
|
# description of the anonymous_vpn? property). This property is only
|
|
108
116
|
# available from Insights.
|
|
109
117
|
#
|
|
118
|
+
# This method is deprecated as of version 1.4.0. Use the anonymizer object
|
|
119
|
+
# from the Insights response instead.
|
|
120
|
+
#
|
|
110
121
|
# @return [Boolean]
|
|
122
|
+
# @deprecated since 1.4.0
|
|
111
123
|
def hosting_provider?
|
|
112
124
|
get('is_hosting_provider')
|
|
113
125
|
end
|
|
@@ -146,7 +158,11 @@ module MaxMind
|
|
|
146
158
|
# This is true if the IP address belongs to a public proxy. This property
|
|
147
159
|
# is only available from Insights.
|
|
148
160
|
#
|
|
161
|
+
# This method is deprecated as of version 1.4.0. Use the anonymizer object
|
|
162
|
+
# from the Insights response instead.
|
|
163
|
+
#
|
|
149
164
|
# @return [Boolean]
|
|
165
|
+
# @deprecated since 1.4.0
|
|
150
166
|
def public_proxy?
|
|
151
167
|
get('is_public_proxy')
|
|
152
168
|
end
|
|
@@ -155,7 +171,11 @@ module MaxMind
|
|
|
155
171
|
# and belongs to a residential ISP. This property is only available
|
|
156
172
|
# from Insights.
|
|
157
173
|
#
|
|
174
|
+
# This method is deprecated as of version 1.4.0. Use the anonymizer object
|
|
175
|
+
# from the Insights response instead.
|
|
176
|
+
#
|
|
158
177
|
# @return [Boolean]
|
|
178
|
+
# @deprecated since 1.4.0
|
|
159
179
|
def residential_proxy?
|
|
160
180
|
get('is_residential_proxy')
|
|
161
181
|
end
|
|
@@ -163,7 +183,11 @@ module MaxMind
|
|
|
163
183
|
# This is true if the IP address is a Tor exit node. This property is only
|
|
164
184
|
# available from Insights.
|
|
165
185
|
#
|
|
186
|
+
# This method is deprecated as of version 1.4.0. Use the anonymizer object
|
|
187
|
+
# from the Insights response instead.
|
|
188
|
+
#
|
|
166
189
|
# @return [Boolean]
|
|
190
|
+
# @deprecated since 1.4.0
|
|
167
191
|
def tor_exit_node?
|
|
168
192
|
get('is_tor_exit_node')
|
|
169
193
|
end
|
|
@@ -212,6 +236,19 @@ module MaxMind
|
|
|
212
236
|
get('user_count')
|
|
213
237
|
end
|
|
214
238
|
|
|
239
|
+
# This field contains the risk associated with the IP address. The value
|
|
240
|
+
# ranges from 0.01 to 99. A higher score indicates a higher risk.
|
|
241
|
+
# Please note that the IP risk score provided in GeoIP products and
|
|
242
|
+
# services is more static than the IP risk score provided in minFraud
|
|
243
|
+
# and is not responsive to traffic on your network. If you need realtime
|
|
244
|
+
# IP risk scoring based on behavioral signals on your own network, please
|
|
245
|
+
# use minFraud. This property is only available from Insights.
|
|
246
|
+
#
|
|
247
|
+
# @return [Float, nil]
|
|
248
|
+
def ip_risk_snapshot
|
|
249
|
+
get('ip_risk_snapshot')
|
|
250
|
+
end
|
|
251
|
+
|
|
215
252
|
# The user type associated with the IP address. This can be one of the
|
|
216
253
|
# following values:
|
|
217
254
|
#
|
data/maxmind-geoip2.gemspec
CHANGED
|
@@ -7,7 +7,7 @@ require 'maxmind/geoip2/version'
|
|
|
7
7
|
|
|
8
8
|
Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ['William Storey']
|
|
10
|
-
s.files = Dir['**/*']
|
|
10
|
+
s.files = Dir['**/*'].difference(Dir['.github/**/*', 'dev-bin/**/*'])
|
|
11
11
|
s.name = 'maxmind-geoip2'
|
|
12
12
|
s.summary = 'A gem for interacting with the GeoIP2 webservices and databases.'
|
|
13
13
|
s.version = MaxMind::GeoIP2::VERSION
|
|
@@ -24,15 +24,18 @@ Gem::Specification.new do |s|
|
|
|
24
24
|
'rubygems_mfa_required' => 'true',
|
|
25
25
|
'source_code_uri' => 'https://github.com/maxmind/GeoIP2-ruby',
|
|
26
26
|
}
|
|
27
|
-
s.required_ruby_version = '>= 2
|
|
27
|
+
s.required_ruby_version = '>= 3.2'
|
|
28
28
|
|
|
29
|
-
s.
|
|
30
|
-
s.
|
|
31
|
-
s.
|
|
29
|
+
s.add_dependency 'connection_pool', ['~> 2.2']
|
|
30
|
+
s.add_dependency 'http', '>= 4.3', '< 6.0'
|
|
31
|
+
s.add_dependency 'maxmind-db', ['~> 1.4']
|
|
32
32
|
|
|
33
33
|
s.add_development_dependency 'minitest'
|
|
34
34
|
s.add_development_dependency 'rake'
|
|
35
35
|
s.add_development_dependency 'rubocop'
|
|
36
|
+
s.add_development_dependency 'rubocop-minitest'
|
|
36
37
|
s.add_development_dependency 'rubocop-performance'
|
|
38
|
+
s.add_development_dependency 'rubocop-rake'
|
|
39
|
+
s.add_development_dependency 'rubocop-thread_safety'
|
|
37
40
|
s.add_development_dependency 'webmock'
|
|
38
41
|
end
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
https://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
2
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
3
|
+
the Software without restriction, including without limitation the rights to
|
|
4
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
5
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
6
|
+
so, subject to the following conditions:
|
|
7
|
+
|
|
8
|
+
The above copyright notice and this permission notice shall be included in all
|
|
9
|
+
copies or substantial portions of the Software.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
12
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
13
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
14
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
15
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
17
|
+
SOFTWARE.
|
|
@@ -544,14 +544,13 @@ data section size for the database is limited to 4GB.
|
|
|
544
544
|
|
|
545
545
|
### Writer
|
|
546
546
|
|
|
547
|
-
* [
|
|
547
|
+
* [Go](https://github.com/maxmind/mmdbwriter)
|
|
548
548
|
|
|
549
549
|
### Reader
|
|
550
550
|
|
|
551
551
|
* [C](https://github.com/maxmind/libmaxminddb)
|
|
552
552
|
* [C#](https://github.com/maxmind/MaxMind-DB-Reader-dotnet)
|
|
553
553
|
* [Java](https://github.com/maxmind/MaxMind-DB-Reader-java)
|
|
554
|
-
* [Perl](https://github.com/maxmind/MaxMind-DB-Reader-perl)
|
|
555
554
|
* [PHP](https://github.com/maxmind/MaxMind-DB-Reader-php)
|
|
556
555
|
* [Python](https://github.com/maxmind/MaxMind-DB-Reader-python)
|
|
557
556
|
* [Ruby](https://github.com/maxmind/MaxMind-DB-Reader-ruby)
|
data/test/data/README.md
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
MaxMind DB is a binary file format that stores data indexed by IP address
|
|
2
2
|
subnets (IPv4 or IPv6).
|
|
3
3
|
|
|
4
|
-
This repository contains the spec for that format.
|
|
4
|
+
This repository contains the spec for that format as well as test databases.
|
|
5
|
+
|
|
6
|
+
# Copyright and License
|
|
7
|
+
|
|
8
|
+
This software is Copyright (c) 2013 - 2025 by MaxMind, Inc.
|
|
9
|
+
|
|
10
|
+
This is free software, licensed under the [Apache License, Version
|
|
11
|
+
2.0](LICENSE-APACHE) or the [MIT License](LICENSE-MIT), at your option.
|
data/test/data/go.mod
CHANGED
|
@@ -16,6 +16,7 @@ import (
|
|
|
16
16
|
// WriteGeoIP2TestDB writes GeoIP2 test mmdb files.
|
|
17
17
|
func (w *Writer) WriteGeoIP2TestDB() error {
|
|
18
18
|
dbTypes := []string{
|
|
19
|
+
"GeoIP-Anonymous-Plus",
|
|
19
20
|
"GeoIP2-Anonymous-IP",
|
|
20
21
|
"GeoIP2-City",
|
|
21
22
|
"GeoIP2-Connection-Type",
|
|
@@ -23,6 +24,7 @@ func (w *Writer) WriteGeoIP2TestDB() error {
|
|
|
23
24
|
"GeoIP2-DensityIncome",
|
|
24
25
|
"GeoIP2-Domain",
|
|
25
26
|
"GeoIP2-Enterprise",
|
|
27
|
+
"GeoIP2-IP-Risk",
|
|
26
28
|
"GeoIP2-ISP",
|
|
27
29
|
"GeoIP2-Precision-Enterprise",
|
|
28
30
|
"GeoIP2-Static-IP-Score",
|
|
@@ -58,18 +60,18 @@ func (w *Writer) WriteGeoIP2TestDB() error {
|
|
|
58
60
|
return fmt.Errorf("creating mmdbwriter: %w", err)
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
if dbType == "GeoIP2-Anonymous-IP" {
|
|
63
|
+
if dbType == "GeoIP2-Anonymous-IP" || dbType == "GeoIP-Anonymous-Plus" {
|
|
62
64
|
if err := populateAllNetworks(dbWriter); err != nil {
|
|
63
65
|
return fmt.Errorf("inserting all networks: %w", err)
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
jsonFileName :=
|
|
69
|
+
jsonFileName := dbType + "-Test.json"
|
|
68
70
|
if err := w.insertJSON(dbWriter, jsonFileName); err != nil {
|
|
69
71
|
return fmt.Errorf("inserting json: %w", err)
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
dbFileName :=
|
|
74
|
+
dbFileName := dbType + "-Test.mmdb"
|
|
73
75
|
if err := w.write(dbWriter, dbFileName); err != nil {
|
|
74
76
|
return fmt.Errorf("writing database: %w", err)
|
|
75
77
|
}
|
|
@@ -146,7 +148,7 @@ func toMMDBType(key string, value any) (mmdbtype.DataType, error) {
|
|
|
146
148
|
return s, nil
|
|
147
149
|
case float64:
|
|
148
150
|
switch key {
|
|
149
|
-
case "accuracy_radius", "confidence", "metro_code":
|
|
151
|
+
case "accuracy_radius", "anonymizer_confidence", "confidence", "metro_code":
|
|
150
152
|
return mmdbtype.Uint16(v), nil
|
|
151
153
|
case "autonomous_system_number", "average_income",
|
|
152
154
|
"geoname_id", "ipv4_24", "ipv4_32", "ipv6_32",
|
|
@@ -156,7 +158,7 @@ func toMMDBType(key string, value any) (mmdbtype.DataType, error) {
|
|
|
156
158
|
"static_ip_score":
|
|
157
159
|
return mmdbtype.Float64(v), nil
|
|
158
160
|
default:
|
|
159
|
-
return nil, fmt.Errorf("unsupported
|
|
161
|
+
return nil, fmt.Errorf("unsupported numeric type for key %q: %T", key, value)
|
|
160
162
|
}
|
|
161
163
|
default:
|
|
162
164
|
return nil, fmt.Errorf("unsupported type for key %q: %T", key, value)
|
|
@@ -53,7 +53,8 @@ func (w *Writer) WriteIPv6TestDB() error {
|
|
|
53
53
|
return nil
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
// WriteMixedIPTestDB writes mmdb files for a mixed ip version range between ::1:ffff:ffff and
|
|
56
|
+
// WriteMixedIPTestDB writes mmdb files for a mixed ip version range between ::1:ffff:ffff and
|
|
57
|
+
// ::2:0000:0059
|
|
57
58
|
// with various record sizes.
|
|
58
59
|
func (w *Writer) WriteMixedIPTestDB() error {
|
|
59
60
|
ipv6Range, err := parseIPRange("::1:ffff:ffff", "::2:0000:0059")
|