Skip to content

Commit cae734d

Browse files
committed
fix no permission test
1 parent 2ee3c51 commit cae734d

File tree

5 files changed

+57
-62
lines changed

5 files changed

+57
-62
lines changed

tailnet/configmaps.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,9 @@ func (c *configMaps) updatePeerLocked(update *proto.CoordinateResponse_PeerUpdat
443443
lc.readyForHandshakeTimer.Stop()
444444
}
445445
if lc.node != nil {
446-
dirty = dirty || !lc.node.KeepAlive
447-
lc.node.KeepAlive = true
446+
old := lc.node.KeepAlive
447+
lc.node.KeepAlive = c.nodeKeepalive(lc, status, lc.node)
448+
dirty = dirty || (old != lc.node.KeepAlive)
448449
}
449450
logger.Debug(context.Background(), "peer ready for handshake")
450451
// only force a reconfig if the node populated
@@ -457,7 +458,6 @@ func (c *configMaps) updatePeerLocked(update *proto.CoordinateResponse_PeerUpdat
457458
logger.Debug(context.Background(), "got peer ready for handshake for unknown peer")
458459
lc = &peerLifecycle{
459460
peerID: id,
460-
lost: true,
461461
readyForHandshake: true,
462462
}
463463
c.peers[id] = lc
@@ -633,10 +633,6 @@ func (*configMaps) nodeKeepalive(lc *peerLifecycle, status *ipnstate.Status, nod
633633
if lc != nil && lc.isDestination && lc.readyForHandshake {
634634
return true
635635
}
636-
// If keepalives are already enabled on the node, keep them enabled.
637-
if lc != nil && lc.node != nil && lc.node.KeepAlive {
638-
return true
639-
}
640636

641637
// If none of the above are true, keepalives should not be enabled.
642638
return false

tailnet/coordinator.go

+7
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,13 @@ func (c *core) handleReadyForHandshakeLocked(src *peer, rfhs []*proto.Coordinate
722722
// subsequently disconnect before the agent has sent back the RFH.
723723
// Since this could potentially happen to a non-malicious agent, we
724724
// don't want to kill its connection.
725+
select {
726+
case src.resps <- &proto.CoordinateResponse{
727+
Error: fmt.Sprintf("you do not share a tunnel with %q", dstID.String()),
728+
}:
729+
default:
730+
return ErrWouldBlock
731+
}
725732
continue
726733
}
727734

tailnet/coordinator_test.go

+3-21
Original file line numberDiff line numberDiff line change
@@ -464,33 +464,15 @@ func TestCoordinator(t *testing.T) {
464464
clientID := uuid.New()
465465
agentID := uuid.New()
466466

467-
aReq, _ := coordinator.Coordinate(ctx, agentID, agentID.String(), tailnet.AgentCoordinateeAuth{ID: agentID})
467+
aReq, aRes := coordinator.Coordinate(ctx, agentID, agentID.String(), tailnet.AgentCoordinateeAuth{ID: agentID})
468468
_, _ = coordinator.Coordinate(ctx, clientID, clientID.String(), tailnet.ClientCoordinateeAuth{AgentID: agentID})
469469

470-
nk, err := key.NewNode().Public().MarshalBinary()
471-
require.NoError(t, err)
472-
dk, err := key.NewDisco().Public().MarshalText()
473-
require.NoError(t, err)
474-
aReq <- &proto.CoordinateRequest{UpdateSelf: &proto.CoordinateRequest_UpdateSelf{
475-
Node: &proto.Node{
476-
Id: 3,
477-
Key: nk,
478-
Disco: string(dk),
479-
},
480-
}}
481-
482-
require.Eventually(t, func() bool {
483-
return coordinator.Node(agentID) != nil
484-
}, testutil.WaitShort, testutil.IntervalFast)
485-
486470
aReq <- &proto.CoordinateRequest{ReadyForHandshake: []*proto.CoordinateRequest_ReadyForHandshake{{
487471
Id: clientID[:],
488472
}}}
489473

490-
// The agent node should disappear, indicating it was booted off.
491-
require.Eventually(t, func() bool {
492-
return coordinator.Node(agentID) == nil
493-
}, testutil.WaitShort, testutil.IntervalFast)
474+
rfhError := testutil.RequireRecvCtx(ctx, t, aRes)
475+
require.NotEmpty(t, rfhError.Error)
494476
})
495477
}
496478

tailnet/proto/tailnet.pb.go

+43-34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tailnet/proto/tailnet.proto

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ message CoordinateResponse {
9696
string reason = 4;
9797
}
9898
repeated PeerUpdate peer_updates = 1;
99+
string error = 2;
99100
}
100101

101102
service Tailnet {

0 commit comments

Comments
 (0)