syspolicy: add exit node related policies (#10172)

Adds policy keys ExitNodeID and ExitNodeIP.
Uses the policy keys to determine the exit node in preferences.
Fixes tailscale/corp#15683

Signed-off-by: Claire Wang <claire@tailscale.com>
This commit is contained in:
Claire Wang
2023-11-29 16:48:25 -05:00
committed by GitHub
parent ecd1ccb917
commit 8af503b0c5
6 changed files with 311 additions and 15 deletions

View File

@@ -6,6 +6,7 @@ package syspolicy
import (
"errors"
"sync/atomic"
"testing"
)
var (
@@ -56,3 +57,10 @@ func RegisterHandler(h Handler) {
panic("handler was already used before registration")
}
}
func SetHandlerForTest(tb testing.TB, h Handler) {
tb.Helper()
oldHandler := handler
handler = h
tb.Cleanup(func() { handler = oldHandler })
}