From 06c5390d894dcf2798207d8988dd51880e0331c1 Mon Sep 17 00:00:00 2001 From: Kristoffer Dalby Date: Fri, 2 May 2025 16:30:04 +0200 Subject: [PATCH] policy/matcher: slices.ContainsFunc, correct contains vs overlap Signed-off-by: Kristoffer Dalby --- hscontrol/policy/matcher/matcher.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/hscontrol/policy/matcher/matcher.go b/hscontrol/policy/matcher/matcher.go index ef29b171..ec07d19c 100644 --- a/hscontrol/policy/matcher/matcher.go +++ b/hscontrol/policy/matcher/matcher.go @@ -68,21 +68,9 @@ func (m *Match) DestsContainsIP(ips ...netip.Addr) bool { } func (m *Match) SrcsOverlapsPrefixes(prefixes ...netip.Prefix) bool { - for _, prefix := range prefixes { - if m.srcs.ContainsPrefix(prefix) { - return true - } - } - - return false + return slices.ContainsFunc(prefixes, m.srcs.OverlapsPrefix) } func (m *Match) DestsOverlapsPrefixes(prefixes ...netip.Prefix) bool { - for _, prefix := range prefixes { - if m.dests.ContainsPrefix(prefix) { - return true - } - } - - return false + return slices.ContainsFunc(prefixes, m.dests.OverlapsPrefix) }