1
0
mirror of https://github.com/juanfont/headscale.git synced 2025-08-10 13:46:46 +02:00

policy/matcher: slices.ContainsFunc

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2025-05-02 16:29:44 +02:00
parent 93afb03f67
commit 15d9ef481b
No known key found for this signature in database

View File

@ -3,6 +3,8 @@ package matcher
import (
"net/netip"
"slices"
"github.com/juanfont/headscale/hscontrol/util"
"go4.org/netipx"
"tailscale.com/tailcfg"
@ -58,23 +60,11 @@ func MatchFromStrings(sources, destinations []string) Match {
}
func (m *Match) SrcsContainsIPs(ips ...netip.Addr) bool {
for _, ip := range ips {
if m.srcs.Contains(ip) {
return true
}
}
return false
return slices.ContainsFunc(ips, m.srcs.Contains)
}
func (m *Match) DestsContainsIP(ips ...netip.Addr) bool {
for _, ip := range ips {
if m.dests.Contains(ip) {
return true
}
}
return false
return slices.ContainsFunc(ips, m.dests.Contains)
}
func (m *Match) SrcsOverlapsPrefixes(prefixes ...netip.Prefix) bool {