update currentRoutes when set is used on tailscale cli

This commit is contained in:
Fran Bull committed 2024-03-15 11:39:10 -07:00
1 parent 28bba7b3db
commit 7fa9bf10dd
2 files changed
+16

No files matched your search

+7
View File
@@ -3223,6 +3223,13 @@ func (b *LocalBackend) setPrefsLockedOnEntry(caller string, newp *ipn.Prefs) ipn
if oldp.Valid() {
newp.Persist = oldp.Persist().AsStruct() // caller isn't allowed to override this
}
// we believe that for the purpose of figuring out advertisedRoutes setPrefsLockedOnEntry is _only_ called when
// up or set is used on the tailscale cli _not_ when we calculate the new advertisedRoutes field.
routeInfo := b.pm.CurrentRoutes()
routeInfo.Local = newp.AdvertiseRoutes
b.pm.SetCurrentRoutes(routeInfo)
//newp.AdvertiseRoutes = b.pm.CurrentRoutes.AsArray() (sort of thing)
// setExitNodeID returns whether it updated b.prefs, but
// everything in this function treats b.prefs as completely new
// anyway. No-op if no exit node resolution is needed.
+9
View File
@@ -47,6 +47,15 @@ func (pm *profileManager) dlogf(format string, args ...any) {
pm.logf(format, args...)
}
func (pm *profileManager) CurrentRoutes() *ipn.RouteInfo {
return pm.currentRoutes
}
func (pm *profileManager) SetCurrentRoutes(in *ipn.RouteInfo) error {
pm.currentRoutes = in
return pm.WriteRoutesForCurrentProfile()
}
func (pm *profileManager) WriteState(id ipn.StateKey, val []byte) error {
return ipn.WriteState(pm.store, id, val)
}