diff --git a/derp/derphttp/derphttp_client.go b/derp/derphttp/derphttp_client.go index 67e947754..f0448d250 100644 --- a/derp/derphttp/derphttp_client.go +++ b/derp/derphttp/derphttp_client.go @@ -96,7 +96,7 @@ func NewRegionClient(privateKey key.NodePrivate, logf logger.Logf, getRegion fun return c } -// NewNetcheckClient returns a Client that's only able to have its DialRegion method called. +// NewNetcheckClient returns a Client that's only able to have its DialRegionTLS method called. // It's used by the netcheck package. func NewNetcheckClient(logf logger.Logf) *Client { return &Client{logf: logf} @@ -985,7 +985,9 @@ func (c *Client) isClosed() bool { // Close closes the client. It will not automatically reconnect after // being closed. func (c *Client) Close() error { - c.cancelCtx() // not in lock, so it can cancel Connect, which holds mu + if c.cancelCtx != nil { + c.cancelCtx() // not in lock, so it can cancel Connect, which holds mu + } c.mu.Lock() defer c.mu.Unlock()