Taildrop to Downloads, exit nodes past captive portals, stay awake

Ports the rest of CoreDesktop's 9dc5eb1 that applies to Pop!_OS.

- configure tailscale turns on federated-connector-taildrop.service,
  which saves files sent here with Taildrop to Downloads and says so in
  a notification. COSMIC Files has no Scripts menu, so CoreDesktop's
  "Send with Tailscale" isn't ported; send with tailscale file cp.
  Leaving the network turns it off.
- It also installs a NetworkManager dispatcher script that stops using a
  Tailscale exit node while you sign in to a captive portal, and uses it
  again once online. Pop!_OS checks connectivity (20-connectivity-pop),
  so NetworkManager sees the portal.
- A computer joined before this shows Tailscale as to do, and configure
  tailscale adds both without signing in again. update restarts the
  Taildrop service on the new version, as it does the email watcher.
- install.sh keeps the computer from sleeping until an install or update
  finishes.

The pacman guard, unowned files and hardware.sh are Arch only.

Smoketest: 75-taildrop-portal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 19:06:31 -07:00
co-authored by Claude Opus 5.5
parent 7185d6cb3e
commit 0eff0c70d3
10 changed files with 265 additions and 19 deletions
+42
View File
@@ -0,0 +1,42 @@
#!/bin/bash
#
# Purpose : NetworkManager runs this as root when the network's connectivity
# changes (configure tailscale installs it in dispatcher.d).
# On a network with a sign-in page (a captive portal: hotels,
# airports, trains), a Tailscale exit node sends the sign-in page
# into a tunnel the network is still blocking, so the sign-in page
# never loads. Stop using the exit node until you've signed
# in, then use it again.
# For the tests
PAUSED="${CAPTIVE_PORTAL_STATE:-/run/federated-connector-exit-node-paused}"
[ "$2" = connectivity-change ] || exit 0
command -v tailscale > /dev/null || exit 0
case "$CONNECTIVITY_STATE" in
PORTAL)
[ -e "$PAUSED" ] && exit 0
# The exit node's Tailscale address, without its /32
node="$(tailscale status --json 2> /dev/null | jq -r '.ExitNodeStatus.TailscaleIPs[0] // empty')"
node="${node%/*}"
[ -n "$node" ] || exit 0
echo "$node" > "$PAUSED"
if tailscale set --exit-node=; then
logger -t federated-connector "Signing in to a captive portal: stopped using exit node $node until online"
else
rm -f "$PAUSED"
fi
;;
FULL)
[ -s "$PAUSED" ] || exit 0
node="$(< "$PAUSED")"
# Leave it if you picked another exit node meanwhile
if [ -z "$(tailscale status --json 2> /dev/null | jq -r '.ExitNodeStatus // empty')" ]; then
tailscale set --exit-node="$node" \
&& logger -t federated-connector "Online again: using exit node $node again"
fi
rm -f "$PAUSED"
;;
esac
exit 0
@@ -0,0 +1,15 @@
[Unit]
Description=Save files sent with Taildrop to Downloads
PartOf=graphical-session.target
After=graphical-session.target
# Only once this computer has joined your Core's Tailscale network
# (configure tailscale starts it then)
ConditionPathExists=%h/.config/federated-connector/tailscale.conf
[Service]
ExecStart=%h/.local/share/federated-connector/connector/system/taildrop
Restart=on-failure
RestartSec=30
[Install]
WantedBy=graphical-session.target
+41
View File
@@ -0,0 +1,41 @@
#!/bin/bash
#
# Purpose : Save files sent to this computer with Taildrop (tailscale file cp,
# or Tailscale's apps) to your Downloads folder, and say so in a
# notification. Run by federated-connector-taildrop.service, which
# configure tailscale turns on.
dir="$(xdg-user-dir DOWNLOAD 2> /dev/null)"
[ -n "$dir" ] && [ "$dir" != "$HOME" ] || dir="$HOME/Downloads"
# The files tailscale file get --verbose reports writing, one per line
received() {
sed -nE 's/.*wrote .* as (.*) \([0-9]+ bytes\).*/\1/p' <<< "$1" | xargs -r -d '\n' -n 1 basename
}
notify() {
local names=() title body action
mapfile -t names < <(received "$1")
if (( ${#names[@]} == 1 )); then
title="Received ${names[0]}"
elif (( ${#names[@]} > 1 )); then
title="Received ${#names[@]} files"
body="$(printf '%s\n' "${names[@]}")"
else
title="Received files"
fi
action="$(notify-send --app-name=Tailscale --icon=folder-download --action=open="Show" \
"$title" "${body:-In $(basename "$dir")}")"
[ "$action" = open ] && xdg-open "$dir"
}
while true; do
mkdir -p "$dir"
# Waits for files, saves them, and returns. It fails at once when Tailscale
# isn't running or this computer is off the network; wait, then try again.
if output="$(tailscale file get --wait --conflict=rename --verbose "$dir" 2>&1)"; then
notify "$output" &
else
sleep 60
fi
done