mirror of
https://github.com/juanfont/headscale.git
synced 2025-08-14 13:51:01 +02:00
policy/matcher: slices.ContainsFunc
Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
parent
93afb03f67
commit
15d9ef481b
@ -3,6 +3,8 @@ package matcher
|
|||||||
import (
|
import (
|
||||||
"net/netip"
|
"net/netip"
|
||||||
|
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/juanfont/headscale/hscontrol/util"
|
"github.com/juanfont/headscale/hscontrol/util"
|
||||||
"go4.org/netipx"
|
"go4.org/netipx"
|
||||||
"tailscale.com/tailcfg"
|
"tailscale.com/tailcfg"
|
||||||
@ -58,23 +60,11 @@ func MatchFromStrings(sources, destinations []string) Match {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *Match) SrcsContainsIPs(ips ...netip.Addr) bool {
|
func (m *Match) SrcsContainsIPs(ips ...netip.Addr) bool {
|
||||||
for _, ip := range ips {
|
return slices.ContainsFunc(ips, m.srcs.Contains)
|
||||||
if m.srcs.Contains(ip) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Match) DestsContainsIP(ips ...netip.Addr) bool {
|
func (m *Match) DestsContainsIP(ips ...netip.Addr) bool {
|
||||||
for _, ip := range ips {
|
return slices.ContainsFunc(ips, m.dests.Contains)
|
||||||
if m.dests.Contains(ip) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Match) SrcsOverlapsPrefixes(prefixes ...netip.Prefix) bool {
|
func (m *Match) SrcsOverlapsPrefixes(prefixes ...netip.Prefix) bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user