actually set the static endpoints

Signed-off-by: Lee Briggs <lee@leebriggs.co.uk>
jaxxstorm/static_endpoints
Lee Briggs 1 month ago
parent 9e2df8093f
commit 78fe75e86c
No known key found for this signature in database
GPG Key ID: A4D09B96FDFEB505

@ -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)

@ -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())
}
}

@ -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)
}

@ -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)
}

Loading…
Cancel
Save