feat(menu): Tailscale exit-node rows show country/city
The Exit node picker listed bare hostnames; Mullvad-style nodes are meaningless without their location. Rows are now "hostname — Country City", sliced from `tailscale exit-node list` by the header's fixed-width column offsets (COUNTRY/CITY can be multi-word, so field splitting is wrong by construction); nodes without a location stay a bare hostname, and the pick strips back to the hostname at the first space before `tailscale set --exit-node`. Closes BACKLOG LATER "VPN exit-node richer display"; the VPN HARDWARE-QUEUE entry now covers the location rows. Verification: V1 — the awk was proven against a fabricated fixture (one-word city, multi-word "United States / New York, NY", bare self-hosted node), flake check exit 0, downstream-template-home builds (writeShellScriptBin syntax-gates the script). Real `tailscale exit-node list` output stays V3 (existing VPN menu live-paths entry). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1191,9 +1191,26 @@ ${themeRows}
|
||||
else ${cfg.terminal} -e sudo tailscale "$@"; fi
|
||||
}
|
||||
ts_exit_node() {
|
||||
node=$( { printf 'none\n'; tailscale exit-node list 2>/dev/null | awk 'NR>1 && $2 {print $2}'; \
|
||||
# Rows show "hostname — Country City" (Mullvad-style nodes carry a
|
||||
# location). The COUNTRY/CITY columns are fixed-width and multi-word,
|
||||
# so they're sliced by the header's column offsets, never by field
|
||||
# splitting; hostnames have no spaces, so the pick strips back to the
|
||||
# hostname at the first space. Locationless nodes stay a bare hostname.
|
||||
node=$( { printf 'none\n'; tailscale exit-node list 2>/dev/null | awk '
|
||||
NR==1 { c=index($0,"COUNTRY"); s=index($0,"STATUS"); next }
|
||||
$2 {
|
||||
loc=""
|
||||
if (c > 0) {
|
||||
end = (s > c) ? s : length($0) + 1
|
||||
loc = substr($0, c, end - c)
|
||||
gsub(/ +/, " ", loc); sub(/^ /, "", loc); sub(/ +$/, "", loc)
|
||||
}
|
||||
if (loc != "" && loc !~ /^[- ]+$/) print $2 " — " loc
|
||||
else print $2
|
||||
}'; \
|
||||
printf '%s\n' "$BACK"; } | rofi_menu -p "Exit node" ) || return
|
||||
{ [ -z "$node" ] || [ "$node" = "$BACK" ]; } && return
|
||||
node=''${node%% *} # display row → hostname
|
||||
[ "$node" = none ] && node=""
|
||||
ts_priv set --exit-node="$node"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user