Skip to content

fix: server propagation, settings atomicity, and config defects#511

Merged
garmr-ulfr merged 4 commits into
mainfrom
fix-server-config-defects
Jun 5, 2026
Merged

fix: server propagation, settings atomicity, and config defects#511
garmr-ulfr merged 4 commits into
mainfrom
fix-server-config-defects

Conversation

@garmr-ulfr
Copy link
Copy Markdown
Collaborator

@garmr-ulfr garmr-ulfr commented Jun 5, 2026

Summary

Independent, self-contained defect fixes:

  • servers: AddServersByJSON/AddServersByURL now propagate added servers to a running tunnel — they return the added *ServerList and call AddOutbounds (ignoring ErrTunnelNotConnected), matching AddServers. Previously the servers were persisted but never pushed to the live tunnel.
  • settings: Set/Clear/Patch hold k.mu across the full mutate+save, closing a lost-update window between concurrent writers. ClearUser clears all user keys in a single atomic Clear, so logout is all-or-nothing rather than seven separate saves.
  • vpn: removed the discarded newSplitTunnel(...) construction in NewVPNClient; the rule-set file is ensured where it's consumed.
  • backend: setServers clears a stale server selection while disconnected; removed a dead location-picker loop (its entries were written to a map only ever read by tag) and nil-guarded the per-server location lookup.

- servers: propagate AddServersByJSON/ByURL to the running tunnel —
  return the added ServerList and call AddOutbounds (ignoring
  ErrTunnelNotConnected), matching AddServers.
- settings: hold the lock across the full mutate+save in Set/Clear/Patch
  so concurrent writers can't lose updates; ClearUser clears all user
  keys in one atomic Clear.
- vpn: drop the discarded newSplitTunnel construction in NewVPNClient;
  the rule-set file is ensured where it's consumed.
- backend: clear a stale server selection in setServers while
  disconnected; remove the dead location-picker loop and nil-guard the
  per-server location lookup.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR delivers several targeted defect fixes across server management, settings persistence, VPN split-tunnel setup, and backend server/location handling—primarily to ensure runtime state stays consistent with persisted configuration and to remove dead/ineffective logic.

Changes:

  • Propagate servers added via JSON/URL to the live tunnel by returning the added ServerList and pushing outbounds (ignoring ErrTunnelNotConnected).
  • Improve settings write atomicity by holding the settings mutex across mutate+save, and make user logout clearing a single persisted operation.
  • Remove an unused split-tunnel construction site and ensure the split-tunnel rule file exists where options are built; simplify backend location/server construction and clear stale selection when disconnected.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
vpn/vpn.go Removes unused split-tunnel initialization during VPN client construction.
vpn/boxoptions.go Ensures split-tunnel rule file exists at the point sing-box options are assembled.
servers/manager.go Clones stored servers and changes AddServersByJSON/URL to return a *ServerList for downstream propagation.
servers/manager_test.go Updates tests to use returned ServerList/Tags() from AddServersByJSON/URL.
common/settings/settings.go Holds mutex across Set/Clear/Patch + save; makes Clear variadic and persisted.
backend/radiance.go Refactors server/location assembly, reintroduces AddServers with tunnel propagation, and clears stale selection while disconnected.
account/user.go Switches logout clearing to a single multi-key settings clear operation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread account/user.go
Comment thread common/settings/settings.go Outdated
Comment thread common/settings/settings.go Outdated
Comment thread common/settings/settings.go Outdated
garmr-ulfr and others added 3 commits June 5, 2026 11:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@garmr-ulfr garmr-ulfr marked this pull request as ready for review June 5, 2026 18:42
@garmr-ulfr garmr-ulfr merged commit 7c83b37 into main Jun 5, 2026
2 checks passed
@garmr-ulfr garmr-ulfr deleted the fix-server-config-defects branch June 5, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants