Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions home-manager/programs/fish/functions/_vpn_function.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ function _vpn_function --description "Connect/disconnect Tailscale exit node thr

switch "$argv[1]"
case on
tailscale set --exit-node=$kyber_host
# --accept-dns=true routes DNS through the exit node; without it
# DNS queries break while tunnelled and name resolution fails.
tailscale set --exit-node=$kyber_host --accept-dns=true
and echo "VPN connected through kyber"
case off
tailscale set --exit-node=
tailscale set --exit-node= --accept-dns=false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Latent: off hard-disables accept-dns regardless of host baseline — This currently matches nix-darwin/config/networking.nix:33-37, which activates with tailscale set --accept-dns=false alongside the /etc/resolver/ts.net split-DNS setup, so on macOS it correctly restores the declared baseline. On a host that instead relies on Tailscale MagicDNS while the exit node is off (e.g. a future Linux/NixOS machine using this same fish function), vpn off will flip --accept-dns to false and silently break .ts.net lookups until the user re-enables it. Worth either scoping this to macOS or reading the current preference before overwriting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: add a symmetric comment on the off path — The on branch documents why --accept-dns=true is required, but the two branches that pass --accept-dns=false are silent. Since this pairs with the activation script in nix-darwin/config/networking.nix:33-37 (which sets --accept-dns=false and configures /etc/resolver/ts.net for split-DNS), a one-line comment on line 11 would prevent a future reader from stripping the flag as dead code.

and echo "VPN disconnected"
case status
tailscale status
case ''
# Toggle: if exit node is set, turn off; otherwise turn on
set -l current (tailscale status --json 2>/dev/null | jq -r '.ExitNodeStatus.ID // empty')
if test -n "$current"
tailscale set --exit-node=
tailscale set --exit-node= --accept-dns=false
and echo "VPN disconnected"
else
tailscale set --exit-node=$kyber_host
tailscale set --exit-node=$kyber_host --accept-dns=true
and echo "VPN connected through kyber"
end
case '*'
Expand Down
Loading