Skip to content

Comments

Improve support for IPv4 mapped IPv6 addresses#888

Merged
hansott merged 14 commits intomainfrom
ipv4-mapped-ipv6
Jan 16, 2026
Merged

Improve support for IPv4 mapped IPv6 addresses#888
hansott merged 14 commits intomainfrom
ipv4-mapped-ipv6

Conversation

@hansott
Copy link
Member

@hansott hansott commented Jan 16, 2026

When an IPMatcher is called frequently or the list is often short/empty, we should add the ranges when creating the IPMatcher instance (e.g. bypassed IPs)

For bigger lists, we should convert the IP when checking (e.g. Geo lists or known threat actors)

Summary by Aikido

Security Issues: 0 Quality Issues: 0 Resolved Issues: 0

🚀 New Features

  • Added addIPv4MappedAddresses helper to generate mapped IPv6 entries

⚡ Enhancements

  • Included IPv4-mapped addresses for small, frequently used IPMatcher lists
  • Added IPMatcher.hasWithMappedCheck and extraction for mapped IPv4 lookups

🐛 Bugfixes

  • Fixed Network.contains overflow bug that mis-evaluated adjacent networks

🔧 Refactors

  • Switched large lists to map IPv4 at lookup time to save memory

More info

When an IPMatcher is called frequently or the list is often short/empty, we should add the ranges when
creating the IPMatcher instance (e.g. bypassed IPs)

For bigger lists, we should convert the IP when checking (e.g. Geo
lists or known threat actors)
@codecov
Copy link

codecov bot commented Jan 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The IPMatcher constructor calls summarizeSortedNetworks which has a bug when mixing IPv4 and IPv6 networks - it can incorrectly merge or drop networks during sorting/summarization. Using .add() for each IP avoids this issue as it inserts without summarization.
The contains() method incorrectly returned true when the "other" network's next address overflowed (extends to end of address space). This caused 224.0.0.0/4.contains(240.0.0.0/4) to return true, preventing adjacent ranges from being merged correctly in summarizeSortedNetworks.

See 482b0d9
@hansott hansott merged commit 5a97aab into main Jan 16, 2026
25 checks passed
@hansott hansott deleted the ipv4-mapped-ipv6 branch January 16, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants