x/net/internal/nettest: make routableIP not return the ipv6 loopback address

On some platform the IPv6 loopback address is not suitable to assign a name.

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/165710043
This commit is contained in:
Mikio Hara
2014-11-10 09:47:34 +09:00
parent fbe893ddcd
commit 89143d4521

View File

@@ -76,6 +76,9 @@ func routableIP(network string, ip net.IP) net.IP {
return ip
}
case "ip6":
if ip.IsLoopback() { // addressing scope of the loopback address depends on each implementation
return nil
}
if ip := ip.To16(); ip != nil && ip.To4() == nil {
return ip
}