Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net: Dial, Listen and ResolveAddr fail when the ipv6 entry in /etc/hosts has a zone identifier #8243
According to issue #8235, all connection setup and resolveaddr functions fail when the target is has an ipv6 scoped addressing zone identifier. For example, /etc/hosts localhost fe80::1%lo0 livingroom fe80::2%en1 garage fe80::2%en2 Listen("tcp6", "localhost:0)" Dial("tcp6", "livingloom:1234") ResolveTCPAddr("tcp", "garage:http")
To fix this issue, we need to handle zone identifier appropriately at; - cgoLookupIPCNAME in cgo_unix.go, fortunately getaddrinfo returns ipv6 address with zone identifier, - readHosts in hosts.go, it doesn't parse ipv6 address with zone identifier correctly, - resolveInternetAddr in ipsock.go and lookupIP in lookup.go, for now both functions drop ipv6 zone identifier.