fix: change servertailnet to register the DERP dialer before setting DERP map (#12137)

I noticed a possible race where tailnet.Conn can try to dial the embedded region before we've set our custom dialer that send the DERP in-memory.  This closes that race and adds a test case for servertailnet with no STUN and an embedded relay
This commit is contained in:
Spike Curtis
2024-02-15 10:51:12 +04:00
committed by GitHub
parent 1bb4aecf49
commit 2d0b9106c0
5 changed files with 81 additions and 34 deletions

View File

@ -116,9 +116,6 @@ func NewConn(options *Options) (conn *Conn, err error) {
if len(options.Addresses) == 0 {
return nil, xerrors.New("At least one IP range must be provided")
}
if options.DERPMap == nil {
return nil, xerrors.New("DERPMap must be provided")
}
nodePrivateKey := key.NewNode()
var nodeID tailcfg.NodeID
@ -219,7 +216,9 @@ func NewConn(options *Options) (conn *Conn, err error) {
magicConn.DiscoPublicKey(),
)
cfgMaps.setAddresses(options.Addresses)
cfgMaps.setDERPMap(options.DERPMap)
if options.DERPMap != nil {
cfgMaps.setDERPMap(options.DERPMap)
}
cfgMaps.setBlockEndpoints(options.BlockEndpoints)
nodeUp := newNodeUpdater(