wgengine/magicsock: reduce log spam during tests

Only do the type assertion to *net.UDPAddr when addr is non-nil.
This prevents a bunch of log spam during tests.
This commit is contained in:
Josh Bleecher Snyder 2021-02-12 10:17:55 -08:00 committed by Josh Bleecher Snyder
parent 88586ec4a4
commit 1632f9fd6b

View File

@ -2775,12 +2775,13 @@ func (c *RebindingUDPConn) ReadFromNetaddr(b []byte) (n int, ipp netaddr.IPPort,
} else { } else {
var addr net.Addr var addr net.Addr
n, addr, err = pconn.ReadFrom(b) n, addr, err = pconn.ReadFrom(b)
var ok2 bool if addr != nil {
pAddr, ok2 = addr.(*net.UDPAddr) pAddr, ok = addr.(*net.UDPAddr)
if !ok2 { if !ok {
return 0, netaddr.IPPort{}, fmt.Errorf("RebindingUDPConn.ReadFromNetaddr: underlying connection returned address of type %T, want *netaddr.UDPAddr", addr) return 0, netaddr.IPPort{}, fmt.Errorf("RebindingUDPConn.ReadFromNetaddr: underlying connection returned address of type %T, want *netaddr.UDPAddr", addr)
} }
} }
}
if err != nil { if err != nil {
c.mu.Lock() c.mu.Lock()