diff --git a/net/stun/stuntest/stuntest.go b/net/stun/stuntest/stuntest.go index e97accbb8..6015b9066 100644 --- a/net/stun/stuntest/stuntest.go +++ b/net/stun/stuntest/stuntest.go @@ -59,6 +59,7 @@ func runSTUN(t *testing.T, pc net.PacketConn, stats *stunStats, done chan<- stru for { n, addr, err := pc.ReadFrom(buf[:]) if err != nil { + // TODO: when we switch to Go 1.16, replace this with errors.Is(err, net.ErrClosed) if strings.Contains(err.Error(), "closed network connection") { t.Logf("STUN server shutdown") return diff --git a/tstest/natlab/natlab.go b/tstest/natlab/natlab.go index 7d1508afe..df2611be4 100644 --- a/tstest/natlab/natlab.go +++ b/tstest/natlab/natlab.go @@ -26,6 +26,7 @@ import ( "sync" "time" + wgconn "github.com/tailscale/wireguard-go/conn" "inet.af/netaddr" ) @@ -758,7 +759,8 @@ func (c *conn) canRead() error { c.mu.Lock() defer c.mu.Unlock() if c.closed { - return errors.New("closed network connection") // sadface: magic string used by other; don't change + // TODO: when we switch to Go 1.16, replace this with net.ErrClosed + return wgconn.NetErrClosed } if !c.readDeadline.IsZero() && c.readDeadline.Before(time.Now()) { return errors.New("read deadline exceeded")