/ go Public
net: Unable to reliably distinguish IPv4-mapped-IPv6 addresses from regular IPv4 addresses #37921
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
What did you do?
What did you expect to see?
Some way to parse an IPv4 mapped IPv6 address (e.g.
::ffff:172.21.0.6) and know that it is an IPv4 mapped IPv6 address.
netpackage is bit prohibitive here, given that the
ParseIPmethod is pretty opinionated. See here:
What did you see instead?
For any given IPv4-mapped-IPv6 address IP, all the IP parsing in the
netpackage only indicate that the input is an IPv4 address.
This is also perhaps, further complicated by the internal representation of IPv4 addresses being 16 bytes, bearing the
However, if the user is using the
netpackage for IP sanitization/validation, not being able to tell the difference seems to be a shortcoming. In order to be implement this on my own, I had to copy/paste the
parseIPv6method from the
netpackage, and do something like the following:
I would propose here to expose the
parseIPv6methods. Exposing the Parse helpers would help multiple use-cases I'm sure, without increasing the API footprint significantly of the net package
For more parsing fun related to IPv4-mapped-IPv6 addresses, here's another instance where things look weird: https://play.golang.org/p/lsVp472VG4E
ipat this point is the 16 byte form, it does have the prefix, but then again any other IPv4 address would have as we see. However, we get an IPv6 network, which will leave the onus on the user to make sense of this result.
The text was updated successfully, but these errors were encountered: