Repository navigation
fix(network): read IPv6 addresses that end in an IPv4 address - #63
Open
VISHNU0906 wants to merge 1 commit into
Open
VISHNU0906 wants to merge 1 commit into
VISHNU0906 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
IPv6 lets the last 32 bits be written as an IPv4 address (RFC 4291 section 2.2), and that is how IPv4-mapped addresses usually show up in logs and socket output:
::ffff:192.168.1.1. Expand IPv6, Compress IPv6, Parse IPv6 address and IPv6 transition addresses all rejected that form ('192.168.1.1' is not a valid IPv6 group.), so the transition operation could not read the very address it describes unless it was rewritten as::ffff:c0a8:101first.Both IPv6 parsers (
network.tsandpackets.ts) now turn a trailing dotted IPv4 address into its two hex groups before splitting, and still refuse an octet above 255. Output is unchanged: the address comes back as hex groups, the same as before for the hex spelling.Related issue
none
How it was tested
New cases, both fail on main:
operations.verified.test.ts:::ffff:192.168.1.1expands to0000:0000:0000:0000:0000:ffff:c0a8:0101,64:ff9b:0:0:0:0:192.0.2.33compresses to64:ff9b::c000:221(the same values Python'sipaddressreads), and::ffff:192.168.1.256is refused.packets.test.ts: IPv6 to IPv4 on::ffff:192.168.0.1givesIPv4-mapped address of 192.168.0.1, and Parse IPv6 address shows the full form of::ffff:10.0.0.1.I also compared Expand/Compress against
ipaddresson about 60 addresses (random zero runs,::,1::,::1.2.3.4); on main the only mismatches were the four dotted ones, which it refused.Locally on Node 24 and Node 22:
npm run lint,npm run typecheck,npm run test -- --run,npm run buildandnpm run check:sdk-dist, plus the CI Chrome load check, the GraalJS Java provider checks andnpm audit --audit-level=high.Checklist
npm run lint,npm run typecheck,npm run testandnpm run buildall pass locallyanyintroduced in application codeeval,new Function,dangerouslySetInnerHTML, orinnerHTMLassignment