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
@@ -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'])
|
@@ -22,8 +22,8 @@ module MaxMind
|
|
22
22
|
|
23
23
|
# The autonomous system number associated with the IP address. See
|
24
24
|
# Wikipedia[https://en.wikipedia.org/wiki/Autonomous_system_(Internet)].
|
25
|
-
# This attribute is only available from the City and Insights web
|
26
|
-
# and the
|
25
|
+
# This attribute is only available from the City Plus and Insights web
|
26
|
+
# services and the Enterprise database.
|
27
27
|
#
|
28
28
|
# @return [Integer, nil]
|
29
29
|
def autonomous_system_number
|
@@ -33,8 +33,8 @@ module MaxMind
|
|
33
33
|
# The organization associated with the registered autonomous system number
|
34
34
|
# for the IP address. See
|
35
35
|
# Wikipedia[https://en.wikipedia.org/wiki/Autonomous_system_(Internet)].
|
36
|
-
# This attribute is only available from the City and Insights web
|
37
|
-
# and the
|
36
|
+
# This attribute is only available from the City Plus and Insights web
|
37
|
+
# services and the Enterprise database.
|
38
38
|
#
|
39
39
|
# @return [String, nil]
|
40
40
|
def autonomous_system_organization
|
@@ -42,8 +42,9 @@ module MaxMind
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# The connection type may take the following values: "Dialup",
|
45
|
-
# "Cable/DSL", "Corporate", "Cellular". Additional
|
46
|
-
# the future. This attribute is only available
|
45
|
+
# "Cable/DSL", "Corporate", "Cellular", and "Satellite". Additional
|
46
|
+
# values may be added in the future. This attribute is only available
|
47
|
+
# from the City Plus and Insights web services and the Enterprise
|
47
48
|
# database.
|
48
49
|
#
|
49
50
|
# @return [String, nil]
|
@@ -53,8 +54,8 @@ module MaxMind
|
|
53
54
|
|
54
55
|
# The second level domain associated with the IP address. This will be
|
55
56
|
# something like "example.com" or "example.co.uk", not "foo.example.com".
|
56
|
-
# This attribute is only available from the City and Insights web
|
57
|
-
# and the
|
57
|
+
# This attribute is only available from the City Plus and Insights web
|
58
|
+
# services and the Enterprise database.
|
58
59
|
#
|
59
60
|
# @return [String, nil]
|
60
61
|
def domain
|
@@ -73,7 +74,7 @@ module MaxMind
|
|
73
74
|
end
|
74
75
|
|
75
76
|
# This is true if the IP address belongs to any sort of anonymous network.
|
76
|
-
# This property is only available from
|
77
|
+
# This property is only available from Insights.
|
77
78
|
#
|
78
79
|
# @return [Boolean]
|
79
80
|
def anonymous?
|
@@ -83,17 +84,28 @@ module MaxMind
|
|
83
84
|
# This is true if the IP address is registered to an anonymous VPN
|
84
85
|
# provider. If a VPN provider does not register subnets under names
|
85
86
|
# associated with them, we will likely only flag their IP ranges using the
|
86
|
-
# hosting_provider? property. This property is only available from
|
87
|
-
# Precision Insights.
|
87
|
+
# hosting_provider? property. This property is only available from Insights.
|
88
88
|
#
|
89
89
|
# @return [Boolean]
|
90
90
|
def anonymous_vpn?
|
91
91
|
get('is_anonymous_vpn')
|
92
92
|
end
|
93
93
|
|
94
|
+
# This is true if the IP address belongs to an
|
95
|
+
# {https://en.wikipedia.org/wiki/Anycast anycast network}.
|
96
|
+
#
|
97
|
+
# This property is only available from the Country, City Plus, and
|
98
|
+
# Insights web services and the GeoIP2 Country, City, and Enterprise
|
99
|
+
# databases.
|
100
|
+
#
|
101
|
+
# @return [Boolean]
|
102
|
+
def anycast?
|
103
|
+
get('is_anycast')
|
104
|
+
end
|
105
|
+
|
94
106
|
# This is true if the IP address belongs to a hosting or VPN provider (see
|
95
107
|
# description of the anonymous_vpn? property). This property is only
|
96
|
-
# available from
|
108
|
+
# available from Insights.
|
97
109
|
#
|
98
110
|
# @return [Boolean]
|
99
111
|
def hosting_provider?
|
@@ -102,7 +114,7 @@ module MaxMind
|
|
102
114
|
|
103
115
|
# This attribute is true if MaxMind believes this IP address to be a
|
104
116
|
# legitimate proxy, such as an internal VPN used by a corporation. This
|
105
|
-
# attribute is only available in the
|
117
|
+
# attribute is only available in the Enterprise database.
|
106
118
|
#
|
107
119
|
# @return [Boolean]
|
108
120
|
def legitimate_proxy?
|
@@ -112,8 +124,8 @@ module MaxMind
|
|
112
124
|
# The {https://en.wikipedia.org/wiki/Mobile_country_code mobile country
|
113
125
|
# code (MCC)} associated with the IP address and ISP.
|
114
126
|
#
|
115
|
-
# This attribute is only available from the City and Insights web
|
116
|
-
# and the
|
127
|
+
# This attribute is only available from the City Plus and Insights web
|
128
|
+
# services and the Enterprise database.
|
117
129
|
#
|
118
130
|
# @return [String, nil]
|
119
131
|
def mobile_country_code
|
@@ -123,8 +135,8 @@ module MaxMind
|
|
123
135
|
# The {https://en.wikipedia.org/wiki/Mobile_country_code mobile network
|
124
136
|
# code (MNC)} associated with the IP address and ISP.
|
125
137
|
#
|
126
|
-
# This attribute is only available from the City and Insights web
|
127
|
-
# and the
|
138
|
+
# This attribute is only available from the City Plus and Insights web
|
139
|
+
# services and the Enterprise database.
|
128
140
|
#
|
129
141
|
# @return [String, nil]
|
130
142
|
def mobile_network_code
|
@@ -132,7 +144,7 @@ module MaxMind
|
|
132
144
|
end
|
133
145
|
|
134
146
|
# This is true if the IP address belongs to a public proxy. This property
|
135
|
-
# is only available from
|
147
|
+
# is only available from Insights.
|
136
148
|
#
|
137
149
|
# @return [Boolean]
|
138
150
|
def public_proxy?
|
@@ -141,7 +153,7 @@ module MaxMind
|
|
141
153
|
|
142
154
|
# This is true if the IP address is on a suspected anonymizing network
|
143
155
|
# and belongs to a residential ISP. This property is only available
|
144
|
-
# from
|
156
|
+
# from Insights.
|
145
157
|
#
|
146
158
|
# @return [Boolean]
|
147
159
|
def residential_proxy?
|
@@ -149,7 +161,7 @@ module MaxMind
|
|
149
161
|
end
|
150
162
|
|
151
163
|
# This is true if the IP address is a Tor exit node. This property is only
|
152
|
-
# available from
|
164
|
+
# available from Insights.
|
153
165
|
#
|
154
166
|
# @return [Boolean]
|
155
167
|
def tor_exit_node?
|
@@ -157,7 +169,7 @@ module MaxMind
|
|
157
169
|
end
|
158
170
|
|
159
171
|
# The name of the ISP associated with the IP address. This attribute is
|
160
|
-
# only available from the City and Insights web services and the
|
172
|
+
# only available from the City Plus and Insights web services and the
|
161
173
|
# Enterprise database.
|
162
174
|
#
|
163
175
|
# @return [String, nil]
|
@@ -175,8 +187,8 @@ module MaxMind
|
|
175
187
|
end
|
176
188
|
|
177
189
|
# The name of the organization associated with the IP address. This
|
178
|
-
# attribute is only available from the City and Insights web services
|
179
|
-
# the
|
190
|
+
# attribute is only available from the City Plus and Insights web services
|
191
|
+
# and the Enterprise database.
|
180
192
|
#
|
181
193
|
# @return [String, nil]
|
182
194
|
def organization
|
@@ -184,7 +196,7 @@ module MaxMind
|
|
184
196
|
end
|
185
197
|
|
186
198
|
# An indicator of how static or dynamic an IP address is. This property is
|
187
|
-
# only available from
|
199
|
+
# only available from Insights.
|
188
200
|
#
|
189
201
|
# @return [Float, nil]
|
190
202
|
def static_ip_score
|
@@ -193,8 +205,7 @@ module MaxMind
|
|
193
205
|
|
194
206
|
# The estimated number of users sharing the IP/network during the past 24
|
195
207
|
# hours. For IPv4, the count is for the individual IP. For IPv6, the count
|
196
|
-
# is for the /64 network. This property is only available from
|
197
|
-
# Precision Insights.
|
208
|
+
# is for the /64 network. This property is only available from Insights.
|
198
209
|
#
|
199
210
|
# @return [Integer, nil]
|
200
211
|
def user_count
|
@@ -208,6 +219,7 @@ module MaxMind
|
|
208
219
|
# * cafe
|
209
220
|
# * cellular
|
210
221
|
# * college
|
222
|
+
# * consumer_privacy_network
|
211
223
|
# * content_delivery_network
|
212
224
|
# * dialup
|
213
225
|
# * government
|
@@ -221,7 +233,7 @@ module MaxMind
|
|
221
233
|
# * traveler
|
222
234
|
#
|
223
235
|
# This attribute is only available from the Insights web service and the
|
224
|
-
#
|
236
|
+
# Enterprise database.
|
225
237
|
#
|
226
238
|
# @return [String, nil]
|
227
239
|
def user_type
|
data/maxmind-geoip2.gemspec
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'maxmind/geoip2/version'
|
7
|
+
|
3
8
|
Gem::Specification.new do |s|
|
4
9
|
s.authors = ['William Storey']
|
5
|
-
s.files = Dir['**/*']
|
10
|
+
s.files = Dir['**/*'].difference(Dir['.github/**/*', 'dev-bin/**/*'])
|
6
11
|
s.name = 'maxmind-geoip2'
|
7
12
|
s.summary = 'A gem for interacting with the GeoIP2 webservices and databases.'
|
8
|
-
s.version =
|
13
|
+
s.version = MaxMind::GeoIP2::VERSION
|
9
14
|
|
10
15
|
s.description = 'A gem for interacting with the GeoIP2 webservices and databases. MaxMind provides geolocation data as downloadable databases as well as through a webservice.'
|
11
16
|
s.email = 'support@maxmind.com'
|
@@ -19,11 +24,11 @@ Gem::Specification.new do |s|
|
|
19
24
|
'rubygems_mfa_required' => 'true',
|
20
25
|
'source_code_uri' => 'https://github.com/maxmind/GeoIP2-ruby',
|
21
26
|
}
|
22
|
-
s.required_ruby_version = '>=
|
27
|
+
s.required_ruby_version = '>= 3.0'
|
23
28
|
|
24
|
-
s.
|
25
|
-
s.
|
26
|
-
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.2']
|
27
32
|
|
28
33
|
s.add_development_dependency 'minitest'
|
29
34
|
s.add_development_dependency 'rake'
|
@@ -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.
|
@@ -0,0 +1,68 @@
|
|
1
|
+
// write-test-data generates test mmdb files.
|
2
|
+
package main
|
3
|
+
|
4
|
+
import (
|
5
|
+
"flag"
|
6
|
+
"fmt"
|
7
|
+
"os"
|
8
|
+
|
9
|
+
"github.com/maxmind/MaxMind-DB/pkg/writer"
|
10
|
+
)
|
11
|
+
|
12
|
+
func main() {
|
13
|
+
source := flag.String("source", "", "Source data directory")
|
14
|
+
target := flag.String("target", "", "Destination directory for the generated mmdb files")
|
15
|
+
|
16
|
+
flag.Parse()
|
17
|
+
|
18
|
+
w, err := writer.New(*source, *target)
|
19
|
+
if err != nil {
|
20
|
+
fmt.Printf("creating writer: %+v\n", err)
|
21
|
+
os.Exit(1)
|
22
|
+
}
|
23
|
+
|
24
|
+
if err := w.WriteIPv4TestDB(); err != nil {
|
25
|
+
fmt.Printf("writing IPv4 test databases: %+v\n", err)
|
26
|
+
os.Exit(1)
|
27
|
+
}
|
28
|
+
|
29
|
+
if err := w.WriteIPv6TestDB(); err != nil {
|
30
|
+
fmt.Printf("writing IPv6 test databases: %+v\n", err)
|
31
|
+
os.Exit(1)
|
32
|
+
}
|
33
|
+
|
34
|
+
if err := w.WriteMixedIPTestDB(); err != nil {
|
35
|
+
fmt.Printf("writing IPv6 test databases: %+v\n", err)
|
36
|
+
os.Exit(1)
|
37
|
+
}
|
38
|
+
|
39
|
+
if err := w.WriteNoIPv4TestDB(); err != nil {
|
40
|
+
fmt.Printf("writing no IPv4 test databases: %+v\n", err)
|
41
|
+
os.Exit(1)
|
42
|
+
}
|
43
|
+
|
44
|
+
if err := w.WriteNoMapTestDB(); err != nil {
|
45
|
+
fmt.Printf("writing no map test databases: %+v\n", err)
|
46
|
+
os.Exit(1)
|
47
|
+
}
|
48
|
+
|
49
|
+
if err := w.WriteMetadataPointersTestDB(); err != nil {
|
50
|
+
fmt.Printf("writing metadata pointers test databases: %+v\n", err)
|
51
|
+
os.Exit(1)
|
52
|
+
}
|
53
|
+
|
54
|
+
if err := w.WriteDecoderTestDB(); err != nil {
|
55
|
+
fmt.Printf("writing decoder test databases: %+v\n", err)
|
56
|
+
os.Exit(1)
|
57
|
+
}
|
58
|
+
|
59
|
+
if err := w.WriteDeeplyNestedStructuresTestDB(); err != nil {
|
60
|
+
fmt.Printf("writing decoder test databases: %+v\n", err)
|
61
|
+
os.Exit(1)
|
62
|
+
}
|
63
|
+
|
64
|
+
if err := w.WriteGeoIP2TestDB(); err != nil {
|
65
|
+
fmt.Printf("writing GeoIP2 test databases: %+v\n", err)
|
66
|
+
os.Exit(1)
|
67
|
+
}
|
68
|
+
}
|
data/test/data/go.mod
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
module github.com/maxmind/MaxMind-DB
|
2
|
+
|
3
|
+
go 1.23
|
4
|
+
|
5
|
+
require (
|
6
|
+
github.com/maxmind/mmdbwriter v1.0.0
|
7
|
+
go4.org/netipx v0.0.0-20230824141953-6213f710f925
|
8
|
+
)
|
9
|
+
|
10
|
+
require (
|
11
|
+
github.com/oschwald/maxminddb-golang v1.12.0 // indirect
|
12
|
+
golang.org/x/sys v0.10.0 // indirect
|
13
|
+
)
|
data/test/data/go.sum
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
2
|
+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
3
|
+
github.com/maxmind/mmdbwriter v1.0.0 h1:bieL4P6yaYaHvbtLSwnKtEvScUKKD6jcKaLiTM3WSMw=
|
4
|
+
github.com/maxmind/mmdbwriter v1.0.0/go.mod h1:noBMCUtyN5PUQ4H8ikkOvGSHhzhLok51fON2hcrpKj8=
|
5
|
+
github.com/oschwald/maxminddb-golang v1.12.0 h1:9FnTOD0YOhP7DGxGsq4glzpGy5+w7pq50AS6wALUMYs=
|
6
|
+
github.com/oschwald/maxminddb-golang v1.12.0/go.mod h1:q0Nob5lTCqyQ8WT6FYgS1L7PXKVVbgiymefNwIjPzgY=
|
7
|
+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
8
|
+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
9
|
+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
10
|
+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
11
|
+
go4.org/netipx v0.0.0-20230824141953-6213f710f925 h1:eeQDDVKFkx0g4Hyy8pHgmZaK0EqB4SD6rvKbUdN3ziQ=
|
12
|
+
go4.org/netipx v0.0.0-20230824141953-6213f710f925/go.mod h1:PLyyIXexvUFg3Owu6p/WfdlivPbZJsZdgWZlrGope/Y=
|
13
|
+
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
|
14
|
+
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
15
|
+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
16
|
+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|