maxmind-db 1.1.1 → 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 +28 -0
- data/Gemfile.lock +72 -0
- data/README.dev.md +2 -35
- data/README.md +2 -3
- data/Rakefile +2 -2
- data/bin/mmdb-benchmark.rb +3 -3
- data/lib/maxmind/db/decoder.rb +3 -0
- data/lib/maxmind/db/file_reader.rb +29 -11
- data/lib/maxmind/db.rb +9 -10
- data/maxmind-db.gemspec +8 -4
- metadata +49 -73
- data/test/data/LICENSE +0 -4
- data/test/data/MaxMind-DB-spec.md +0 -570
- data/test/data/MaxMind-DB-test-metadata-pointers.mmdb +0 -0
- data/test/data/README.md +0 -4
- data/test/data/bad-data/README.md +0 -7
- data/test/data/bad-data/libmaxminddb/libmaxminddb-offset-integer-overflow.mmdb +0 -0
- data/test/data/bad-data/maxminddb-golang/cyclic-data-structure.mmdb +0 -0
- data/test/data/bad-data/maxminddb-golang/invalid-bytes-length.mmdb +0 -1
- data/test/data/bad-data/maxminddb-golang/invalid-data-record-offset.mmdb +0 -0
- data/test/data/bad-data/maxminddb-golang/invalid-map-key-length.mmdb +0 -0
- data/test/data/bad-data/maxminddb-golang/invalid-string-length.mmdb +0 -1
- data/test/data/bad-data/maxminddb-golang/metadata-is-an-uint128.mmdb +0 -1
- data/test/data/bad-data/maxminddb-golang/unexpected-bytes.mmdb +0 -0
- data/test/data/perltidyrc +0 -12
- data/test/data/source-data/GeoIP2-Anonymous-IP-Test.json +0 -48
- data/test/data/source-data/GeoIP2-City-Test.json +0 -12852
- data/test/data/source-data/GeoIP2-Connection-Type-Test.json +0 -102
- data/test/data/source-data/GeoIP2-Country-Test.json +0 -15916
- data/test/data/source-data/GeoIP2-DensityIncome-Test.json +0 -14
- data/test/data/source-data/GeoIP2-Domain-Test.json +0 -452
- data/test/data/source-data/GeoIP2-Enterprise-Test.json +0 -673
- data/test/data/source-data/GeoIP2-ISP-Test.json +0 -12593
- data/test/data/source-data/GeoIP2-Precision-Enterprise-Test.json +0 -2018
- data/test/data/source-data/GeoIP2-Static-IP-Score-Test.json +0 -2132
- data/test/data/source-data/GeoIP2-User-Count-Test.json +0 -2837
- data/test/data/source-data/GeoLite2-ASN-Test.json +0 -37
- data/test/data/source-data/README +0 -15
- 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-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/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/README.md +0 -26
- data/test/data/test-data/maps-with-pointers.raw +0 -0
- data/test/data/test-data/write-test-data.pl +0 -640
- data/test/data/tidyall.ini +0 -5
- data/test/mmdb_util.rb +0 -26
- data/test/test_decoder.rb +0 -243
- data/test/test_reader.rb +0 -539
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77f9cd0d89c27c78de29dc99fab391f945d9828b4b5fa84f3deffcee524be975
|
|
4
|
+
data.tar.gz: 8310c429dded70a05039a7e338c59b2d09167ba4d4a68e79233fea67f21abd6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 20721610296dd6758e18e7c735cb9321a71dcdbce22b30df0203883fd78b6aa02117585bad059a5db86c1f57d22ac4bdb7e2d9bac01391f528f37b27a3103a29
|
|
7
|
+
data.tar.gz: 1f19868cdd79c85a1a654ea8e84bc5ae02c5fd422724fcd0cc2766cee445bb02b6f761bd2f66518fbe4d4839d0e028cb481a13a9e5ab022dbbcb8e464fa6a028
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.4.0 (2025-11-20)
|
|
4
|
+
|
|
5
|
+
* Ruby 3.2+ is now required. If you're using Ruby 3.0 or 3.1, please use
|
|
6
|
+
version 1.3.2 of this gem.
|
|
7
|
+
|
|
8
|
+
## 1.3.2 (2025-04-03)
|
|
9
|
+
|
|
10
|
+
* Re-release to fix a release script problem. There are no code changes.
|
|
11
|
+
|
|
12
|
+
## 1.3.1 (2025-04-03)
|
|
13
|
+
|
|
14
|
+
* Re-release to fix a release script problem. There are no code changes.
|
|
15
|
+
|
|
16
|
+
## 1.3.0 (2025-04-03)
|
|
17
|
+
|
|
18
|
+
* Ruby 3.0+ is now required. If you're using Ruby 2.5, 2.6, or 2.7, please
|
|
19
|
+
use version 1.2.0 of this gem.
|
|
20
|
+
|
|
21
|
+
## 1.2.0 (2023-11-22)
|
|
22
|
+
|
|
23
|
+
* Ruby 2.4 is no longer supported. If you're using Ruby 2.4, please use
|
|
24
|
+
version 1.1.1 of this gem.
|
|
25
|
+
* `Object#respond_to?` is no longer called on every read. Pull request by
|
|
26
|
+
Jean byroot Boussier. GitHub #65.
|
|
27
|
+
* The `get` and `get_prefix_length` methods now accept the IP addresses as
|
|
28
|
+
`IPAddr` objects. Strings are still accepted too. Pull request by Eddie
|
|
29
|
+
Lebow. GitHub #69.
|
|
30
|
+
|
|
3
31
|
## 1.1.1 (2020-06-23)
|
|
4
32
|
|
|
5
33
|
* Fixed the memory reader's inspect method to no longer attempt to modify a
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
maxmind-db (1.4.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.3)
|
|
10
|
+
json (2.16.0)
|
|
11
|
+
language_server-protocol (3.17.0.5)
|
|
12
|
+
lint_roller (1.1.0)
|
|
13
|
+
minitest (5.26.2)
|
|
14
|
+
parallel (1.27.0)
|
|
15
|
+
parser (3.3.10.0)
|
|
16
|
+
ast (~> 2.4.1)
|
|
17
|
+
racc
|
|
18
|
+
prism (1.6.0)
|
|
19
|
+
racc (1.8.1)
|
|
20
|
+
rainbow (3.1.1)
|
|
21
|
+
rake (13.3.1)
|
|
22
|
+
regexp_parser (2.11.3)
|
|
23
|
+
rubocop (1.81.7)
|
|
24
|
+
json (~> 2.3)
|
|
25
|
+
language_server-protocol (~> 3.17.0.2)
|
|
26
|
+
lint_roller (~> 1.1.0)
|
|
27
|
+
parallel (~> 1.10)
|
|
28
|
+
parser (>= 3.3.0.2)
|
|
29
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
30
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
31
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
32
|
+
ruby-progressbar (~> 1.7)
|
|
33
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
34
|
+
rubocop-ast (1.48.0)
|
|
35
|
+
parser (>= 3.3.7.2)
|
|
36
|
+
prism (~> 1.4)
|
|
37
|
+
rubocop-minitest (0.38.2)
|
|
38
|
+
lint_roller (~> 1.1)
|
|
39
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
40
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
|
41
|
+
rubocop-performance (1.26.1)
|
|
42
|
+
lint_roller (~> 1.1)
|
|
43
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
44
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
45
|
+
rubocop-rake (0.7.1)
|
|
46
|
+
lint_roller (~> 1.1)
|
|
47
|
+
rubocop (>= 1.72.1)
|
|
48
|
+
rubocop-thread_safety (0.7.3)
|
|
49
|
+
lint_roller (~> 1.1)
|
|
50
|
+
rubocop (~> 1.72, >= 1.72.1)
|
|
51
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
|
52
|
+
ruby-progressbar (1.13.0)
|
|
53
|
+
unicode-display_width (3.2.0)
|
|
54
|
+
unicode-emoji (~> 4.1)
|
|
55
|
+
unicode-emoji (4.1.0)
|
|
56
|
+
|
|
57
|
+
PLATFORMS
|
|
58
|
+
ruby
|
|
59
|
+
x86_64-linux
|
|
60
|
+
|
|
61
|
+
DEPENDENCIES
|
|
62
|
+
maxmind-db!
|
|
63
|
+
minitest
|
|
64
|
+
rake
|
|
65
|
+
rubocop
|
|
66
|
+
rubocop-minitest
|
|
67
|
+
rubocop-performance
|
|
68
|
+
rubocop-rake
|
|
69
|
+
rubocop-thread_safety
|
|
70
|
+
|
|
71
|
+
BUNDLED WITH
|
|
72
|
+
2.6.9
|
data/README.dev.md
CHANGED
|
@@ -1,37 +1,4 @@
|
|
|
1
1
|
# How to release
|
|
2
|
-
* Ensure tests pass: `rake`
|
|
3
|
-
* Update changelog: Set version and release date
|
|
4
|
-
* Set version in `maxmind-db.gemspec`
|
|
5
|
-
* Add them: `git add -p`
|
|
6
|
-
* Commit: `git commit -m v1.0.0`
|
|
7
|
-
* Tag: `git tag -a v1.0.0 -m v1.0.0`
|
|
8
|
-
* Clean up to be sure nothing stray gets into gem: `git clean -dxff`
|
|
9
|
-
* Create `.gem` file: `gem build maxmind-db.gemspec`
|
|
10
|
-
* Complete prerequisites (see below)
|
|
11
|
-
* You only need to do this if `~/.gem/credentials` is missing
|
|
12
|
-
`:rubygems_api_key`.
|
|
13
|
-
* Upload to rubygems.org: `gem push maxmind-db-1.0.0.gem`
|
|
14
|
-
* Push: `git push`
|
|
15
|
-
* Push tag: `git push --tags`
|
|
16
|
-
* Double check it looks okay at https://rubygems.org/gems/maxmind-db and
|
|
17
|
-
https://www.rubydoc.info/gems/maxmind-db
|
|
18
2
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## Step 1
|
|
23
|
-
Sign up for an account at rubygems.org if you don't have one.
|
|
24
|
-
|
|
25
|
-
Enable multi factor authentication.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## Step 2
|
|
29
|
-
Ask someone who is an owner of the gem to add you as one.
|
|
30
|
-
|
|
31
|
-
They do this by using the `gem owner` command
|
|
32
|
-
([docs](https://guides.rubygems.org/command-reference/#gem-owner)).
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## Step 3
|
|
36
|
-
Go to your rubygems.org profile and find the curl command to run to
|
|
37
|
-
download your API key.
|
|
3
|
+
See
|
|
4
|
+
[here](https://github.com/maxmind/minfraud-api-ruby/blob/main/README.dev.md).
|
data/README.md
CHANGED
|
@@ -6,7 +6,6 @@ This is the Ruby API for reading [MaxMind
|
|
|
6
6
|
DB](https://maxmind.github.io/MaxMind-DB/) files. MaxMind DB is a binary
|
|
7
7
|
file format that stores data indexed by IP address subnets (IPv4 or IPv6).
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
## Installation
|
|
11
10
|
|
|
12
11
|
```
|
|
@@ -36,7 +35,7 @@ For more information see the
|
|
|
36
35
|
|
|
37
36
|
## Requirements
|
|
38
37
|
|
|
39
|
-
This code requires Ruby version 2
|
|
38
|
+
This code requires Ruby version 3.2 or higher.
|
|
40
39
|
|
|
41
40
|
## Contributing
|
|
42
41
|
|
|
@@ -57,7 +56,7 @@ This library uses [Semantic Versioning](https://semver.org/).
|
|
|
57
56
|
|
|
58
57
|
## Copyright and License
|
|
59
58
|
|
|
60
|
-
This software is Copyright (c) 2018 -
|
|
59
|
+
This software is Copyright (c) 2018 - 2025 by MaxMind, Inc.
|
|
61
60
|
|
|
62
61
|
This is free software, licensed under the [Apache License, Version
|
|
63
62
|
2.0](LICENSE-APACHE) or the [MIT License](LICENSE-MIT), at your option.
|
data/Rakefile
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
3
4
|
require 'rake/testtask'
|
|
4
5
|
require 'rubocop/rake_task'
|
|
5
6
|
|
|
@@ -10,5 +11,4 @@ end
|
|
|
10
11
|
RuboCop::RakeTask.new
|
|
11
12
|
|
|
12
13
|
desc 'Run tests and RuboCop'
|
|
13
|
-
task default:
|
|
14
|
-
task default: :rubocop
|
|
14
|
+
task default: %i[test rubocop]
|
data/bin/mmdb-benchmark.rb
CHANGED
|
@@ -29,9 +29,9 @@ end
|
|
|
29
29
|
|
|
30
30
|
def print_usage
|
|
31
31
|
# rubocop:disable Style/StderrPuts
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
$stderr.puts "Usage: #{$PROGRAM_NAME} <MMDB file> <IP file>"
|
|
33
|
+
$stderr.puts
|
|
34
|
+
$stderr.puts 'Benchmark by reading IPs from the IP file and looking up each one in the MMDB file.'
|
|
35
35
|
# rubocop:enable Style/StderrPuts
|
|
36
36
|
end
|
|
37
37
|
|
data/lib/maxmind/db/decoder.rb
CHANGED
|
@@ -12,6 +12,8 @@ module MaxMind
|
|
|
12
12
|
#
|
|
13
13
|
# @!visibility private
|
|
14
14
|
class Decoder
|
|
15
|
+
# rubocop:disable Style/OptionalBooleanParameter
|
|
16
|
+
|
|
15
17
|
# Create a +Decoder+.
|
|
16
18
|
#
|
|
17
19
|
# +io+ is the DB. It must provide a +read+ method. It must be opened in
|
|
@@ -28,6 +30,7 @@ module MaxMind
|
|
|
28
30
|
@pointer_base = pointer_base
|
|
29
31
|
@pointer_test = pointer_test
|
|
30
32
|
end
|
|
33
|
+
# rubocop:enable Style/OptionalBooleanParameter
|
|
31
34
|
|
|
32
35
|
private
|
|
33
36
|
|
|
@@ -6,10 +6,36 @@ module MaxMind
|
|
|
6
6
|
class DB
|
|
7
7
|
# @!visibility private
|
|
8
8
|
class FileReader
|
|
9
|
+
if ::File.method_defined?(:pread)
|
|
10
|
+
PReadFile = ::File
|
|
11
|
+
else
|
|
12
|
+
# For Windows support
|
|
13
|
+
class PReadFile
|
|
14
|
+
def initialize(filename, mode)
|
|
15
|
+
@mutex = Mutex.new
|
|
16
|
+
@file = File.new(filename, mode)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def size
|
|
20
|
+
@file.size
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def close
|
|
24
|
+
@file.close
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def pread(size, offset)
|
|
28
|
+
@mutex.synchronize do
|
|
29
|
+
@file.seek(offset, IO::SEEK_SET)
|
|
30
|
+
@file.read(size)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
9
36
|
def initialize(filename)
|
|
10
|
-
@fh =
|
|
37
|
+
@fh = PReadFile.new(filename, 'rb')
|
|
11
38
|
@size = @fh.size
|
|
12
|
-
@mutex = Mutex.new
|
|
13
39
|
end
|
|
14
40
|
|
|
15
41
|
attr_reader :size
|
|
@@ -21,15 +47,7 @@ module MaxMind
|
|
|
21
47
|
def read(offset, size)
|
|
22
48
|
return ''.b if size == 0
|
|
23
49
|
|
|
24
|
-
|
|
25
|
-
if @fh.respond_to?(:pread)
|
|
26
|
-
buf = @fh.pread(size, offset)
|
|
27
|
-
else
|
|
28
|
-
@mutex.synchronize do
|
|
29
|
-
@fh.seek(offset, IO::SEEK_SET)
|
|
30
|
-
buf = @fh.read(size)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
50
|
+
buf = @fh.pread(size, offset)
|
|
33
51
|
|
|
34
52
|
raise InvalidDatabaseError, 'The MaxMind DB file contains bad data' if buf.nil? || buf.length != size
|
|
35
53
|
|
data/lib/maxmind/db.rb
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
require 'ipaddr'
|
|
4
4
|
require 'maxmind/db/decoder'
|
|
5
5
|
require 'maxmind/db/errors'
|
|
6
|
-
require 'maxmind/db/file_reader
|
|
7
|
-
require 'maxmind/db/memory_reader
|
|
8
|
-
require 'maxmind/db/metadata
|
|
6
|
+
require 'maxmind/db/file_reader'
|
|
7
|
+
require 'maxmind/db/memory_reader'
|
|
8
|
+
require 'maxmind/db/metadata'
|
|
9
9
|
|
|
10
10
|
module MaxMind
|
|
11
11
|
# DB provides a way to read {MaxMind DB
|
|
@@ -130,8 +130,7 @@ module MaxMind
|
|
|
130
130
|
#
|
|
131
131
|
# If no record is found for the IP address, +get+ returns +nil+.
|
|
132
132
|
#
|
|
133
|
-
# @param ip_address [String]
|
|
134
|
-
# IPv4 or IPv6.
|
|
133
|
+
# @param ip_address [String, IPAddr] IPv4 or IPv6 address.
|
|
135
134
|
#
|
|
136
135
|
# @raise [ArgumentError] if you attempt to look up an IPv6 address in an
|
|
137
136
|
# IPv4-only database.
|
|
@@ -153,8 +152,7 @@ module MaxMind
|
|
|
153
152
|
# If no record is found for the IP address, the record will be +nil+ and
|
|
154
153
|
# the prefix length will be the value for the missing network.
|
|
155
154
|
#
|
|
156
|
-
# @param ip_address [String]
|
|
157
|
-
# IPv4 or IPv6.
|
|
155
|
+
# @param ip_address [String, IPAddr] IPv4 or IPv6 address.
|
|
158
156
|
#
|
|
159
157
|
# @raise [ArgumentError] if you attempt to look up an IPv6 address in an
|
|
160
158
|
# IPv4-only database.
|
|
@@ -163,7 +161,8 @@ module MaxMind
|
|
|
163
161
|
#
|
|
164
162
|
# @return [Array<(Object, Integer)>]
|
|
165
163
|
def get_with_prefix_length(ip_address)
|
|
166
|
-
ip = IPAddr.new(ip_address)
|
|
164
|
+
ip = ip_address.is_a?(IPAddr) ? ip_address : IPAddr.new(ip_address)
|
|
165
|
+
|
|
167
166
|
# We could check the IP has the correct prefix (32 or 128) but I do not
|
|
168
167
|
# for performance reasons.
|
|
169
168
|
|
|
@@ -200,7 +199,7 @@ module MaxMind
|
|
|
200
199
|
break if depth >= bit_count || node >= node_count
|
|
201
200
|
|
|
202
201
|
c = packed[depth >> 3].ord
|
|
203
|
-
bit = 1 & (c >> 7 - (depth % 8))
|
|
202
|
+
bit = 1 & (c >> (7 - (depth % 8)))
|
|
204
203
|
node = read_node(node, bit)
|
|
205
204
|
depth += 1
|
|
206
205
|
end
|
|
@@ -273,7 +272,7 @@ module MaxMind
|
|
|
273
272
|
end
|
|
274
273
|
|
|
275
274
|
def find_metadata_start
|
|
276
|
-
metadata_max_size = @size
|
|
275
|
+
metadata_max_size = [@size, METADATA_MAX_SIZE].min
|
|
277
276
|
|
|
278
277
|
stop_index = @size - metadata_max_size
|
|
279
278
|
index = @size - METADATA_START_MARKER_LENGTH
|
data/maxmind-db.gemspec
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.authors = ['William Storey']
|
|
5
|
-
s.files = Dir['**/*']
|
|
5
|
+
s.files = Dir['**/*'].difference(Dir['.github/**/*', 'dev-bin/**/*', 'test/**/*'])
|
|
6
6
|
s.name = 'maxmind-db'
|
|
7
7
|
s.summary = 'A gem for reading MaxMind DB files.'
|
|
8
|
-
s.version = '1.
|
|
8
|
+
s.version = '1.4.0'
|
|
9
9
|
|
|
10
10
|
s.description = 'A gem for reading MaxMind DB files. MaxMind DB is a binary file format that stores data indexed by IP address subnets (IPv4 or IPv6).'
|
|
11
11
|
s.email = 'support@maxmind.com'
|
|
@@ -13,15 +13,19 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.licenses = ['Apache-2.0', 'MIT']
|
|
14
14
|
s.metadata = {
|
|
15
15
|
'bug_tracker_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby/issues',
|
|
16
|
-
'changelog_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby/blob/
|
|
16
|
+
'changelog_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby/blob/main/CHANGELOG.md',
|
|
17
17
|
'documentation_uri' => 'https://www.rubydoc.info/gems/maxmind-db',
|
|
18
18
|
'homepage_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby',
|
|
19
19
|
'source_code_uri' => 'https://github.com/maxmind/MaxMind-DB-Reader-ruby',
|
|
20
|
+
'rubygems_mfa_required' => 'true',
|
|
20
21
|
}
|
|
21
|
-
s.required_ruby_version = '>= 2
|
|
22
|
+
s.required_ruby_version = '>= 3.2'
|
|
22
23
|
|
|
23
24
|
s.add_development_dependency 'minitest'
|
|
24
25
|
s.add_development_dependency 'rake'
|
|
25
26
|
s.add_development_dependency 'rubocop'
|
|
27
|
+
s.add_development_dependency 'rubocop-minitest'
|
|
26
28
|
s.add_development_dependency 'rubocop-performance'
|
|
29
|
+
s.add_development_dependency 'rubocop-rake'
|
|
30
|
+
s.add_development_dependency 'rubocop-thread_safety'
|
|
27
31
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: maxmind-db
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- William Storey
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: minitest
|
|
@@ -52,6 +51,20 @@ dependencies:
|
|
|
52
51
|
- - ">="
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
53
|
version: '0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rubocop-minitest
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - ">="
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '0'
|
|
55
68
|
- !ruby/object:Gem::Dependency
|
|
56
69
|
name: rubocop-performance
|
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -66,6 +79,34 @@ dependencies:
|
|
|
66
79
|
- - ">="
|
|
67
80
|
- !ruby/object:Gem::Version
|
|
68
81
|
version: '0'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: rubocop-rake
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: rubocop-thread_safety
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0'
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
69
110
|
description: A gem for reading MaxMind DB files. MaxMind DB is a binary file format
|
|
70
111
|
that stores data indexed by IP address subnets (IPv4 or IPv6).
|
|
71
112
|
email: support@maxmind.com
|
|
@@ -75,6 +116,7 @@ extra_rdoc_files: []
|
|
|
75
116
|
files:
|
|
76
117
|
- CHANGELOG.md
|
|
77
118
|
- Gemfile
|
|
119
|
+
- Gemfile.lock
|
|
78
120
|
- LICENSE-APACHE
|
|
79
121
|
- LICENSE-MIT
|
|
80
122
|
- README.dev.md
|
|
@@ -88,81 +130,17 @@ files:
|
|
|
88
130
|
- lib/maxmind/db/memory_reader.rb
|
|
89
131
|
- lib/maxmind/db/metadata.rb
|
|
90
132
|
- maxmind-db.gemspec
|
|
91
|
-
- test/data/LICENSE
|
|
92
|
-
- test/data/MaxMind-DB-spec.md
|
|
93
|
-
- test/data/MaxMind-DB-test-metadata-pointers.mmdb
|
|
94
|
-
- test/data/README.md
|
|
95
|
-
- test/data/bad-data/README.md
|
|
96
|
-
- test/data/bad-data/libmaxminddb/libmaxminddb-offset-integer-overflow.mmdb
|
|
97
|
-
- test/data/bad-data/maxminddb-golang/cyclic-data-structure.mmdb
|
|
98
|
-
- test/data/bad-data/maxminddb-golang/invalid-bytes-length.mmdb
|
|
99
|
-
- test/data/bad-data/maxminddb-golang/invalid-data-record-offset.mmdb
|
|
100
|
-
- test/data/bad-data/maxminddb-golang/invalid-map-key-length.mmdb
|
|
101
|
-
- test/data/bad-data/maxminddb-golang/invalid-string-length.mmdb
|
|
102
|
-
- test/data/bad-data/maxminddb-golang/metadata-is-an-uint128.mmdb
|
|
103
|
-
- test/data/bad-data/maxminddb-golang/unexpected-bytes.mmdb
|
|
104
|
-
- test/data/perltidyrc
|
|
105
|
-
- test/data/source-data/GeoIP2-Anonymous-IP-Test.json
|
|
106
|
-
- test/data/source-data/GeoIP2-City-Test.json
|
|
107
|
-
- test/data/source-data/GeoIP2-Connection-Type-Test.json
|
|
108
|
-
- test/data/source-data/GeoIP2-Country-Test.json
|
|
109
|
-
- test/data/source-data/GeoIP2-DensityIncome-Test.json
|
|
110
|
-
- test/data/source-data/GeoIP2-Domain-Test.json
|
|
111
|
-
- test/data/source-data/GeoIP2-Enterprise-Test.json
|
|
112
|
-
- test/data/source-data/GeoIP2-ISP-Test.json
|
|
113
|
-
- test/data/source-data/GeoIP2-Precision-Enterprise-Test.json
|
|
114
|
-
- test/data/source-data/GeoIP2-Static-IP-Score-Test.json
|
|
115
|
-
- test/data/source-data/GeoIP2-User-Count-Test.json
|
|
116
|
-
- test/data/source-data/GeoLite2-ASN-Test.json
|
|
117
|
-
- test/data/source-data/README
|
|
118
|
-
- test/data/test-data/GeoIP2-Anonymous-IP-Test.mmdb
|
|
119
|
-
- test/data/test-data/GeoIP2-City-Test-Broken-Double-Format.mmdb
|
|
120
|
-
- test/data/test-data/GeoIP2-City-Test-Invalid-Node-Count.mmdb
|
|
121
|
-
- test/data/test-data/GeoIP2-City-Test.mmdb
|
|
122
|
-
- test/data/test-data/GeoIP2-Connection-Type-Test.mmdb
|
|
123
|
-
- test/data/test-data/GeoIP2-Country-Test.mmdb
|
|
124
|
-
- test/data/test-data/GeoIP2-DensityIncome-Test.mmdb
|
|
125
|
-
- test/data/test-data/GeoIP2-Domain-Test.mmdb
|
|
126
|
-
- test/data/test-data/GeoIP2-Enterprise-Test.mmdb
|
|
127
|
-
- test/data/test-data/GeoIP2-ISP-Test.mmdb
|
|
128
|
-
- test/data/test-data/GeoIP2-Precision-Enterprise-Test.mmdb
|
|
129
|
-
- test/data/test-data/GeoIP2-Static-IP-Score-Test.mmdb
|
|
130
|
-
- test/data/test-data/GeoIP2-User-Count-Test.mmdb
|
|
131
|
-
- test/data/test-data/GeoLite2-ASN-Test.mmdb
|
|
132
|
-
- test/data/test-data/MaxMind-DB-no-ipv4-search-tree.mmdb
|
|
133
|
-
- test/data/test-data/MaxMind-DB-string-value-entries.mmdb
|
|
134
|
-
- test/data/test-data/MaxMind-DB-test-broken-pointers-24.mmdb
|
|
135
|
-
- test/data/test-data/MaxMind-DB-test-broken-search-tree-24.mmdb
|
|
136
|
-
- test/data/test-data/MaxMind-DB-test-decoder.mmdb
|
|
137
|
-
- test/data/test-data/MaxMind-DB-test-ipv4-24.mmdb
|
|
138
|
-
- test/data/test-data/MaxMind-DB-test-ipv4-28.mmdb
|
|
139
|
-
- test/data/test-data/MaxMind-DB-test-ipv4-32.mmdb
|
|
140
|
-
- test/data/test-data/MaxMind-DB-test-ipv6-24.mmdb
|
|
141
|
-
- test/data/test-data/MaxMind-DB-test-ipv6-28.mmdb
|
|
142
|
-
- test/data/test-data/MaxMind-DB-test-ipv6-32.mmdb
|
|
143
|
-
- test/data/test-data/MaxMind-DB-test-metadata-pointers.mmdb
|
|
144
|
-
- test/data/test-data/MaxMind-DB-test-mixed-24.mmdb
|
|
145
|
-
- test/data/test-data/MaxMind-DB-test-mixed-28.mmdb
|
|
146
|
-
- test/data/test-data/MaxMind-DB-test-mixed-32.mmdb
|
|
147
|
-
- test/data/test-data/MaxMind-DB-test-nested.mmdb
|
|
148
|
-
- test/data/test-data/README.md
|
|
149
|
-
- test/data/test-data/maps-with-pointers.raw
|
|
150
|
-
- test/data/test-data/write-test-data.pl
|
|
151
|
-
- test/data/tidyall.ini
|
|
152
|
-
- test/mmdb_util.rb
|
|
153
|
-
- test/test_decoder.rb
|
|
154
|
-
- test/test_reader.rb
|
|
155
133
|
homepage: https://github.com/maxmind/MaxMind-DB-Reader-ruby
|
|
156
134
|
licenses:
|
|
157
135
|
- Apache-2.0
|
|
158
136
|
- MIT
|
|
159
137
|
metadata:
|
|
160
138
|
bug_tracker_uri: https://github.com/maxmind/MaxMind-DB-Reader-ruby/issues
|
|
161
|
-
changelog_uri: https://github.com/maxmind/MaxMind-DB-Reader-ruby/blob/
|
|
139
|
+
changelog_uri: https://github.com/maxmind/MaxMind-DB-Reader-ruby/blob/main/CHANGELOG.md
|
|
162
140
|
documentation_uri: https://www.rubydoc.info/gems/maxmind-db
|
|
163
141
|
homepage_uri: https://github.com/maxmind/MaxMind-DB-Reader-ruby
|
|
164
142
|
source_code_uri: https://github.com/maxmind/MaxMind-DB-Reader-ruby
|
|
165
|
-
|
|
143
|
+
rubygems_mfa_required: 'true'
|
|
166
144
|
rdoc_options: []
|
|
167
145
|
require_paths:
|
|
168
146
|
- lib
|
|
@@ -170,16 +148,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
170
148
|
requirements:
|
|
171
149
|
- - ">="
|
|
172
150
|
- !ruby/object:Gem::Version
|
|
173
|
-
version: 2
|
|
151
|
+
version: '3.2'
|
|
174
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
153
|
requirements:
|
|
176
154
|
- - ">="
|
|
177
155
|
- !ruby/object:Gem::Version
|
|
178
156
|
version: '0'
|
|
179
157
|
requirements: []
|
|
180
|
-
|
|
181
|
-
rubygems_version: 2.7.6.2
|
|
182
|
-
signing_key:
|
|
158
|
+
rubygems_version: 3.6.9
|
|
183
159
|
specification_version: 4
|
|
184
160
|
summary: A gem for reading MaxMind DB files.
|
|
185
161
|
test_files: []
|
data/test/data/LICENSE
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
|
|
2
|
-
Unported License. To view a copy of this license, visit
|
|
3
|
-
http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
|
|
4
|
-
Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
|