From efe6d5e2e3851ceb6211b3d062f6de39c3c61656 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Mon, 27 Nov 2023 17:27:48 +0100 Subject: [PATCH] clean up logging, populate online for change Signed-off-by: Kristoffer Dalby --- hscontrol/mapper/tail.go | 11 ----------- hscontrol/poll.go | 18 ++++++++---------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/hscontrol/mapper/tail.go b/hscontrol/mapper/tail.go index dc500cbfc5f..6aa688ad93c 100644 --- a/hscontrol/mapper/tail.go +++ b/hscontrol/mapper/tail.go @@ -9,7 +9,6 @@ import ( "github.com/juanfont/headscale/hscontrol/policy" "github.com/juanfont/headscale/hscontrol/types" "github.com/juanfont/headscale/hscontrol/util" - "github.com/rs/zerolog/log" "github.com/samber/lo" "tailscale.com/tailcfg" ) @@ -91,16 +90,6 @@ func tailNode( return nil, fmt.Errorf("tailNode, failed to create FQDN: %s", err) } - if node.IsOnline != nil { - if *node.IsOnline { - log.Trace().Msgf("NODE IS ONLINE %s", node.Hostname) - } else { - log.Trace().Msgf("NODE IS NOT ONLINE %s", node.Hostname) - } - } else { - log.Trace().Msgf("NODE IS ONLINE IS NIL %s", node.Hostname) - } - tags, _ := pol.TagsOfNode(node) tags = lo.Uniq(append(tags, node.ForcedTags...)) diff --git a/hscontrol/poll.go b/hscontrol/poll.go index a1a01b43ebc..dfbfefe3ba5 100644 --- a/hscontrol/poll.go +++ b/hscontrol/poll.go @@ -348,27 +348,25 @@ func (h *Headscale) handlePoll( case types.StateFullUpdate: logInfo("Sending Full MapResponse") - log.Trace().Msgf("NODE FULLMAP BEGIN %s", node.Hostname) - - // TODO(kradalby): We need to update online status in this case data, err = mapp.FullMapResponse(mapRequest, node, h.ACLPolicy) - log.Trace().Msgf("NODE FULLMAP END %s", node.Hostname) case types.StatePeerChanged: logInfo("Sending Changed MapResponse") - log.Trace().Msgf("NODE CHANGEDMAP BEGIN %s", node.Hostname) + for _, node := range update.ChangeNodes { + isOnline := h.nodeNotifier.IsConnected(node.MachineKey) + node.IsOnline = &isOnline + } - // TODO(kradalby): We need to update online status in this case data, err = mapp.PeerChangedResponse(mapRequest, node, update.ChangeNodes, h.ACLPolicy) - log.Trace().Msgf("NODE CHANGEDMAP END %s", node.Hostname) case types.StatePeerChangedNoPolicy: logInfo("Sending PeerChangedWithoutACL MapResponse") - log.Trace().Msgf("NODE PATCHMAP BEGIN %s", node.Hostname) + for _, node := range update.ChangeNodes { + isOnline := h.nodeNotifier.IsConnected(node.MachineKey) + node.IsOnline = &isOnline + } - // TODO(kradalby): We need to update online status in this case data, err = mapp.PeerChangedWithoutACLResponse(mapRequest, node, update.ChangeNodes, h.ACLPolicy) - log.Trace().Msgf("NODE PATCHMAP BEGIN %s", node.Hostname) case types.StatePeerChangedPatch: logInfo("Sending PeerChangedPatch MapResponse") data, err = mapp.PeerChangedPatchResponse(mapRequest, node, update.ChangePatches, h.ACLPolicy)