mirror of
https://github.com/golang/go
synced 2024-11-11 22:40:22 -07:00
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>
This commit is contained in:
parent
c4fd3f6ff6
commit
4b28f5ded3
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user