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