Skip to content

Commit 75e38f3

Browse files
committed
Fix wrong impl failing IPv4-in-IPv6 when IPv4-mapped IPv6 is missing
--- Fix wrong root in MMDB tree parser, which failed IPv4 lookups in IPv6 databases that don't include IPv4-mapped IPv6 addresses. A bug that was part of locus since forever but didn't show up in MaxMind databases since those appear to always include the IPv4-mapped IPv6 addresses node. Thanks to https://github.com/nickjacob who left me the clues I needed in an earlier closed PR: * #39
1 parent b83d0cc commit 75e38f3

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [Unreleased]
8+
9+
### Fixed
10+
11+
- wrong root in MMDB tree parser, failing IPv4 lookups in IPv6 databases that
12+
don't include IPv4-mapped IPv6 addresses [wrong since 1.0.0]
13+
714
## [2.3.7] - 2024-03-16
815

916
### Added

src/locus_mmdb_tree.erl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@
4545
%% Macro Definitions
4646
%% ------------------------------------------------------------------
4747

48-
% https://en.wikipedia.org/wiki/IPv6#IPv4-mapped_IPv6_addresses
49-
-define(IPV4_IPV6_PREFIX, <<0:80, 16#FFFF:16>>).
48+
% "When storing IPv4 addresses in an IPv6 tree, they are stored as-is, so they
49+
% occupy the first 32-bits of the address space (from 0 to 2**32 - 1)."
50+
%
51+
% * https://maxmind.github.io/MaxMind-DB/#ipv4-addresses-in-an-ipv6-tree
52+
%
53+
-define(IPV4_IPV6_PREFIX, <<0:96>>).
5054

5155
%% ------------------------------------------------------------------
5256
%% API Record and Type Definitions

0 commit comments

Comments
 (0)