@ -1318,6 +1318,9 @@ func (c *Conn) derpWriteChanOfAddr(addr netip.AddrPort, peer key.NodePublic) cha
if ! c . wantDerpLocked ( ) || c . closed {
if ! c . wantDerpLocked ( ) || c . closed {
return nil
return nil
}
}
if c . derpMap == nil || c . derpMap . Regions [ regionID ] == nil {
return nil
}
if c . privateKey . IsZero ( ) {
if c . privateKey . IsZero ( ) {
c . logf ( "magicsock: DERP lookup of %v with no private key; ignoring" , addr )
c . logf ( "magicsock: DERP lookup of %v with no private key; ignoring" , addr )
return nil
return nil
@ -1362,9 +1365,6 @@ func (c *Conn) derpWriteChanOfAddr(addr netip.AddrPort, peer key.NodePublic) cha
c . activeDerp = make ( map [ int ] activeDerp )
c . activeDerp = make ( map [ int ] activeDerp )
c . prevDerp = make ( map [ int ] * syncs . WaitGroupChan )
c . prevDerp = make ( map [ int ] * syncs . WaitGroupChan )
}
}
if c . derpMap == nil || c . derpMap . Regions [ regionID ] == nil {
return nil
}
// Note that derphttp.NewRegionClient does not dial the server
// Note that derphttp.NewRegionClient does not dial the server
// (it doesn't block) so it is safe to do under the c.mu lock.
// (it doesn't block) so it is safe to do under the c.mu lock.