Skip to content

Commit 41b64ee

Browse files
committed
fix: expired peer missing in peer list
1 parent 0eef9fa commit 41b64ee

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

internal/mapping/poll_net_mapper.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ func (h *PollNetMapper) CreateMapResponse(ctx context.Context, delta bool) (*Map
8989
syncedUserIDs := map[tailcfg.UserID]bool{user.ID: true}
9090

9191
for _, peer := range candidatePeers {
92-
if peer.IsExpired() {
93-
continue
94-
}
9592
if policies.IsValidPeer(m, &peer) || policies.IsValidPeer(&peer, m) {
9693
isConnected := h.sessionManager.HasSession(peer.TailnetID, peer.ID)
9794

tests/expired_peers_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package tests
2+
3+
import (
4+
"github.com/jsiebens/ionscale/tests/sc"
5+
"github.com/jsiebens/ionscale/tests/tsn"
6+
"github.com/stretchr/testify/require"
7+
"testing"
8+
)
9+
10+
func TestExpiredPeersShouldBeListed(t *testing.T) {
11+
sc.Run(t, func(s *sc.Scenario) {
12+
tailnet := s.CreateTailnet()
13+
key := s.CreateAuthKey(tailnet.Id, true)
14+
15+
nodeA := s.NewTailscaleNode()
16+
17+
require.NoError(t, nodeA.Up(key))
18+
19+
s.ExpireMachines(tailnet.Id)
20+
21+
nodeB := s.NewTailscaleNode()
22+
require.NoError(t, nodeB.Up(key))
23+
require.NoError(t, nodeB.Check(tsn.HasExpiredPeer(nodeA.Hostname())))
24+
})
25+
}

tests/sc/scenario.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ func (s *Scenario) AuthorizeMachines(tailnetID uint64) {
7777
}
7878
}
7979

80+
func (s *Scenario) ExpireMachines(tailnetID uint64) {
81+
machines := s.ListMachines(tailnetID)
82+
for _, m := range machines {
83+
_, err := s.ionscaleClient.ExpireMachine(context.Background(), connect.NewRequest(&api.ExpireMachineRequest{MachineId: m.Id}))
84+
require.NoError(s.t, err)
85+
}
86+
}
87+
8088
func (s *Scenario) SetACLPolicy(tailnetID uint64, policy *api.ACLPolicy) {
8189
_, err := s.ionscaleClient.SetACLPolicy(context.Background(), connect.NewRequest(&api.SetACLPolicyRequest{TailnetId: tailnetID, Policy: policy}))
8290
require.NoError(s.t, err)

tests/tsn/conditions.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ func PeerCount(expected int) Condition {
6666
}
6767
}
6868

69+
func HasExpiredPeer(name string) Condition {
70+
return func(status *ipnstate.Status) bool {
71+
for _, peer := range status.Peer {
72+
if strings.HasPrefix(peer.DNSName, name) {
73+
return peer.Expired
74+
}
75+
}
76+
return false
77+
}
78+
}
79+
6980
func HasCapability(capability tailcfg.NodeCapability) Condition {
7081
return func(status *ipnstate.Status) bool {
7182
self := status.Self

0 commit comments

Comments
 (0)