Skip to content

Commit

Permalink
only check online status if offline
Browse files Browse the repository at this point in the history
Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Dec 2, 2023
1 parent 817fd3d commit 70c1017
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions hscontrol/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,15 @@ func (h *Headscale) handlePoll(
logInfo(fmt.Sprintf("Sending Changed MapResponse: %s", update.Message))

for _, node := range update.ChangeNodes {
isOnline := h.nodeNotifier.IsConnected(node.MachineKey)
node.IsOnline = &isOnline
// If a node is not reported to be online, it might be
// because the value is outdated, check with the notifier.
// However, if it is set to Online, and not in the notifier,
// this might be because it has announced itself, but not
// reached the stage to actually create the notifier channel.
if node.IsOnline != nil && !*node.IsOnline {
isOnline := h.nodeNotifier.IsConnected(node.MachineKey)
node.IsOnline = &isOnline
}
}

data, err = mapp.PeerChangedResponse(mapRequest, node, update.ChangeNodes, h.ACLPolicy, update.Message)
Expand Down

0 comments on commit 70c1017

Please sign in to comment.