From 70c1017bf493a206d7a67ec00a8def9d69df0649 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Sat, 2 Dec 2023 22:53:24 +0100 Subject: [PATCH] only check online status if offline Signed-off-by: Kristoffer Dalby --- hscontrol/poll.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hscontrol/poll.go b/hscontrol/poll.go index 5b2d526660..a07fda08de 100644 --- a/hscontrol/poll.go +++ b/hscontrol/poll.go @@ -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)