Skip to content

internal/ui: add automatic exit-node selection - #344

Open
itsAnchorpoint wants to merge 1 commit into
DeedleFake:masterfrom
itsAnchorpoint:feat/automatic-exit-node
Open

itsAnchorpoint wants to merge 1 commit into
DeedleFake:masterfrom
itsAnchorpoint:feat/automatic-exit-node

Conversation

@itsAnchorpoint

Copy link
Copy Markdown
Contributor

Add Automatic exit node and Current exit node to the this-machine page. Automatic uses tailscaled's existing recommended-node tracking (tailscale set --exit-node=auto:any), so selection remains active when Trayscale exits. See Tailscale's documentation.

Behavior:

  • Turning Automatic off keeps a resolved current exit node selected.
  • Choosing a specific node, or clearing the selection, explicitly leaves automatic mode.
  • The existing Use Exit Node toggle continues to disable exit-node use and restore the daemon's remembered selection/mode.
  • The current-node row shows the peer name, None, Waiting for an exit node, or Unavailable as appropriate.
  • Automatic is unavailable while this machine advertises itself as an exit node. Requests run off the GTK main loop with a timeout and are cancelled when the page is destroyed. Errors restore the daemon-reported switch state and show a toast.

The control lives on the this-machine page because automatic selection applies to standard and Mullvad exit nodes. The mode is stored in tailscaled's preferences.

Validation:

  • Full go test -vet=all ./... passed with a private D-Bus session and memory GSettings backend.
  • Full -race tests passed for internal/tsutil and internal/ui.
  • New API/UI tests passed under ASAN with detect_leaks=0 (memory-access checking).
  • Local LeakSanitizer reports exactly the same Fontconfig allocations for the new animation test and the unchanged upstream TestStatusSwitchUpdates: 1,013,122 bytes in 23,693 allocations, including with the existing suppressions. Local Pango/Fontconfig internal debug symbols are absent; the repository's CI installs them. Leak detection is not claimed clean locally, and CI/suppressions are unchanged by this patch.
  • Lint, go fix -diff, git diff --check, and the nested tsharness module check passed.
  • Drove the real GTK UI against a separate userspace tailscaled and testcontrol server: automatic selection, keeping the selected node when turning Automatic off, selecting another peer manually, fully disabling exit-node use, native off/resume, and persistence across app restart. Also exercised the no-recommendation state. Checked the daemon's preferences as well as the UI. The user's real tailscaled and installed Trayscale were not modified.

The animation regression fails if an old daemon status unconditionally calls SetActive during a toggle, and passes when unchanged values are left alone. The fixture's opt-in -suggest-exit-nodes flag and feature recipe make the recommendation path reproducible.

AI attribution: OpenAI Codex implemented the upstream adaptation, tests, and verification fixture and ran the automated checks and UI verification. The submitter supplied the original use case and feature scope. The commit includes a Co-authored-by: Codex trailer.

Expose tailscaled's automatic exit-node mode on the self page, together
with the current node. Keep selection in the daemon so it survives
closing Trayscale. Leaving automatic mode preserves a resolved node;
explicitly selecting or clearing a node disables automatic selection.

Apply changes off the GTK main loop, cancel pending work when the page
is destroyed, and keep old status updates from cancelling toggle
animations. Add preference, error-handling, UI-state, and animation
regression tests.

Extend tsharness with opt-in recommendation eligibility and document
the feature and its isolated verification path.

Co-authored-by: Codex <noreply@openai.com>
@DeedleFake

Copy link
Copy Markdown
Owner

Hmmm... I don't like that turning on the the Automatic Exit Node option also immediately connects to the exit node. Nothing in the name or description makes it sound like it does that. It just sounds like a configuration option for when the exit node option in the menu is used.

I also don't like the Current Exit Node row being in the middle of a bunch of other rows with switches on them. It looks very out-of-place.

I need to think a bit about how I would prefer this designed.

@DeedleFake

Copy link
Copy Markdown
Owner

@itsAnchorpoint, I created #345 with some tweaks. It includes your commits, but it's a separate pull request because it can't be stacked onto a pull request in a fork. Let me know what you think when you get a chance, please.

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.

2 participants