]> Cypherpunks repositories - gostls13.git/commitdiff
net: fix TestDialerLocalAddr on Plan 9
authorFazlul Shahriar <fshahriar@gmail.com>
Mon, 29 Jun 2020 23:22:34 +0000 (19:22 -0400)
committerDavid du Colombier <0intro@gmail.com>
Tue, 30 Jun 2020 13:18:16 +0000 (13:18 +0000)
We cannot use "0.0.0.0" (IPv4) or "::" (IPv6) for local address, so
don't use those addresses in the control message. Alternatively, we
could've used "*" instead.

Fixes #39931

Change-Id: Ib2dcbb1a0c648296c3ecaddbe938053a569b1f1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/240464
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
src/net/ipsock_plan9.go

index a5d722d3a1e378c5ee91f947bff3004032a9379d..9db01b090d5b8c45b106f7afe91ffa4641eb8014 100644 (file)
@@ -311,25 +311,25 @@ func toLocal(a Addr, net string) Addr {
 // plan9LocalAddr returns a Plan 9 local address string.
 // See setladdrport at https://9p.io/sources/plan9/sys/src/9/ip/devip.c.
 func plan9LocalAddr(addr Addr) string {
-       ip := ""
+       var ip IP
        port := 0
        switch a := addr.(type) {
        case *TCPAddr:
                if a != nil {
-                       ip = ipEmptyString(a.IP)
+                       ip = a.IP
                        port = a.Port
                }
        case *UDPAddr:
                if a != nil {
-                       ip = ipEmptyString(a.IP)
+                       ip = a.IP
                        port = a.Port
                }
        }
-       if ip == "" {
+       if len(ip) == 0 || ip.IsUnspecified() {
                if port == 0 {
                        return ""
                }
                return itoa(port)
        }
-       return ip + "!" + itoa(port)
+       return ip.String() + "!" + itoa(port)
 }