Find storage and AI servers on the tailnet, not only over mDNS

Ports CoreDesktop's 16e5a9c.

configure storage and configure ai-servers now also ask the other online
computers on the Core's tailnet, so a laptop away from home still finds
the MiniServer and the LLM box. A machine found both ways is listed
once, by its tailnet name, and tailnet servers mount at /mnt/<short name>.

Smoketest: 45-tailnet, with a stand-in tailscale.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 18:58:18 -07:00
co-authored by Claude Opus 5.5
parent 1445ad7bb1
commit dfb43c866c
7 changed files with 195 additions and 23 deletions
+1
View File
@@ -32,6 +32,7 @@ Each run writes its logs to `smoketest/results/<time>/`, one per scenario, and p
| `20-goa` | `goa-account` with Online Accounts 3.50. It adds Nextcloud and email (quoting a name), adding again changes nothing, and it pauses email and ends the pause. Test a Core takes an unreachable mail server as a sign-in failure, not a wrong password. Removing leaves nothing in the keyring. |
| `30-core-local` | Superpanel's entry, Element's config (in ~/.config, or the Flatpak's folder), and the COSMIC Files sidebar. The sidebar check reads and writes ron's pretty format with network places and escaped names, keeps COSMIC Files' defaults, and leaves a file it can't read alone. Then davfs2's secret, read back. |
| `40-backup` | restic and rclone from apt, with `rclone serve webdav` standing in for Nextcloud and the secrets in the keyring. `system/backup` makes a snapshot that leaves out caches and the install, a file restores from it, and without the passphrase it fails. |
| `45-tailnet` | `lib/tailnet.sh` with a stand-in `tailscale`: the other online computers, without phones; nothing when Tailscale is stopped or missing. `configure ai-servers` and `configure storage` ask the tailnet's machines as well as mDNS's, list a machine found both ways once by its tailnet name, and mount a tailnet server at /mnt/<short name>. |
| `50-sandbox` *(all)* | Node.js and srt download and install. A stand-in agent can't read `~/.ssh` or Federated Connector's settings, or write outside its project, reaches allowed sites only, and won't start in your home folder. A new bash finds the sandboxed command first. |
| `55-hermes-homeserver` | Hermes' gateway reaches only a Matrix server you've allowed: a server in Hermes' settings is to do until `configure hermes` allows it, a wildcard or escape codes never count, and `configure agents` carries over the server an old drop-in allowed. `edit_json` fills an empty file from its default. |
| `60-packages` *(all)* | davfs2 installs with `mount.davfs` setuid, and `davfs2_ready` fixes one installed without. sshfs' `fusermount3` and smbclient are where `configure storage` expects them, and so is GTK's CUPS print backend. mise installs from its apt repository and a new bash has it. |
+82
View File
@@ -0,0 +1,82 @@
# shellcheck shell=bash
# Scenarios set what the runner and items read
# shellcheck disable=SC2034
DESCRIPTION="Storage and AI servers found on the Core's tailnet as well as over mDNS"
TIER=quick
# What tailscale status --json prints on a tailnet with: llm (also on mDNS as
# llm.local), nas (only on the tailnet), an offline machine, a phone, and this
# machine (Self, which isn't a Peer)
TAILNET_JSON='{
"BackendState": "Running",
"Self": {"HostName": "basement", "DNSName": "basement.tail.example.", "OS": "linux", "Online": true},
"Peer": {
"nodekey:1": {"HostName": "LLM", "DNSName": "llm.tail.example.", "OS": "macOS", "Online": true},
"nodekey:2": {"HostName": "nas", "DNSName": "nas.tail.example.", "OS": "linux", "Online": true},
"nodekey:3": {"HostName": "old", "DNSName": "old.tail.example.", "OS": "linux", "Online": false},
"nodekey:4": {"HostName": "phone", "DNSName": "phone.tail.example.", "OS": "iOS", "Online": true}
}
}'
scenario() {
local bin="$HOME/.local/bin" status_json="$HOME/tailscale.json" probes="$HOME/probes"
mkdir -p "$bin"
# A stand-in tailscale that prints $status_json for `status --json`
printf '#!/bin/bash\ncat %q\n' "$status_json" > "$bin/tailscale"
chmod +x "$bin/tailscale"
echo '{"BackendState": "Stopped", "Peer": {}}' > "$status_json"
source "$CONNECTOR/configure.d/lib/tailnet.sh"
step "lib/tailnet.sh"
check_eq "nothing while Tailscale is stopped" "" "$(tailnet_hosts)"
check_not "not joined while it's stopped" tailnet_joined
echo "$TAILNET_JSON" > "$status_json"
check_eq "the other online computers, without phones or the trailing dot" \
"$(printf 'llm.tail.example\nnas.tail.example')" "$(tailnet_hosts)"
check "joined while it runs" tailnet_joined
check_eq "nothing without Tailscale" "" "$(PATH=/usr/bin:/bin tailnet_hosts)"
check_eq "short_host shortens a tailnet name" box "$(short_host box.tail.example)"
check_eq "and a .local one" box "$(short_host box.local)"
check_eq "not an address" 192.168.0.5 "$(short_host 192.168.0.5)"
check "box.tail.example is a tailnet name" is_tailnet_host box.tail.example
check_not "box.local isn't" is_tailnet_host box.local
check_not "nor 100.64.0.3" is_tailnet_host 100.64.0.3
check_eq "a machine found both ways is listed once, by its tailnet name" \
"$(printf 'llm.tail.example\nnas.tail.example\nlab.local\npi-star.local')" \
"$(with_tailnet_hosts "$(printf 'lab.local\nllm.local\npi-star.local')")"
step "configure ai-servers"
source "$CONNECTOR/configure.d/50-ai-servers.sh"
mdns_hosts() { printf 'llm.local\npi-star.local\n'; }
curl() {
echo "$*" >> "$probes"
case "$*" in
*http://llm.tail.example:11434/v1/models*) echo '{"data": [{"id": "gemma4:12b"}]}' ;;
*) return 7 ;;
esac
}
: > "$probes"
check_eq "find_servers finds the server on the tailnet" "llm.tail.example:11434|1" "$(find_servers)"
check "it asks the machine only on the tailnet" grep -qF http://nas.tail.example:11434/v1/models "$probes"
check "and the one only on mDNS" grep -qF http://pi-star.local:11434/v1/models "$probes"
check_not "not a machine twice" grep -qF llm.local "$probes"
unset -f curl
step "configure storage"
source "$CONNECTOR/configure.d/60-storage.sh"
mdns_own_host() { echo basement.local; }
mdns_services() {
printf '%s\n' 'PI-STAR|_smb._tcp|pi-star.local|192.168.0.9|445|' \
'llm|_sftp-ssh._tcp|llm.local|192.168.0.7|22|' \
'basement|_smb._tcp|basement.local|192.168.0.2|445|'
}
port_open() { [ "$1:$2" = nas.tail.example:22 ] || [ "$1:$2" = llm.tail.example:445 ]; }
check_eq "find_storage lists each machine once, tailnet ones by their tailnet name" \
"$(printf 'sftp|nas.tail.example|nas\nsmb|llm.tail.example|llm\nsmb|pi-star.local|PI-STAR')" \
"$(find_storage)"
STORAGE_CONF="$HOME/storage"
check_eq "a tailnet server mounts at /mnt/<short name>" /mnt/nas-data "$(mount_point nas.tail.example data)"
rm -f "$bin/tailscale" "$status_json" "$probes"
}