mirror of
https://github.com/jsiebens/ionscale.git
synced 2026-03-31 15:07:49 +01:00
fix: expired peer missing in peer list
This commit is contained in:
@@ -89,9 +89,6 @@ func (h *PollNetMapper) CreateMapResponse(ctx context.Context, delta bool) (*Map
|
||||
syncedUserIDs := map[tailcfg.UserID]bool{user.ID: true}
|
||||
|
||||
for _, peer := range candidatePeers {
|
||||
if peer.IsExpired() {
|
||||
continue
|
||||
}
|
||||
if policies.IsValidPeer(m, &peer) || policies.IsValidPeer(&peer, m) {
|
||||
isConnected := h.sessionManager.HasSession(peer.TailnetID, peer.ID)
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"github.com/jsiebens/ionscale/tests/sc"
|
||||
"github.com/jsiebens/ionscale/tests/tsn"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExpiredPeersShouldBeListed(t *testing.T) {
|
||||
sc.Run(t, func(s *sc.Scenario) {
|
||||
tailnet := s.CreateTailnet()
|
||||
key := s.CreateAuthKey(tailnet.Id, true)
|
||||
|
||||
nodeA := s.NewTailscaleNode()
|
||||
|
||||
require.NoError(t, nodeA.Up(key))
|
||||
|
||||
s.ExpireMachines(tailnet.Id)
|
||||
|
||||
nodeB := s.NewTailscaleNode()
|
||||
require.NoError(t, nodeB.Up(key))
|
||||
require.NoError(t, nodeB.Check(tsn.HasExpiredPeer(nodeA.Hostname())))
|
||||
})
|
||||
}
|
||||
@@ -77,6 +77,14 @@ func (s *Scenario) AuthorizeMachines(tailnetID uint64) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scenario) ExpireMachines(tailnetID uint64) {
|
||||
machines := s.ListMachines(tailnetID)
|
||||
for _, m := range machines {
|
||||
_, err := s.ionscaleClient.ExpireMachine(context.Background(), connect.NewRequest(&api.ExpireMachineRequest{MachineId: m.Id}))
|
||||
require.NoError(s.t, err)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Scenario) SetACLPolicy(tailnetID uint64, policy *api.ACLPolicy) {
|
||||
_, err := s.ionscaleClient.SetACLPolicy(context.Background(), connect.NewRequest(&api.SetACLPolicyRequest{TailnetId: tailnetID, Policy: policy}))
|
||||
require.NoError(s.t, err)
|
||||
|
||||
@@ -66,6 +66,17 @@ func PeerCount(expected int) Condition {
|
||||
}
|
||||
}
|
||||
|
||||
func HasExpiredPeer(name string) Condition {
|
||||
return func(status *ipnstate.Status) bool {
|
||||
for _, peer := range status.Peer {
|
||||
if strings.HasPrefix(peer.DNSName, name) {
|
||||
return peer.Expired
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
func HasCapability(capability tailcfg.NodeCapability) Condition {
|
||||
return func(status *ipnstate.Status) bool {
|
||||
self := status.Self
|
||||
|
||||
Reference in New Issue
Block a user