Skip to content

Commit d9c3eaf

Browse files
committed
matcher: Add func for comparing Dests and TheInternet
Signed-off-by: Kristoffer Dalby <[email protected]>
1 parent bd9cf42 commit d9c3eaf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

hscontrol/policy/matcher/matcher.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/juanfont/headscale/hscontrol/util"
99
"go4.org/netipx"
10+
"tailscale.com/net/tsaddr"
1011
"tailscale.com/tailcfg"
1112
)
1213

@@ -91,3 +92,12 @@ func (m *Match) SrcsOverlapsPrefixes(prefixes ...netip.Prefix) bool {
9192
func (m *Match) DestsOverlapsPrefixes(prefixes ...netip.Prefix) bool {
9293
return slices.ContainsFunc(prefixes, m.dests.OverlapsPrefix)
9394
}
95+
96+
// DestsIsTheInternet reports if the destination is equal to "the internet"
97+
// which is a IPSet that represents "autogroup:internet" and is special
98+
// cased for exit nodes.
99+
func (m Match) DestsIsTheInternet() bool {
100+
return m.dests.Equal(util.TheInternet()) ||
101+
m.dests.ContainsPrefix(tsaddr.AllIPv4()) ||
102+
m.dests.ContainsPrefix(tsaddr.AllIPv6())
103+
}

0 commit comments

Comments
 (0)