Przeglądaj źródła

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
Mikio Hara 11 lat temu
rodzic
commit
89143d4521
1 zmienionych plików z 3 dodań i 0 usunięć
  1. 3 0
      internal/nettest/interface.go

+ 3 - 0
internal/nettest/interface.go

@@ -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
 		}