Skip to content

Commit 298655b

Browse files
committed
fixup! add auth to in-memory coordinator
1 parent 5660e03 commit 298655b

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

tailnet/configmaps.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (c *configMaps) peerConfigLocked() []*tailcfg.Node {
231231
return out
232232
}
233233

234-
func (c *configMaps) setTunnelDestinaion(id uuid.UUID) {
234+
func (c *configMaps) setTunnelDestination(id uuid.UUID) {
235235
c.L.Lock()
236236
defer c.L.Unlock()
237237
lc, ok := c.peers[id]
@@ -542,10 +542,12 @@ func (c *configMaps) peerLostTimeout(id uuid.UUID) {
542542
"timeout triggered for peer that is removed from the map")
543543
return
544544
}
545-
if peerStatus, ok := status.Peer[lc.node.Key]; ok {
546-
lc.lastHandshake = peerStatus.LastHandshake
545+
if lc.node != nil {
546+
if peerStatus, ok := status.Peer[lc.node.Key]; ok {
547+
lc.lastHandshake = peerStatus.LastHandshake
548+
}
549+
logger = logger.With(slog.F("key_id", lc.node.Key.ShortString()))
547550
}
548-
logger = logger.With(slog.F("key_id", lc.node.Key.ShortString()))
549551
if !lc.lost {
550552
logger.Debug(context.Background(),
551553
"timeout triggered for peer that is no longer lost")
@@ -588,7 +590,7 @@ func (c *configMaps) nodeAddresses(publicKey key.NodePublic) ([]netip.Prefix, bo
588590
c.L.Lock()
589591
defer c.L.Unlock()
590592
for _, lc := range c.peers {
591-
if lc.node.Key == publicKey {
593+
if lc.node != nil && lc.node.Key == publicKey {
592594
return lc.node.Addresses, true
593595
}
594596
}
@@ -608,12 +610,16 @@ func (c *configMaps) fillPeerDiagnostics(d *PeerDiagnostics, peerID uuid.UUID) {
608610
if !ok {
609611
return
610612
}
613+
611614
d.ReceivedNode = lc.node
612-
ps, ok := status.Peer[lc.node.Key]
613-
if !ok {
614-
return
615+
if lc.node != nil {
616+
ps, ok := status.Peer[lc.node.Key]
617+
if !ok {
618+
return
619+
}
620+
d.LastWireguardHandshake = ps.LastHandshake
615621
}
616-
d.LastWireguardHandshake = ps.LastHandshake
622+
return
617623
}
618624

619625
func (c *configMaps) peerReadyForHandshakeTimeout(peerID uuid.UUID) {
@@ -638,9 +644,9 @@ type peerLifecycle struct {
638644
peerID uuid.UUID
639645
// isDestination specifies if the peer is a destination, meaning we
640646
// initiated a tunnel to the peer. When the peer is a destination, we do not
641-
// respond to node updates with READY_FOR_HANDSHAKEs, and we wait to program
642-
// the peer into wireguard until we receive a READY_FOR_HANDSHAKE from the
643-
// peer or the timeout is reached.
647+
// respond to node updates with `READY_FOR_HANDSHAKE`s, and we wait to
648+
// program the peer into wireguard until we receive a READY_FOR_HANDSHAKE
649+
// from the peer or the timeout is reached.
644650
isDestination bool
645651
// node is the tailcfg.Node for the peer. It may be nil until we receive a
646652
// NODE update for it.

tailnet/configmaps_internal_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func TestConfigMaps_updatePeers_new_waitForHandshake_neverConfigures(t *testing.
204204
p1Node := newTestNode(1)
205205
p1n, err := NodeToProto(p1Node)
206206
require.NoError(t, err)
207-
uut.setTunnelDestinaion(p1ID)
207+
uut.setTunnelDestination(p1ID)
208208

209209
// it should not send the peer to the netmap
210210
requireNeverConfigures(ctx, t, &uut.phased)
@@ -250,7 +250,7 @@ func TestConfigMaps_updatePeers_new_waitForHandshake_outOfOrder(t *testing.T) {
250250
p1Node := newTestNode(1)
251251
p1n, err := NodeToProto(p1Node)
252252
require.NoError(t, err)
253-
uut.setTunnelDestinaion(p1ID)
253+
uut.setTunnelDestination(p1ID)
254254

255255
go func() {
256256
<-fEng.status
@@ -323,7 +323,7 @@ func TestConfigMaps_updatePeers_new_waitForHandshake(t *testing.T) {
323323
p1Node := newTestNode(1)
324324
p1n, err := NodeToProto(p1Node)
325325
require.NoError(t, err)
326-
uut.setTunnelDestinaion(p1ID)
326+
uut.setTunnelDestination(p1ID)
327327

328328
go func() {
329329
<-fEng.status
@@ -396,7 +396,7 @@ func TestConfigMaps_updatePeers_new_waitForHandshake_timeout(t *testing.T) {
396396
p1Node := newTestNode(1)
397397
p1n, err := NodeToProto(p1Node)
398398
require.NoError(t, err)
399-
uut.setTunnelDestinaion(p1ID)
399+
uut.setTunnelDestination(p1ID)
400400

401401
go func() {
402402
<-fEng.status

tailnet/conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ type Conn struct {
312312
}
313313

314314
func (c *Conn) SetTunnelDestination(id uuid.UUID) {
315-
c.configMaps.setTunnelDestinaion(id)
315+
c.configMaps.setTunnelDestination(id)
316316
}
317317

318318
func (c *Conn) GetBlockEndpoints() bool {

0 commit comments

Comments
 (0)