From 78fe75e86cfa81e9ac5b21f506b50739d42b68b3 Mon Sep 17 00:00:00 2001 From: Lee Briggs Date: Thu, 6 Nov 2025 09:47:05 -0500 Subject: [PATCH] actually set the static endpoints Signed-off-by: Lee Briggs --- cmd/tailscale/cli/set.go | 1 + ipn/ipnlocal/local.go | 6 ++++++ ipn/prefs.go | 1 + wgengine/magicsock/magicsock.go | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/cmd/tailscale/cli/set.go b/cmd/tailscale/cli/set.go index 9ff543a87..162515f7c 100644 --- a/cmd/tailscale/cli/set.go +++ b/cmd/tailscale/cli/set.go @@ -205,6 +205,7 @@ func runSet(ctx context.Context, args []string) (retErr error) { endpoints = append(endpoints, ap) } maskedPrefs.Prefs.StaticEndpoints = endpoints + maskedPrefs.StaticEndpointsSet = true } warnOnAdvertiseRoutes(ctx, &maskedPrefs.Prefs) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 3865ad604..578cc8e49 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -4659,6 +4659,12 @@ func (b *LocalBackend) setPrefsLockedOnEntry(newp *ipn.Prefs, unlock unlockOnce) // Update static endpoints if they've changed if !oldp.Valid() || !slices.Equal(oldp.StaticEndpoints().AsSlice(), prefs.StaticEndpoints().AsSlice()) { if ms, ok := b.sys.MagicSock.GetOK(); ok { + endpoints := prefs.StaticEndpoints().AsSlice() + if len(endpoints) > 0 { + b.logf("Setting static endpoints: %v", endpoints) + } else { + b.logf("Clearing static endpoints") + } ms.SetStaticEndpoints(prefs.StaticEndpoints()) } } diff --git a/ipn/prefs.go b/ipn/prefs.go index 99c80f6c1..b3c287a81 100644 --- a/ipn/prefs.go +++ b/ipn/prefs.go @@ -679,6 +679,7 @@ func (p *Prefs) Equals(p2 *Prefs) bool { p.PostureChecking == p2.PostureChecking && slices.EqualFunc(p.DriveShares, p2.DriveShares, drive.SharesEqual) && p.NetfilterKind == p2.NetfilterKind && + slices.Equal(p.StaticEndpoints, p2.StaticEndpoints) && compareIntPtrs(p.RelayServerPort, p2.RelayServerPort) } diff --git a/wgengine/magicsock/magicsock.go b/wgengine/magicsock/magicsock.go index 658478901..f758ba570 100644 --- a/wgengine/magicsock/magicsock.go +++ b/wgengine/magicsock/magicsock.go @@ -1021,6 +1021,7 @@ func (c *Conn) SetStaticEndpoints(ep views.Slice[netip.AddrPort]) { c.mu.Unlock() return } + c.logf("magicsock: setting static endpoints: %v", ep.AsSlice()) c.staticEndpoints = ep c.mu.Unlock() // Technically this is not a reSTUNning, but ReSTUN does what we need at @@ -1363,6 +1364,10 @@ func (c *Conn) determineEndpoints(ctx context.Context) ([]tailcfg.Endpoint, erro // re-run. eps = c.endpointTracker.update(time.Now(), eps) + staticEpsSlice := c.staticEndpoints.AsSlice() + if len(staticEpsSlice) > 0 { + c.logf("magicsock: adding %d static endpoints: %v", len(staticEpsSlice), staticEpsSlice) + } for _, ep := range c.staticEndpoints.All() { addAddr(ep, tailcfg.EndpointExplicitConf) }