# c8-tailscale

Tailscale: the app (connect, devices, exit node, account) and `c8-tailscale-tile` for its live tile; the `tailscale` command does everything.
Depends on: c8ui, gio, tailscale (run time).

`org.cont8nuum.Tailscale`, one copy (`c8ui_app_main`), PC settings' layout
(dark page list, white content). Shared core (`tailscale-core`, no window
system, also in the tile provider): `status.c` runs `tailscale status
--json` then `tailscale debug prefs` and fills `struct ts_status ts`
(state, this device, account, prefs, `ts.peers` sorted online first with
Mullvad nodes last; a peer's `name` is the first label of its DNS name,
as the CLI shows it, `host` its OS name), `ts_poll` reads again every N s,
`ts_on_change` tells. Changing things goes through `ts_control`:
`tailscale set/up/down/login/logout/switch`, as ourselves when we are
tailscaled's operator (`OperatorUser` in the prefs, or root), else through
`pkexec`; the Status page offers "Allow me" (`pkexec tailscale set
--operator=USER`) and "Start it" (`pkexec systemctl enable --now
tailscaled`) when there is no daemon. `ts_login` spawns `tailscale login`
and keeps polling: the status's `AuthURL` is opened in the browser when it
appears. `tile.c` sends (only when it changed since the last send to
that tile, or after `RESEND_S`, 5 min, or a new owner of the Tiles name)
one untagged update (block template: devices
online, the first five by name, the exit node on large tiles; muted or
warning colour when off or logged out) and a `⇄` badge while an exit node
is in use, to both `org.cont8nuum.Tailscale` and the `tailscale` tile of
`tailscale.widget` (which also has `Exec=c8-tailscale`). `c8-tailscale-tile
TILE-ID` (`provider.c`) polls every 30 s while Start shows, 5 min when
not. `c8-widget tailscale ID` (the old kind) execs it, for start.ini
files from before.
`main.c`: pages Status (connect toggle = `up`/`down`, health warnings as
info bars, this device with Copy links, Taildrop "Collect received files"
= `tailscale file get --conflict=rename` into Downloads), Devices (search
box, a list of our peers; a device page with details updated in place,
Ping = `tailscale ping -c 3`, Send a file through the portal picker =
`tailscale file cp`, Use as exit node), Exit node (None, the tailnet's
own, Mullvad by country and city from the peers' `Location`, "Pick the
nearest" = `exit-node suggest`, LAN access and advertise toggles),
Account (`switch --list --json`, Add an account = `login`, Log out). The
content is built again only when a fingerprint of what it shows changes
(polling every 5 s, 2 s while logging in), so typing isn't undone.
`--page status|devices|exit-node|account`.
Pages are `c8ui_pages` (a device page is its sub page), built once for
both widths: under 760 px c8ui_pages folds by itself (the app doesn't
watch the size): the list and the page take turns filling the window;
a page has a back button and a smaller title, back/Escape returns to
the list (a device page to Devices). The details are rows whose name
and value (`pair`) go one over the other when the window is narrow
(`c8ui_box_set_narrow_orientation`), Copy staying at the right. Search charm: devices;
Settings charm "Options": accept-routes, accept-dns, LAN access, shields
up, SSH, advertise exit node, hostname. Tested live: every page, a device
page, the tile provider's update, a plain `down`/`up` keeping the prefs.
Untested: logging in and out, pkexec paths, sending a file, Mullvad
selection and switching accounts (only one is logged in here).
Stealth mode (`[stealth] on`, c8-base's `stealth.h`): `shown.c` (core)
gives what's drawn, `ts_shown_*`; the parsed `ts` keeps the real values,
which every command gets (ping, send, exit node, switch). This device is
the persona host; peers' names `C8_STEALTH_DEVICE` (Mullvad nodes and
their DNS names stay, they're public), MagicDNS names the alias plus
`example.ts.net` (`example-N.ts.net` for further suffixes), addresses
and a direct connection's `ip:port` `C8_STEALTH_ADDRESS`, owners the
persona name for our own user else `C8_STEALTH_PERSON` (Tagged Devices
stays), logins the persona email for ours else `person@example.com`,
tailnets `example.com/.org/.net` (one named after a login: that login's
stand-in). `ts_shown_text` scrubs command output (ping, errors, health,
Taildrop's list, tags): known DNS names and names, then every IPv4/IPv6
in it, then `c8_stealth_text`. The device search matches what's shown.
Copy links copy the real value (copying is using it). Options' hostname
box shows the persona host; Enter on it unchanged is ignored. The app
watches (`c8_stealth_watch`: page built again, flyout, tile) and so does
the provider. Tested with a fake `tailscale` on PATH (status, prefs,
`switch --list`, ping from files) headless, wide and 480 wide, every
page, a device page, ping output, a live toggle in the app and in the
provider (tile fields on a private bus), and the real status read-only.
Untested: the Search charm's results, the Options flyout, send/Taildrop
messages, a second account in the real switcher.
