mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-15 07:27:30 +00:00
tailcfg: add Hostinfo.ExitNodeID to report the selected exit node (#16625)
When a client selects a particular exit node, Control may use that as a signal for deciding other routes. This patch causes the client to report whenever the current exit node changes, through tailcfg.Hostinfo.ExitNodeID. It relies on a properly set ipn.Prefs.ExitNodeID, which should already be resolved by `tailscale set`. Updates tailscale/corp#30536 Signed-off-by: Simon Law <sfllaw@tailscale.com>
This commit is contained in:
@@ -5612,6 +5612,11 @@ func (b *LocalBackend) applyPrefsToHostinfoLocked(hi *tailcfg.Hostinfo, prefs ip
|
||||
// WireIngress.
|
||||
hi.WireIngress = b.shouldWireInactiveIngressLocked()
|
||||
hi.AppConnector.Set(prefs.AppConnector().Advertise)
|
||||
|
||||
// The [tailcfg.Hostinfo.ExitNodeID] field tells control which exit node
|
||||
// was selected, if any. Since [LocalBackend.resolveExitNodeIPLocked]
|
||||
// has already run, there is no need to consult [ipn.Prefs.ExitNodeIP].
|
||||
hi.ExitNodeID = prefs.ExitNodeID()
|
||||
}
|
||||
|
||||
// enterState transitions the backend into newState, updating internal
|
||||
@@ -6136,6 +6141,10 @@ func (b *LocalBackend) resolveExitNode() (changed bool) {
|
||||
}); err != nil {
|
||||
b.logf("failed to save exit node changes: %v", err)
|
||||
}
|
||||
|
||||
// Send the resolved exit node to Control via Hostinfo.
|
||||
b.hostinfo.ExitNodeID = prefs.ExitNodeID
|
||||
|
||||
b.sendToLocked(ipn.Notify{Prefs: ptr.To(prefs.View())}, allClients)
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user