pires / go-proxyproto

A Go library implementation of the PROXY protocol, versions 1 and 2.
Apache License 2.0
478 stars 107 forks source link

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

Closed Freeaqingme closed 1 year ago

Freeaqingme commented 2 years ago

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.

coveralls commented 2 years ago

Coverage Status

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

pires commented 2 years ago

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