[confighttp] Fix parseIP to support IPv6 addresses with zone IDs#14590
Open
RoryGlenn wants to merge 1 commit intoopen-telemetry:mainfrom
Open
[confighttp] Fix parseIP to support IPv6 addresses with zone IDs#14590RoryGlenn wants to merge 1 commit intoopen-telemetry:mainfrom
RoryGlenn wants to merge 1 commit intoopen-telemetry:mainfrom
Conversation
Use netip.ParseAddr instead of net.ParseIP to correctly handle IPv6 addresses with zone identifiers (e.g., fe80::1%eth0). net.ParseIP does not support zone IDs, causing parseIP to return nil for link-local IPv6 connections with zones, leaving client.Info.Addr unset. Fixes open-telemetry#14545 Assisted-by: Claude Opus 4
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.
Description
Fix
parseIPinconfig/confighttpto correctly handle IPv6 addresses with zone identifiers (e.g.,fe80::1%eth0).The previous implementation used
net.ParseIP, which does not support zone IDs in IPv6 addresses. When a client connects using a link-local IPv6 address with a zone (common for%eth0,%en0, etc.),parseIPreturnednil, leavingclient.Info.Addrunset in the request context.This fix replaces
net.ParseIPwithnetip.ParseAddrfrom thenet/netippackage, which correctly handles IPv6 zone identifiers. TheZonefield is now properly propagated to the returned*net.IPAddr.Link to tracking issue
Fixes #14545
Testing
TestParseIPtest cases to use the canonical 4-byte IPv4 representation returned bynetip.ParseAddr::1)[::1]:12345)fe80::1%eth0)[fe80::1%eth0]:12345)TestContextWithClientexpectation to match the 4-byte IPv4 formconfig/confighttptests passDocumentation
No documentation changes needed.