From 74b4f7f2595d2e2c7bea37e513a45b02a06403a0 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Wed, 16 Apr 2025 11:19:35 +0200 Subject: [PATCH] policy/v1: slices.Contains Signed-off-by: Kristoffer Dalby --- hscontrol/policy/v1/policy.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hscontrol/policy/v1/policy.go b/hscontrol/policy/v1/policy.go index 06558927..89625ce3 100644 --- a/hscontrol/policy/v1/policy.go +++ b/hscontrol/policy/v1/policy.go @@ -7,6 +7,8 @@ import ( "os" "sync" + "slices" + "github.com/juanfont/headscale/hscontrol/types" "github.com/rs/zerolog/log" "tailscale.com/tailcfg" @@ -145,13 +147,7 @@ func (pm *PolicyManager) NodeCanHaveTag(node *types.Node, tag string) bool { tags, invalid := pm.pol.TagsOfNode(pm.users, node) log.Debug().Strs("authorised_tags", tags).Strs("unauthorised_tags", invalid).Uint64("node.id", node.ID.Uint64()).Msg("tags provided by policy") - for _, t := range tags { - if t == tag { - return true - } - } - - return false + return slices.Contains(tags, tag) } func (pm *PolicyManager) NodeCanApproveRoute(node *types.Node, route netip.Prefix) bool {