mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-20 01:47:33 +00:00
ipn/ipnlocal,util/syspolicy/source: retain existing exit node when using auto exit node, if it's allowed by policy
In this PR, we update setExitNodeID to retain the existing exit node if auto exit node is enabled, the current exit node is allowed by policy, and no suggested exit node is available yet. Updates tailscale/corp#29969 Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
@@ -2026,7 +2026,20 @@ func mutationsAreWorthyOfTellingIPNBus(muts []netmap.NodeMutation) bool {
|
||||
// or resolve ExitNodeIP to an ID and use that. It returns whether prefs was mutated.
|
||||
func setExitNodeID(prefs *ipn.Prefs, suggestedExitNodeID tailcfg.StableNodeID, nm *netmap.NetworkMap) (prefsChanged bool) {
|
||||
if prefs.AutoExitNode.IsSet() {
|
||||
newExitNodeID := cmp.Or(suggestedExitNodeID, unresolvedExitNodeID)
|
||||
var newExitNodeID tailcfg.StableNodeID
|
||||
if !suggestedExitNodeID.IsZero() {
|
||||
// If we have a suggested exit node, use it.
|
||||
newExitNodeID = suggestedExitNodeID
|
||||
} else if isAllowedAutoExitNodeID(prefs.ExitNodeID) {
|
||||
// If we don't have a suggested exit node, but the prefs already
|
||||
// specify an allowed auto exit node ID, retain it.
|
||||
newExitNodeID = prefs.ExitNodeID
|
||||
} else {
|
||||
// Otherwise, use [unresolvedExitNodeID] to install a blackhole route,
|
||||
// preventing traffic from leaking to the local network until an actual
|
||||
// exit node is selected.
|
||||
newExitNodeID = unresolvedExitNodeID
|
||||
}
|
||||
if prefs.ExitNodeID != newExitNodeID {
|
||||
prefs.ExitNodeID = newExitNodeID
|
||||
prefsChanged = true
|
||||
|
Reference in New Issue
Block a user