go-proxyproto icon indicating copy to clipboard operation
go-proxyproto copied to clipboard

Allow IPv6 compat addresses (4in6) when parsing TCPv6 in V1 header

Open Freeaqingme opened this issue 2 years ago • 2 comments

This is a follow-up on MR #49 by @emersion . All credits should go to him :)

I had a need to parse 4in6 addresses myself as well, so I took his MR as a starting point and took it from there. I have not yet tested this code in production, but I figured I'd already turn it into a PR.

There is one issue that I had to sort of work around: In the default net.IP library, an IPv4 address is (or can be) stored more or less in the same way an IPv6 address is stored with a ::FFFF: prefix. As such, there's no way to make a distinction based on a net.IP object if it was an IPv4 address, or IPv6 4in6 address.

Freeaqingme avatar Apr 29 '22 20:04 Freeaqingme

Coverage Status

Coverage decreased (-0.4%) to 95.16% when pulling 129dcf86e10569d10f0078000ab8de5d7e9ebc61 on Freeaqingme:master into 1966d35336fbd6e5f4204453c6a269d16e01b027 on pires:main.

coveralls avatar Apr 29 '22 20:04 coveralls

Maybe it's a good time to introduce https://pkg.go.dev/net/netip#Addr.Is4In6?

pires avatar May 02 '22 11:05 pires