1
1
Fork 0
nixos/options/custom/scripts/vpn.sh
Myned 53c8575116
git: migrate to forgejo
Squashes 1,331 commits

Signed-off-by: Myned <dev@bjork.tech>
2024-09-12 19:41:21 -05:00

16 lines
688 B
Bash

#! /usr/bin/env bash
# Toggle tailscale exit node
if [[ "$(tailscale status --json | jq .ExitNodeStatus.Online)" == 'true' ]]; then
tailscale set --exit-node=
notify-send '> vpn' 'Disconnected' --urgency low
elif [[ "${1-}" == '-s' ]]; then
# TODO: Remove regex workaround when tailscale v1.70.0 is in nixpkgs
suggested="$(tailscale exit-node suggest | sed --regexp-extended --quiet 's/Suggested exit node: (.+)\./\1/p')"
tailscale set --exit-node="$suggested" --exit-node-allow-lan-access
notify-send '> vpn' "Connected to $suggested" --urgency low
else
tailscale set --exit-node="$1" --exit-node-allow-lan-access
notify-send '> vpn' "Connected to $1" --urgency low
fi