net: fix TestDialerLocalAddr on Plan 9
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>
diff --git a/src/net/ipsock_plan9.go b/src/net/ipsock_plan9.go
index a5d722d..9db01b0 100644
--- a/src/net/ipsock_plan9.go
+++ b/src/net/ipsock_plan9.go
@@ -311,25 +311,25 @@
// 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)
}