dentatsu

Operator reference

Every setting and recipe for running a dentatsu hub: TLS, iroh, who may sign in, caps, backups, monitoring and a whole machine.

A hub is one program (dentatsu hub) and one data directory. This page is what a self-hoster needs on top of that: TLS, a public URL, iroh's UDP port, invites, and what the clients do when a connection drops. It is the operator reference; the site's self-hosting guide (site/pages/self-host/index.md, served at /self-host/) walks through a whole setup in order and links here for each step. The site serves this page as it is at /self-host/reference/.

TLS: a reverse proxy in front, wss everywhere outside

The hub speaks plain WebSocket and HTTP on its port. A TLS reverse proxy in front of it gives people https:// and wss://. The supported setup is Caddy: it gets and renews the certificate by itself (ACME, Let's Encrypt or ZeroSSL) and proxies WebSockets with no extra lines. nginx works too.

Why a proxy, and not TLS in the hub:

  • Certificates are the hard part, not the handshake. A hub with native TLS would still need ACME (an HTTP-01 or TLS-ALPN-01 responder, renewal, storage, rate limits), and that is most of what a self-hoster gets wrong. Caddy has done it for years; a hub that did it too would be one more ACME client to keep right.
  • The hub's sockets are shared out to I/O threads (docs/architecture.md, "Transport and runtime"): the home loop reads the upgrade and passes the socket's descriptor to a thread. A TLS session can't be passed that way, so native TLS would mean moving the handshake into the I/O threads, a rewrite of the gateway for what a proxy does already.
  • One port, many things. The proxy can serve other sites on 443 beside the hub, and the hub's voice and iroh use their own UDP ports anyway (DTLS-SRTP and QUIC, not this TLS).
  • The dialing side is different: a client or another hub reaching a hub from outside must speak wss, so dentatsu dials wss natively (src/dentatsu/dial.nim: chronos's TLS stream on BearSSL, which chronos vendors, TLS 1.2). The CLI, the TUI and federation links take wss://HOST/ URLs everywhere a ws:// one was taken. The web client is same-origin: its page opens wss:// to the host it came from.
# /etc/caddy/Caddyfile
chat.example.org {
    reverse_proxy 127.0.0.1:7180
}

That is the whole file: Caddy listens on 80 and 443, gets the certificate for chat.example.org (its A/AAAA record must point at this machine, and ports 80 and 443 must be reachable for the ACME challenge), redirects http to https, and passes WebSocket upgrades through (the client's / and federation's /fed alike).

nginx

map $http_upgrade $connection_upgrade { default upgrade; '' close; }
server {
  listen 443 ssl;
  server_name chat.example.org;
  ssl_certificate     /etc/letsencrypt/live/chat.example.org/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/chat.example.org/privkey.pem;
  client_max_body_size 64k;
  location / {
    proxy_pass http://127.0.0.1:7180;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;   # the hub's limits count by it
    proxy_buffering off;
    proxy_read_timeout 1h;        # a quiet WebSocket stays open
  }
}

Certificates for nginx come from an ACME client of its own (certbot: certbot certonly --webroot or --nginx, and its timer renews them). tests/e2e/services.sh runs this same configuration in the e2e-web step, with a throwaway CA.

The hub's side

# /etc/dentatsu/hub.conf
listen = 127.0.0.1          # only the proxy reaches it
port = 7180
data = /var/lib/dentatsu
web = /usr/share/dentatsu/web
web-url = https://chat.example.org/
# public-url = wss://chat.example.org/   # (the default when web-url is set: https → wss)
  • web-url is the https URL people open: the OAuth client id, redirect and cookies (__Host-, Secure) are built from it, so the hub never needs to read X-Forwarded-Proto or Host to know it is behind TLS.
  • public-url is the URL the hub gives other servers and clients in servers frames and server lists. It defaults to web-url as a WebSocket URL; set it when the hub has no web client (public-url = wss://chat.example.org/).
  • The hub's rate limits count by the client's address: behind a proxy on this machine it believes X-Forwarded-For from loopback peers only (trusted-proxies, below in "Caps"). Caddy and nginx as shown set it.
  • resume-s = 120: how long a dropped session can be resumed (below).

iroh: one UDP port beside the proxy

The hub serves iroh too (plans/04a step 8; docs/wire.md, "iroh beside the WebSocket"): native clients (the CLI, the TUI) and other hubs use it once the hub's ready or link handshake told them how to reach it, and keep their connection when their network changes (a laptop moving from Wi-Fi to a phone's hotspot). iroh brings its own encryption (QUIC, the hub's key as its identity), so it goes around the proxy, on UDP.

  • The bridge. iroh runs in dial-iroh, a second program the hub starts and restarts (iroh-bridge, else DIAL_IROH_BRIDGE, else beside dentatsu, else on PATH; build it from the dial-iroh repository with cargo build --release). Without it the hub says so once and serves WebSocket only. iroh = false turns it off.
  • The port. By default iroh binds UDP on every interface at the hub's port number (port = 7180: UDP 7180). Open that UDP port in the firewall. iroh-bind picks another; iroh-addrs names an address the hub can't see itself (a forwarded port on a home router): IP:PORT, [IPv6]:PORT, or NAME:PORT for a dynamic address (below, "A dynamic address"). There is no UPnP or NAT-PMP: dial-iroh is built without iroh's portmapper (it never probes the gateway), so behind a home router the UDP port is forwarded by hand, like voice's.
  • Relays. iroh-relay = none (the default) uses direct addresses only and sends nothing to anyone else: right for a hub with a public address. A hub behind NAT (a family hub at home) needs a relay to be reached. Give your own relays first, and n0 last if n0's public relays may stand in while none of yours answers (decision 0046): iroh-relay = https://relay.example.org, n0. The list is URLs separated by commas, at most 8, optionally ending in n0 (also spelled default); n0 alone uses only n0's relays. n0's relays see the hub's node id and addresses and carry encrypted packets when no direct path works.
    • n0 really last. iroh picks its home relay by latency among all the relays it knows, not by the order you write them, so dial-iroh starts with your relays alone. When none of them has been connected for 5 s, it adds n0's relays (iroh then picks one); when its next network report (every 20 to 26 s) reaches one of yours again, it takes n0's out and goes back to yours.
    • The relay the hub tells is the one it uses. The IrohAddr in ready and in link handshakes names the hub's home relay as it is now: after a fallback, n0's; after the way back, yours. A client that saved the older one still dials the hub's direct addresses, falls back to the WebSocket if iroh doesn't connect, and learns the new one from that ready.
    • Clients (the CLI, the TUI) take the hub's hint: they dial the hub through the relay it told, and use that same relay as their own home relay. They have no relay setting of their own.
    • iroh-relay-ca names a PEM file of CA certificates for relays with a private CA. Clients don't have it: a relay that clients use should have a certificate their systems trust (Let's Encrypt, below).
  • iroh-log keeps the bridge's own log in a file.
# iroh beside the proxy, a public hub
iroh-bind = 0.0.0.0:7180
# a hub at home behind NAT: your own relay first, n0's public relays only when yours is down
# iroh-relay = https://relay.example.org, n0

A dynamic address

A home connection's public address changes now and then. voice-public and iroh-addrs take a DNS name for it instead of an IP literal (voice-public = chat.example.org, iroh-addrs = chat.example.org:7180), a name the DDNS timer (below, "DNS records") keeps at the router's address:

  • The hub resolves each name at start, then again every resolve-s seconds (60 by default; 0: only at start), in a thread of its own. When an answer differs, it logs voice-public: NAME is IP now or iroh-addrs: … now and tells the new address from then on: the ICE candidate of new calls, and the iroh addresses in ready and the federation's handshakes. No restart, no rewritten config.
  • Calls under way keep the address they were given. A moved address breaks them anyway (their packets went to the old one); the participants join again and get the new one. iroh clients and hubs that knew the old address fall back to the WebSocket and learn the new one from the next ready.
  • voice-public takes the name's first address of voice-udp's family (0.0.0.0:7181: its IPv4 address, the A record), with the name's port if one is given (NAME:PORT), else the bound port. iroh-addrs takes every address of the name (IPv4 first), with the entry's port, after the entries written before it; at most 8 in all.
  • A failed lookup (DNS down, no answer) keeps the last addresses. At start, a voice-public name with no address stops the hub (exit 1: there is no candidate to give; systemd starts it again 5 s later); an iroh-addrs name with none is left out until it resolves.
  • The name is resolved on the hub's machine. Split DNS there (a local resolver answering the LAN address for chat.example.org) would tell clients the LAN address: let the machine resolve the public record, or give these keys a name of their own that only the DDNS timer sets (DDNS_NAMES=chat,pds,ip and voice-public = ip.example.org).
  • With a static address, IP literals are fine and nothing is resolved.

Running your own relay

A relay is upstream's iroh-relay program (n0's, MIT or Apache-2.0) at the version dial-iroh is built with: 1.5.0 (dial-iroh's Cargo.toml pins it; move both together). It carries only encrypted QUIC packets between node ids and tells endpoints their public address; it sees which node ids talk, not what they say. One small VPS serves many hubs. deploy/iroh-relay/ has the files.

User-only steps (nothing here does them for you):

  1. Choose the host: a machine with a public IPv4 address (and IPv6 if you have it), not behind NAT. Your hub's own machine at home is the wrong place: the relay is what reaches it there.
  2. DNS: an A (and AAAA) record, for example relay.example.org, pointing at it.
  3. Open the ports in its firewall and the provider's: TCP 80, TCP 443, UDP 7842.
  4. Install, start and keep it running: below.

Install (on the relay host, as root):

cargo install iroh-relay --version =1.5.0 --features server --locked --root /usr/local
install -d /etc/iroh-relay
install -m 0644 deploy/iroh-relay/iroh-relay.toml /etc/iroh-relay/    # then set hostname and contact
install -m 0644 deploy/iroh-relay/iroh-relay.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable --now iroh-relay
journalctl -u iroh-relay -f                     # the certificate is fetched at the first TLS connection
  • TLS. By default the relay gets and renews a Let's Encrypt certificate itself (cert_mode = "LetsEncrypt", hostname, contact, kept in /var/lib/iroh-relay). With a certificate of your own (another ACME client, or a private CA) use cert_mode = "Manual" (or "Reloading", which picks up a renewed one without a restart) and the unit's LoadCredential= lines; for a private CA, give each hub the CA's certificate as iroh-relay-ca (clients can't use such a relay, see above).
  • Ports. TCP 443 is the relay (HTTPS, WebSocket upgrade), TCP 80 plain HTTP (captive-portal checks), UDP 7842 QUIC address discovery. Metrics listen on 127.0.0.1:9090 only.
  • Who may use it. Anyone who knows the URL, by default; [access] allowlist in the config limits it to node ids you list (your hubs' keys, and your devices' keys if their clients use it).
  • Check it. curl -I https://relay.example.org/ from anywhere answers; the hub's log says iroh: node … relay https://relay.example.org/ once it uses it.

Point the hubs at it, n0 last:

# /etc/dentatsu/hub.conf
iroh-relay = https://relay.example.org, n0
# with several of your own: iroh picks the nearest of them; n0 only when none answers
# iroh-relay = https://relay1.example.org, https://relay2.example.org, n0

Restart the hub. Without n0, a hub whose relays are all down is reachable only by its direct addresses (and the WebSocket) until one is back.

Federation links prove each server's key with a mutual challenge (docs/wire.md, "Federation links"). Binding that proof to the TLS session (RFC 9266 tls-exporter, so a relay between two servers can't pass the proof along) needs both ends to see the same TLS session. Behind a proxy the listening hub never sees it: the proxy terminates TLS. So the binding would only work between hubs that terminate TLS themselves, which this setup doesn't do. Deferred until a hub can terminate TLS itself (or a proxy forwards the exporter value, which none of the common ones do). Links over iroh don't need it: the proven key must be the node id the QUIC connection proved. Meanwhile the link proof binds both keys and both nonces, and TLS's certificate check stops a relay that can't pass for the hub's name.

Who may sign in

By default (accounts = any) every atproto account that proves a device may sign in to a hub and found spaces on it. That suits a hub on loopback or a test. A hub others can reach refuses to start until accounts is set, listed or an explicit any: one that listens beyond loopback, whose public URL or web-url names another host, whose iroh endpoint (when a bridge is installed) or voice port binds beyond loopback. So it is never open to the world by accident. For a family hub:

# /etc/dentatsu/hub.conf
accounts = listed
allow-pds = https://pds.example.org                        # every account on your own PDS
allow-accounts = did:plc:FRIEND1, did:plc:FRIEND2          # friends on other hosts, by DID
admins = did:plc:YOU                                       # admins are let in too
space-create = admins                                      # only admins found spaces here
  • accounts = listed lets in an account that allow-accounts or admins names, or whose DID document names a PDS in allow-pds; every other one is refused with "DID may not sign in to this hub", at every door: auth over WebSocket and iroh, a resumed session, the web sign-in (before the PAR goes to the account's server, and again at the callback, where the tokens of a refused account are revoked), and Conduit's logins.
  • The DID alone decides first. An account not in the lists, when there is no allow-pds (or the account is a did:key, which has no PDS), is refused before the hub fetches anything for it. With allow-pds, the hub needs the account's verified DID document to know its PDS (the one a login's proofs are checked under), so the PDS-listed check comes after the device check.
  • allow-pds takes origins (https://pds.example.org, the scheme's default port optional) or bare hosts (pds.example.org: any scheme and port). It is compared with the DID document's PDS URL exactly, never as a suffix.
  • space-create = admins: only admins may found a space whose genesis names this hub. Everyone signed in still joins spaces by invite, creates rooms and invites others as the space's roles allow.
  • Invites don't admit. A newcomer with an invite to a space hosted here must still be let in by the lists (decision 0054); an invite-scoped sign-in may come later.
  • conduit-allow = accounts (Conduit's client protocol, conduit = PATH) means the hub's own accounts that the lists still admit: an account that signed in before the hub went listed is refused there too.
  • The config's lists are read at start: change the file and restart the hub. Live sessions end with the restart. Without a restart, dentatsu hub admin accounts allow|deny DID keeps a rule beside them (below).

The operator's rules, and which wins

dentatsu hub admin accounts allow DID and … deny DID ("Admin commands") keep rules in the hub file (hub.db, table account_rules), so the allow list changes without editing hub.conf or restarting; the config's lists stay in force beside them. The order, at every door:

  1. admins (the config) are always let in. deny refuses an admin: take it out of admins first.
  2. A deny rule refuses the DID, whatever allow-accounts, allow-pds or accounts = any say, and ends its sessions when it is set on a running hub.
  3. An allow rule, or allow-accounts, lets the DID in under accounts = listed; else allow-pds by its PDS. (Under accounts = any an allow rule changes nothing until the hub is listed.)

accounts clear DID removes a rule: the config alone decides again. The config and the rules add up; neither rewrites the other, so the file stays the record of what the operator wrote by hand.

What the hub dials

A hub fetches and dials what its users and other servers name: their handles, DID documents and PDSes at sign-in, the URLs of other servers for federation (a servers hint, space join --via, a fallback list, a server's handshake), and the iroh addresses other servers tell. Every one of them goes only to public addresses, checked after DNS on the address actually connected to: not loopback, RFC 1918, CGNAT (100.64.0.0/10), link-local, multicast, unspecified, documentation or benchmark space, IPv6 unique local, or a mapped, NAT64 or 6to4 form of one. Nothing follows redirects. A refused dial says "refused by the address filter" in the hub's log.

fetch-allow names the blocks that are let through anyway, for a PDS, PLC or other hub on your own network:

fetch-allow = 192.168.1.0/24, fd12:3456::/48    # a PDS on the LAN, reached through split DNS
  • Leave it empty on a hub on the internet; the PDS beside the hub is reached at its public name.
  • The iroh ways other servers tell are filtered too; a relay is checked by resolving its name first, and the iroh bridge resolves it again itself (a name that answers differently the second time is the residue).
  • What the operator configures (plc, iroh-relay, conduit-peers) isn't filtered, except the PLC's fetches, which go through the same guard (set fetch-allow for a PLC on a private address).

Caps

A hub on the internet holds against floods with these caps; the defaults suit a family hub (0 turns one off):

KeyDefaultWhat
max-connections1024open connections at most (WebSocket, web, federation, iroh streams); past it a new one is answered 503 and closed without reading it
account-sessions16sessions one account may hold at once; past it a login is refused ("rate limited", saying why)
head-timeout-ms10000a request's line and headers, or a WebSocket upgrade, must arrive within this, over TCP or iroh
auth-timeout-ms30000a client's WebSocket must log in within this, or it is closed (a Conduit client's too; with 0, Conduit clients get 10 s, as his server gives them)
login-rate60WebSocket upgrades (logins, Conduit logins, federation links) one address may make a minute, in a burst or spread out; past it: 429 with when to try again
signin-rate10web sign-ins and sign-outs one address may begin a minute; past it the page is told to wait, and nothing is fetched
signin-per-address8web sign-ins under way one address may hold: its own oldest goes first, and when the table (1024) is full the address holding the most loses its oldest, so a flood from a few addresses never pushes out anyone else's
handle-rate60handles the web page may have the hub look up for one address a minute (/web/handle, which anyone may ask: the page asks for every person it shows); an answer the hub keeps (an hour, a miss 5 minutes) costs nothing; past it: 429 with when to try again, nothing is fetched, and the page shows the DID until it asks again
trusted-proxies127.0.0.0/8, ::1peers whose X-Forwarded-For names the client's address
  • The address is the TCP peer's, unless the peer is a trusted proxy: then the rightmost address in X-Forwarded-For that isn't a trusted proxy (what a client writes there itself is left of it and ignored). Forwarded is read only when there is no X-Forwarded-For, since Caddy and nginx pass it through as the client wrote it. An IPv6 address counts by its /64. An iroh stream counts by its node id.
  • A trusted peer that names no forwarded address is this machine itself (a health check, a test, the operator's CLI on loopback): it isn't limited. So the proxy in front must set X-Forwarded-For: Caddy does by itself; nginx needs the proxy_set_header X-Forwarded-For line above.
  • With the hub listening on 0.0.0.0 and no proxy, set trusted-proxies = (empty) if anything else on the machine could connect on someone's behalf; on loopback behind Caddy, keep the default.
  • A family behind one home NAT shares one address: 60 logins a minute is far above what its devices make, even after a hub restart (each client reconnects once, then resumes).
  • Not capped yet: spaces, rooms and bytes per account (phase 5 media brings quotas); space-create = admins covers a family hub meanwhile. Nor connections per address: max-connections is one cap for everyone (behind Caddy, idle connections end at Caddy).
  • A scripted flood checks them: tools/flood/flood.nim (--local against a scratch hub, --url against a running one), run by the suite (tests/test_flood.nim) and by tools/preprod-smoke.sh ("Real-network smoke test").

Health

  • GET /healthz on the hub's port (through the proxy too), with no sign-in: {"ok": true, "version": "0.1.0", "commit": "1a2b3c4d5e6f", "store": "writable"}, 200; 503 with "ok": false when the data directory stops taking a write (checked at most every 5 s) or the hub is stopping. Nothing secret, and cheap enough for an outside monitor every minute. HEAD /healthz gives the status alone.
  • The version is in dentatsu --version (dentatsu 0.1.0 (1a2b3c4d5e6f)) and at the end of the hub's start line (version=0.1.0 commit=1a2b3c4d5e6f). The commit is read from git when the program is built from a checkout (-dirty when src/ had uncommitted changes); a build from a tarball passes -d:dentatsuCommit=HASH, or says unknown.
  • Metrics (metrics = 127.0.0.1:7189, off by default): a second listener, on loopback only, answering GET /metrics in Prometheus's text format: connections, sessions, spaces, rooms, bytes queued to clients, federation links up and dropped frames, the Conduit home's events, what the caps refused (connections, sessions, logins, sign-ins, auth timeouts), the data directory's bytes, the resident memory, and the build. It is never on the public port, so the proxy can't expose it.
curl -fsS https://chat.example.org/healthz
curl -fsS http://127.0.0.1:7189/metrics

Admin commands

dentatsu hub admin is the operator's view of who signs in and what the hub holds. Run it as the hub's user, with the hub's config (or --data DIR):

sudo -u dentatsu dentatsu hub admin accounts --config /etc/dentatsu/hub.conf
CommandWhat it does
accounts (accounts list)Every account the hub knows: those that signed in here (first and last seen), the config's admins and allow-accounts, the rules; whether each is let in now (yes, no, by its PDS); its sessions (live)
accounts allow DIDA rule that lets the DID in (as allow-accounts does)
accounts deny DIDA rule that refuses the DID at every door, and ends its sessions
accounts clear DIDThe DID's rule removed
accounts end DIDThe account's connections closed and its sessions dropped (WebSocket and iroh, resumable, web, Conduit). An account still let in signs in again: to keep it out, deny it
spacesEach space: its file's bytes, rooms, the voters of its newest configuration (this hub a voter or a receiver), its log's incarnation
health/healthz (version, commit, store), sessions and spaces, the data disk's free space, the last hub backup's age. Unhealthy (exit 1) when the hub isn't running, its store is read-only, the disk has under --disk-free-pct (10) free, or the last backup is older than --backup-age-h (36) hours or missing

--json prints the answer as one JSON object. Exit codes: 0 done (health: healthy), 1 failed (health: unhealthy), 2 a usage mistake (a bad DID, denying an admin).

  • While the hub runs, the commands go through its admin socket: a Unix socket at admin-socket (default DATA/admin.sock; the unit's data is /var/lib/dentatsu), mode 0600 from the moment it exists, owned by the hub's user. The hub answers only a peer of its own uid (it checks the peer's credentials), not even root: run the command as the hub's user. It is never a network port. A change counts at once at every door. admin-socket = none turns the socket off.
  • While the hub is stopped, the same commands work on the data directory itself. The hub holds a lock on DATA/hub.lock while it runs; the offline commands take it too, so they never write beside a running hub (one without a socket is refused: ask it through the socket, or stop it). A second hub on the same data directory refuses to start for the same reason. Run them as the data directory's owner (they refuse otherwise: files SQLite makes as root would lock the hub out).
  • What it can't do: the operator has no keys to change a space; that stays its owner's. spaces reads; stopping hosting a space or deleting one isn't a command yet.
  • The hub logs each rule change and each ending of sessions (dentatsu hub: admin: …).
  • hub backup notes the backup it made in DATA/backup-last.json (left out of backups), which health reads.

Invites

dentatsu invite create SPACE [--expires SECONDS] [--uses N] [--role ROLE] prints a link:

https://chat.example.org/#invite=<space>.<invite>.<code>[.<checkpoint>]

The checkpoint (<version>-<gseq>-<prefix>) is the owner's newest checkpoint of the space's server list, when the member's log holds one (decision 0038): the newcomer's client and its hub take it as a floor, so a server that shows an older list can't mislead it.

The newcomer opens it in a browser (the hub's page signs them in, then joins), or runs dentatsu join LINK after dentatsu login (in the TUI, Ctrl+O and the link). Nobody needs to know their DID first. invite list and invite revoke manage them. docs/wire.md ("Invites") has the events and why the code never reaches the hub.

Moderating a space: roles and removing a member

A space's rules are its own, not the hub's: the owner (who founded it) has every permission and can't be removed; the others have what @everyone and their roles give them (Discord's model: the bits and the order are in src/dentatsu/log/perms.nim). The hub's operator can't change a space; only its members can, as their roles allow, and every server of the space checks each change against the same rules.

dentatsu role list family                                   # number, name, position, permissions, members
dentatsu role create family mods --perms kick-members,manage-roles,create-invite   # prints the role's number
dentatsu member roles family uncle.example.org --add mods   # or --remove mods, or --set mods,helpers (--set none)
dentatsu member roles family uncle.example.org              # their roles and what they may do
dentatsu role update family mods --perms +manage-channels   # +NAME, -NAME change it; --name, --position, --color
dentatsu role update family @everyone --perms -create-invite  # what everyone may do
dentatsu role delete family mods
  • Who may: making, changing and giving roles needs MANAGE_ROLES; a role you make or change must sit below your own top role and carry only permissions you have, and you give or take only roles below yours. The owner may do it all.
  • PERMS: names, comma-separated (dentatsu role create with a wrong one lists them all), default (what @everyone gets in a new space), all, none, or the number.
  • Refused: the command exits 1 with the space's reason ("missing MANAGE_ROLES", "role not below yours") and changes nothing.

Removing a member

dentatsu member remove family someone.example.org --reason "asked to leave"
  • Who may: a member with KICK_MEMBERS whose top role is above the member's; nobody removes the owner. Anyone may remove themselves (that is leaving: dentatsu member remove family MY-HANDLE).
  • What happens:
    • The account and every one of its devices leave the space at once: the hub refuses their requests in it from then on ("not a member of this space").
    • Their devices' places in each room's MLS group (its leaves) go with the next commit of any member's client, which makes one by itself within seconds to a minute (decision 0041). From that commit on they can't read new messages, even with what their devices kept.
    • What they read before stays on their devices: removal doesn't reach back.
  • They can come back with an invite still in force: revoke the ones they might hold (dentatsu invite list, then invite revoke). There are no bans yet (phase 5).

A lost device

A phone left in a taxi, a laptop stolen: remove that device from the account, and every hub refuses it. Nothing on the device needs to answer. (Pre-production has no recovery phrases, decision 0054: the account's PDS record of each device is what makes it the account's, decision 0028.)

From the web page, on any other device of the account: devices (beside sign out) lists the account's devices as the hub knows them: each one's name (its label), when it was added, when it last signed in to this hub, and whether it is online now. remove beside the lost one asks the account's own server (the PDS) to approve, in the same short sign-in as sign-out, which may only delete device records. Back on the page, the list says what happened.

From the CLI (dentatsu login on a device of the account):

dentatsu device list family            # the account's devices; with a space, where each stands in it
dentatsu device revoke did:key:z6Mk…   # the lost one: prints a URL to approve in a browser

What happens, for an atproto account (on our PDS or another):

  1. Its record is deleted at the account's PDS. Removing it from the page goes through the hub, which then knows at once; from the CLI, each hub sees it gone at its next look (device-watch-s, 60 s by default).
  2. Its sessions end: the hub closes its connections, telling it why, forgets its sessions, and refuses its next login ("removed"). A resumed session is checked the same way.
  3. Every space it was in removes it: each server of the space orders its device.remove. The space keeps the key as removed, so it can't come back, not even with its old record put back or its old grant.
  4. Its places in rooms' encrypted groups go with the next commit a member's device makes there (the web page and the TUI do it by themselves within a minute, the CLI on its next command in the space: decision 0041). From then on it can't read anything new. What it read before stays on it: removal doesn't reach back.

device list (and the page) shows the removed device as "removed" while the hub still remembers it signed in, with how many rooms' groups still hold it.

  • A did:key account (no PDS) removes another device only from its device 0, the account's own key: dentatsu device revoke there signs the removal in every space that device knows. Any device may remove itself.
  • An account with a recovery phrase may also remove a device from one space with the root: dentatsu device remove SPACE DID:KEY --phrase-env VAR.
  • No other device at hand: sign in on a new one first (the page, or dentatsu login), then remove the lost one from there. A family member who forgot their password asks the admin to reset it (pdsadmin).

When a connection drops

The CLI's tail, the TUI and the web client reconnect by themselves, and resume the session instead of logging in again: hello carries a proof the device signed for its last session, and the room subscriptions go right behind it, from the last message each client saw. One round trip after the WebSocket is up, and nothing is missed or shown twice (docs/wire.md, "Resume"). A hub that restarted has forgotten its sessions, and a session older than resume-s is gone: then the client logs in as before, in the same flow.

The hub's key

The hub proves its key at every login (it signs the client's nonce), and the CLI pins the key each URL proved. A server that answers at a pinned URL with another key is refused unless the space's own log names that key (a server the owner's server list added, after a space move). A server the client meets for the first time is checked against the log once it is synced: it must be one of the space's servers (docs/wire.md, open question 19).

A whole machine

One always-on Linux machine with systemd runs everything: Caddy on TCP 443 in front of the public site (DOMAIN and www.DOMAIN: the landing page, the guides, registration; site/), the hub (chat.DOMAIN) and an atproto PDS for the family's accounts (pds.DOMAIN, deploy/pds/), the hub's iroh and voice on forwarded UDP ports, and a nightly encrypted backup to another disk (decision 0057 put the site at the apex). The names here are placeholders: DOMAIN is your domain on Cloudflare (example.org), handles are NAME.DOMAIN. Your own names, addresses and DIDs go in /etc on the machine, never in this repository.

WhatWhereReached from outside as
CaddyTCP 443 (80 not needed: certificates by DNS-01)https://DOMAIN/ (and www.), https://chat.DOMAIN/, https://pds.DOMAIN/
the sitestatic files in /usr/local/share/dentatsu/site, served by Caddythrough Caddy
hub (dentatsu-hub.service)TCP 127.0.0.1:7180; UDP 0.0.0.0:7180 (iroh); UDP 0.0.0.0:7181 (voice)through Caddy; UDP 7180 and 7181 forwarded
PDS (deploy/pds/)TCP 127.0.0.1:3000through Caddy
registration (dentatsu-register.service, deploy/register/)TCP 127.0.0.1:7190https://DOMAIN/register through Caddy
data/var/lib/dentatsu (hub), /srv/pds (PDS)
backupsdentatsu-backup.timer → BACKUP_DIR on another disk
monitoringdentatsu-check.timer every 5 min; OnFailure= on the hub, backup and DDNS units → ntfyan outside uptime check of https://chat.DOMAIN/healthz

Every file is in deploy/hub/: the unit dentatsu-hub.service, hub.conf.example, Caddyfile.example, caddy-cloudflare.conf (Caddy's token, from a file), Containerfile.caddy, install.sh, the backup (dentatsu-backup.sh, its .service and .timer, backup.conf.example) and restore-drill.sh; the monitoring is in deploy/monitor/, the registration (invites and the /register page) in deploy/register/. CI checks them (.nd/ci.md, step deploy-check); nothing in CI touches a real machine, DNS or Cloudflare.

Before you start: user-only steps

Nothing in this repository does these. Each one is marked user-only; the rest of the recipe works around them.

  1. User-only: check for CGNAT. Compare the WAN address on the router's status page with curl -4 https://icanhazip.com run on the machine. If they differ, or the router's is in 100.64.0.0/10, the line is behind carrier-grade NAT and no port can be opened: use a Cloudflare Tunnel for HTTPS, iroh-relay = n0 (or an own relay on a VPS), and no voice (the tunnel variant, not this recipe).
  2. User-only: static or dynamic IPv4. Ask the ISP, or watch the address for a few days. A dynamic address needs the DDNS timer (deploy/cloudflare/); the hub follows it by itself while iroh-addrs and voice-public name chat.DOMAIN (the example's way: "A dynamic address" above).
  3. User-only: IPv6. curl -6 https://icanhazip.com. With a global IPv6 address, add AAAA records and a second iroh-addrs entry ([ADDR]:7180); open the same ports in the router's IPv6 firewall (there is no NAT to forward).
  4. User-only: forward the ports on the router to the machine's LAN address (give it a DHCP reservation first): TCP 443, UDP 7180 (iroh), UDP 7181 (voice). TCP 80 isn't needed. Open the same ports in the machine's firewall (ufw allow 443/tcp; ufw allow 7180/udp; ufw allow 7181/udp).
  5. User-only: hairpin NAT. The hub and the PDS fetch each other's public names (OAuth metadata, DID documents), and family members at home use the same names, so the router must hairpin: from the machine itself, and from a laptop on the LAN, curl -sI https://chat.DOMAIN/ must answer once Caddy runs. Without hairpin, turn it on in the router (often "NAT loopback"), or use split DNS (a LAN resolver answering the machine's LAN address), which then needs fetch-allow = LAN-CIDR in hub.conf; but the PDS refuses the hub's OAuth client metadata at a private address (its SSRF protection: "Real-network smoke test", step 10), so web sign-in needs hairpin, not split DNS, for the PDS's container.
  6. User-only: mint the Cloudflare token. Cloudflare dashboard → My Profile → API Tokens → Create Token → the "Edit zone DNS" template. Permissions: Zone → DNS → Edit and Zone → Zone → Read. Zone Resources: Include → Specific zone → DOMAIN (only that zone). Optionally limit it to your public IP (Client IP Address Filtering) and give it an end date. Keep it in the password manager. It goes on the machine in two root-only files: /etc/caddy/cloudflare.env (CF_API_TOKEN=..., mode 0600, for Caddy's DNS-01) and, for the DNS scripts, /etc/dentatsu/cloudflare.token (the token alone, mode 0600; deploy/cloudflare/). Never on a command line, in an environment dump, or in a repository.
  7. User-only: the backup disk and key. Mount the other disk (for example at /srv/backup, in /etc/fstab), and make an age key pair on another machine (age-keygen -o dentatsu-backup.key): keep the private key in the password manager, and put only the public line (age1...) in /etc/dentatsu/backup-recipients.txt on this one. Add RequiresMountsFor=/srv/backup to the backup's unit (below, "Backups"). The private key comes back to the machine only for a restore or the monthly restore drill, and is deleted after (below, "The restore drill").
  8. User-only: the PDS's secrets. After make-env.sh (below, "The PDS"), copy the PLC rotation key and the admin password from /srv/pds/pds.env into the password manager.
  9. User-only: the first accounts. new-account.sh for each family member (below), or an invite each (dentatsu-register invite create, below, "Invites and registration"), and the friends' DIDs in hub.conf's allow-accounts (or dentatsu hub admin accounts allow DID) when allow-pds doesn't cover them.
  10. User-only (recommended): full-disk encryption on the machine. The hub keeps its key and the plaintext of the rooms it is a visible member of (room hub, for search) in its data directory; the PDS keeps its rotation key in its env file.
  11. User-only: a notification topic and an outside check (below, "Monitoring"): pick an ntfy server and topic, put its URL in /etc/dentatsu/ntfy.url, and point a free uptime checker at https://chat.DOMAIN/healthz.
  12. User-only: a narrow token for the registration service. The registration writes _atproto.NAME TXT records on its own, from a page anyone can reach, so its token must be the narrow one of step 6: Zone → DNS → Edit and Zone → Zone → Read on DOMAIN only (better a second token with the same scope, so it can be revoked alone; limit it to the machine's public IP). Never an account-wide token or one that sees other zones. It goes in /etc/dentatsu/cloudflare.token (0600 root), which systemd hands to the service as a credential.
  13. User-only: the release onto the machine. Build it on the desktop (tools/bundle.sh), copy the tarball and its .sha256 over, and run install.sh there as root (below, "Install the hub"). Nothing here logs in to the machine.

Caddy with the Cloudflare module

Plain Caddy has no Cloudflare DNS provider: DNS-01 needs a Caddy built with caddy-dns/cloudflare. One of:

  • The distribution's caddy package, plus the module (Debian, Ubuntu): install caddy from Caddy's apt repository (or the distribution's own: Ubuntu 26.04's universe has 2.6.2, too old for Caddyfile.example's stream_close_delay, which needs 2.7, until add-package replaces it with the current release), then caddy add-package github.com/caddy-dns/cloudflare (it downloads a build with the module from caddyserver.com and replaces the binary). An upgrade of the package puts the plain binary back: run add-package again after each one, or apt-mark hold caddy.
  • xcaddy (Go installed): go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest, then xcaddy build --with github.com/caddy-dns/cloudflare and install the caddy it makes as /usr/bin/caddy (dpkg-divert --divert /usr/bin/caddy.default --rename /usr/bin/caddy first, so the package keeps its hands off it).
  • A container: podman build -t localhost/caddy-cloudflare -f deploy/hub/Containerfile.caddy deploy/hub, run with --network host (it reaches the hub and the PDS on loopback), the Caddyfile mounted at /etc/caddy/Caddyfile, a volume for /data (certificates) and --env-file /etc/caddy/cloudflare.env.

caddy list-modules | grep cloudflare shows dns.providers.cloudflare when it's in. The token reaches a native Caddy by the systemd drop-in caddy-cloudflare.conf (EnvironmentFile=/etc/caddy/cloudflare.env), which install.sh --caddy puts in place. The drop-in also starts Caddy without --environ: the packaged unit runs caddy run --environ, which prints the whole environment, the token with it, into the journal at every start. Make /etc/caddy/cloudflare.env from the DNS scripts' token file (below, "DNS records") instead of typing the token a second time; nothing is printed:

umask 077
sed -n 's/^\(CF_API_TOKEN\|apiToken\|token\)=/CF_API_TOKEN=/p' /etc/dentatsu/cloudflare.token > /etc/caddy/cloudflare.env
# a token file holding the token alone: { printf 'CF_API_TOKEN='; cat /etc/dentatsu/cloudflare.token; } > /etc/caddy/cloudflare.env
grep -c '^CF_API_TOKEN=' /etc/caddy/cloudflare.env      # 1: a count, not the token

Then /etc/caddy/Caddyfile from Caddyfile.example (the same flag writes it when there is none): replace DOMAIN and ADMIN_EMAIL, systemctl reload caddy, and journalctl -u caddy shows each certificate obtained.

DNS records

deploy/cloudflare/cf.py (standard-library Python: uv run deploy/cloudflare/cf.py … or python3 …) writes the records through Cloudflare's API with the token in /etc/dentatsu/cloudflare.token (the token alone, or CF_API_TOKEN=…; mode 0600, root). It reads the token from that file only (--token-file names another), never from an argument or the environment, and never prints it. Every command only prints what it would change until you add --apply.

RecordValueMade by
DOMAIN and www.DOMAIN A (and AAAA)the public address, DNS only: the sitecf.py --zone DOMAIN upsert @ A ADDR (and www), or the DDNS timer
chat.DOMAIN A (and AAAA)the public address, DNS only (grey cloud)cf.py --zone DOMAIN upsert chat A ADDR, or the DDNS timer
pds.DOMAIN A (and AAAA)the samecf.py --zone DOMAIN upsert pds A ADDR, or the DDNS timer
_atproto.NAME.DOMAIN TXTdid=did:plc:…, one per personcf.py --zone DOMAIN handle NAME DID (deploy/pds/new-account.sh calls it)
relay.DOMAIN A/AAAAan own iroh relay on a VPS, latercf.py --zone DOMAIN upsert relay A ADDR
cf.py --zone DOMAIN status                          # chat, pds, relay and every _atproto/_lexicon TXT
cf.py --zone DOMAIN upsert chat A 203.0.113.7       # prints "would create …"; again with --apply to do it
cf.py --zone DOMAIN --apply handle mom did:plc:…    # the handle mom.DOMAIN
cf.py --zone DOMAIN --apply delete relay A

upsert keeps one record per name and type (it updates the one there, and deletes duplicates); handle replaces only the name's did= TXT records. Records are DNS only unless --proxied: the hub's WebSockets, iroh and voice must reach the machine directly.

A dynamic address: the DDNS timer. dentatsu-ddns.timer runs cf.py ddns every 5 minutes: it asks a public "what is my address" URL (https://api.ipify.org, and https://api6.ipify.org for IPv6; --ipv4-source and --ipv6-source pick others, --no-ipv6 skips AAAA records) and points the names in DDNS_NAMES (chat, pds, and the site's @ and www) at the answer. A hub whose voice-public and iroh-addrs name chat.DOMAIN (hub.conf.example's way) follows by itself within resolve-s seconds plus the record's TTL (Cloudflare's automatic TTL for a DNS-only record: 5 minutes): nothing is rewritten or restarted. Where those keys are IP literals instead, the timer swaps the old IPv4 address (the one the chat A record held before) for the new one in hub.conf and restarts a running hub (--hub-conf and --on-hub-change in the unit; --on-change CMD runs a command after any change). Settings in /etc/dentatsu/ddns.env (DDNS_ZONE, DDNS_NAMES, DDNS_EXTRA, from ddns.env.example); install.sh --ddns --start turns it on; journalctl -u dentatsu-ddns shows each run. On a line without global IPv6, DDNS_EXTRA=--no-ipv6 (else each run asks api6.ipify.org in vain). With a static address, leave it off and set the records once with upsert.

The release bundle

One tarball holds a release, built on the desktop from a commit (tools/bundle.sh, about as long as nd build, the bridge's cargo build and the web build together; the first time longer):

tools/bundle.sh                 # dist/dentatsu-0.1.0-COMMIT-x86_64-linux.tar.gz and its .sha256
tools/bundle.sh --web web/dist  # with a web client built before (web/build.sh), instead of building it again

It refuses a tree with uncommitted changes in src/, rust/, web/ or deploy/ (--allow-dirty builds anyway and says -dirty). Inside the tarball, one directory dentatsu-VERSION-COMMIT-x86_64-linux/:

PathWhat
bin/dentatsuthe program: nd build (-d:release, the Rust core linked in)
bin/dial-irohthe iroh bridge: cargo build --release --locked of the dial-iroh checkout beside this one (--dial-iroh-src DIR for another)
web/the web client: web/build.sh (the emsdk container, this desktop)
site/the public site: site/build.sh (node; the landing page, guides, privacy, this page, the style page)
deploy/the recipes: hub/ (with install.sh), cloudflare/, pds/, iroh-relay/
VERSIONkey=value lines: version, commit, built, arch=x86_64-linux-gnu, glibc (the newest glibc symbol version the programs need), loads (the libraries the program opens at run time, any one of them: libcurl.so.4, libcurl-gnutls.so.4, libcurl.so), dial-iroh (the bridge's commit), web, libs (each sibling library's commit)
SHA256SUMSevery other file's SHA-256, in sha256sum's format

The tar is sorted, owned by root, writable by the owner alone, and stamped with the commit's time, so the same files make the same tarball.

glibc, not static. The programs are linked dynamically against the build machine's glibc, and VERSION's glibc is the newest symbol version either of them asks for. They run on any x86_64 Linux whose glibc is that or newer. On 2026-11-27 the desktop had 2.39 and the bundle said glibc=2.39: dentatsu needs 2.34, but dial-iroh references pidfd_spawnp (2.39) through Rust's standard library, and that version isn't marked optional in the binary, so an older glibc refuses to load it. genji, the machine it is for, has 2.43, so the desktop's build runs there; a target older than the desktop would need a build on an older system (a container), which this script doesn't do. install.sh compares VERSION's glibc with the machine's (getconf GNU_LIBC_VERSION) and refuses an older one. A static musl build was not chosen: the hub opens libcurl at run time for its fetches (dlopen), which a static musl program can't do, and the Rust core's build and cargo have no musl target set up here. So the machine needs libcurl.so.4 (Debian and Ubuntu: libcurl4; Arch and Fedora: curl's libraries), and install.sh says so when it is missing. (Rex's trap on genji was the other way round: a musl binary on a machine with no musl loader.)

Install the hub

User-only: copy the tarball and its .sha256 to the machine (scp dist/dentatsu-…* genji:), then as root there:

sha256sum -c dentatsu-…-x86_64-linux.tar.gz.sha256
tar xzf dentatsu-…-x86_64-linux.tar.gz
R=dentatsu-…-x86_64-linux                                  # the unpacked release
$R/deploy/hub/install.sh --caddy --dry-run                 # what it would do (the release around it is the bundle)
$R/deploy/hub/install.sh --caddy                           # user, files, units; starts nothing
$EDITOR /etc/dentatsu/hub.conf                             # the placeholders in capitals (below)
$R/deploy/hub/install.sh --start                           # enable and start the hub and the backup timer
journalctl -u dentatsu-hub -f

A later release: /usr/local/share/dentatsu/deploy/hub/install.sh --bundle NEW.tar.gz --start (any install.sh takes a tarball). Given a tarball, install.sh checks it against the .sha256 beside it when there is one, unpacks it into a temporary directory and hands over to the install.sh inside it, so the recipes installed are that release's. Before it changes anything, it checks every file against SHA256SUMS (a changed, missing or extra file refuses the release), VERSION's arch and glibc against the machine's, and warns when libcurl.so.4 is missing. --no-verify takes a directory without SHA256SUMS (parts gathered by hand).

install.sh is idempotent: run it again with a newer bundle and it replaces only what changed, restarts a running hub when its program, bridge, web client or unit changed, and never overwrites /etc/dentatsu/hub.conf or backup.conf once they exist (the examples stay in /usr/local/share/dentatsu/deploy/, and the release's VERSION in /usr/local/share/dentatsu/VERSION). It refuses --start while hub.conf still has placeholders. --dry-run prints what it would change and changes nothing; --root DIR installs into a staging tree instead of / (no user, no systemctl; the CI tests do that).

CI builds a real bundle (.nd/ci.md, step bundle), installs it into a scratch root and starts the installed hub on loopback (--version, /healthz, the page); deploy-check tests install.sh's checks with a fake release.

hub.conf (hub.conf.example): the TCP port on loopback for Caddy, the data directory, the web client, web-url = https://chat.DOMAIN/, the public plc.directory, one I/O thread, iroh on UDP 7180 with iroh-addrs = chat.DOMAIN:7180 and no relay, voice on UDP 7181 with voice-public = chat.DOMAIN (both resolved again every resolve-s = 60 seconds: "A dynamic address"), Conduit off, and who may sign in: accounts = listed, allow-pds = https://pds.DOMAIN (every account on your PDS), allow-accounts (friends on other hosts, by DID), admins and space-create = admins; trusted-proxies for Caddy's X-Forwarded-For. Those access keys come with plans' W1 and W3; a hub built before them refuses to start with them (on purpose: it never starts open by mistake).

The site (site/: site/build.sh renders site/pages and this page with the shared design): install.sh puts the release's site/ in /usr/local/share/dentatsu/site (no restart: Caddy reads the files), and Caddyfile.example's DOMAIN block serves it, with www.DOMAIN redirected there and a missing page answered by its 404.html. Its "Sign in" links go to /app/, which that block redirects to https://chat.DOMAIN/, so the built site names no host and works for any domain; site/build.sh --app-url URL links the web client directly instead. "Get an account" goes to /register (plans W19). To serve the site under another name, change the two site blocks' addresses and the DNS records; nothing in the site changes. CI builds it and checks its links and HTML (.nd/ci.md, step site).

The unit (dentatsu-hub.service) runs the hub as the system user dentatsu (made by systemd-sysusers from dentatsu.sysusers), with /var/lib/dentatsu as its StateDirectory, /run/dentatsu for voice-stats, and a sandbox: ProtectSystem=strict, ProtectHome, PrivateTmp, PrivateDevices, NoNewPrivileges, no capabilities, RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK (dial-iroh's pipes and network-change events), MemoryMax=512M (a guess until plans' W15 measures the whole hub), LimitNOFILE=65536, Restart=on-failure. Its child dial-iroh stops with it.

Check it:

  • systemctl status dentatsu-hub; the log's listening … line.
  • curl -fsS http://127.0.0.1:7180/healthz on the machine (plans' W4, once the hub has it).
  • curl -sI https://chat.DOMAIN/ from outside and from the LAN (hairpin): 200, with the hub's COOP and COEP headers.
  • The web page signs in a listed account and refuses an unlisted one; a native client's log shows iroh connected (from outside the LAN: the UDP forward works); a call between two people outside the LAN.

The PDS

Family accounts live on our own atproto PDS at pds.DOMAIN: the official image (ghcr.io/bluesky-social/pds:0.4, the tag upstream's compose.yaml uses) on TCP 127.0.0.1:3000 behind the machine's Caddy, its data and env file in /srv/pds. Not upstream's installer: it brings its own Caddy (which would collide with ours on 80 and 443), a wildcard on-demand certificate and watchtower's automatic upgrades. Friends keep their accounts elsewhere (bsky.social or any PDS) and are admitted by DID (allow-accounts).

What dentatsu needs from a PDS (the same for ours and for any friend's):

  • the atproto OAuth authorization server, with PAR, PKCE, DPoP and granular repo: scopes (the reference PDS 0.4 and bsky.social take repo:<nsid> in PAR): the CLI's and the web page's sign-in only enrolls a device, and hub sessions use the device key after that;
  • writes with com.atproto.repo.applyWrites and validate=false on dentatsu's two collections (city.goodboy.dentatsu.device and city.goodboy.dentatsu.identity);
  • com.atproto.sync.getRecord (the record with its proof), com.atproto.sync.getLatestCommit and the record listing: the hub checks devices with them and watches for removed ones every 60 s;
  • public HTTPS at its name, reachable from the hub's machine (hairpin), and the hub's https://chat.DOMAIN/ reachable from the PDS (it fetches the hub's OAuth client metadata).

Nothing else: no AppView, no relay, no email. Unverified until plans' W14 (the real-network test): whether the PDS's rate limits see Caddy's X-Forwarded-For or count every request as from 127.0.0.1, and whether it refuses the hub's client metadata at a private address when split DNS is used instead of hairpin.

Set it up (as root, from /usr/local/share/dentatsu/deploy/ or a checkout):

pds/make-env.sh DOMAIN                     # /srv/pds/pds.env, mode 0600, fresh secrets (never printed)
hub/install.sh --pds podman --start        # or --pds docker: the quadlet (or a unit around docker compose)
curl -fsS https://pds.DOMAIN/xrpc/_health  # {"version":"0.4..."}
  • User-only: copy the PDS's secrets into the password manager: PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX controls every DID made on this PDS, and PDS_ADMIN_PASSWORD is the admin's. The nightly backup carries the env file too, encrypted.
  • pds.env.example follows upstream's installer, with PDS_INVITE_REQUIRED=true, PDS_CRAWLERS empty (the accounts don't announce themselves to Bluesky's relay; https://bsky.network if the family wants Bluesky's apps too), the public https://plc.directory, and no email yet (PDS_EMAIL_SMTP_URL and PDS_EMAIL_FROM_ADDRESS later).
  • The podman variant is a quadlet (/etc/containers/systemd/dentatsu-pds.container, podman 4.4 or newer): systemd generates dentatsu-pds.service from it, which starts at boot by itself. The docker variant is /etc/systemd/system/dentatsu-pds.service around /etc/dentatsu/pds-compose.yaml. Either way the unit is dentatsu-pds.service, the name the backup stops and starts; the container is capped at 1 GB.
  • Upgrades: change the image tag in the quadlet (or the compose file), systemctl daemon-reload, systemctl restart dentatsu-pds, after reading the PDS's release notes and with a fresh backup.

An account for a family member (user-only: the first accounts are yours to make):

pds/new-account.sh mom mom@example.org

It makes a one-use invite code and the account under the temporary handle mom.pds.DOMAIN (through the PDS's admin API on loopback, as pdsadmin account create does), writes _atproto.mom.DOMAIN TXT "did=…" with cf.py handle, waits until public DNS answers it, sets the handle mom.DOMAIN, and prints the account's first password once (hand it over), with the next steps: sign in at https://chat.DOMAIN/ (or through an invite link) with mom.DOMAIN; the hub admits accounts on this PDS by allow-pds = https://pds.DOMAIN, else add the DID to allow-accounts and restart the hub. NAME is 3 to 18 letters, digits or hyphens. When the record or the handle step fails, it says so and how to finish later: new-account.sh --set-handle mom DID. --dry-run says what it would do.

  • No email yet, so a forgotten password is reset by the admin: PDS_ENV_FILE=/srv/pds/pds.env pdsadmin account reset-password DID (upstream's pdsadmin downloads its subcommand from GitHub each time and runs it as root: read it first, or post com.atproto.admin.updateAccountPassword yourself with the admin password).
  • Repositories are public: anyone who knows a DID can read its device records and their labels. Keep device labels generic ("phone", not "Mom's iPhone").

Invites and registration

Family members get their own account on our PDS from the site: an admin makes an invite, hands over its link (https://DOMAIN/register?code=…), and the person picks a name, a password and, if they like, an email. They end up with the handle NAME.DOMAIN and are signed in to the chat at https://chat.DOMAIN/. Friends who already have an atproto account (bsky.social or any PDS) don't register: an admin lists their DID (allow-accounts, or dentatsu hub admin accounts allow DID) and they sign in with it.

It is a small service of its own, dentatsu-register (deploy/register/register.py: standard-library Python like cf.py, which it imports), not part of the hub. Who holds which secret:

WhoHoldsCan
dentatsu-register.service, user dentatsu-registerthe Cloudflare token (systemd LoadCredential= from /etc/dentatsu/cloudflare.token, so a copy only it reads); its database /var/lib/dentatsu-register/register.db (0600): invites (their codes only as hashes) and one PDS invite code per invitecreate an account with an invite's PDS code; write and delete _atproto TXT records; act as a new account in its first minute (the session createAccount gives it, revoked at the end)
root: dentatsu-register invite create/revoke, dentatsu-register sweep (hourly timer)PDS_ADMIN_PASSWORD, read from /srv/pds/pds.env each time, never copied; then they drop to the dentatsu-register user for the databasemint and disable PDS invite codes; delete the accounts a failed registration left deactivated
the hubneitherlet the new accounts in by allow-pds = https://pds.DOMAIN
Caddyits own DNS-01 token (/etc/caddy/cloudflare.env)route /register and /register/* to 127.0.0.1:7190

Why this split: the PDS's admin password can reset any account's password (a takeover of every family account), so it stays out of anything the internet reaches. A registration needs none of it: the invite's PDS code creates the account, and everything after is done as that account (com.atproto.identity.updateHandle, and on a failure the switch back and com.atproto.server.deactivateAccount). What only an admin can do (a new PDS invite code, deleting an account) waits for root's commands. The DNS token can change any record in the zone (Cloudflare can't narrow a token to some names), which is why the service runs as its own sandboxed user, the token is the narrow one-zone token (user-only step 12), and the hub never sees it.

Set it up (as root):

hub/install.sh --register --start      # user dentatsu-register, /etc/dentatsu/register.conf, the page, the units
$EDITOR /etc/dentatsu/register.conf    # DOMAIN; then install.sh --register --start again enables it

and in /etc/caddy/Caddyfile the DOMAIN, www.DOMAIN site of Caddyfile.example (the @register route; the rest of the site is static files). curl -fsS https://DOMAIN/register/healthz answers {"ok": true}. It needs our PDS (above) and the narrow Cloudflare token.

Make an invite (as root; one account each, used once, expiring):

dentatsu-register invite create --expires 7d --note mom
#   invite 3 (mom), one account, until 2026-12-04 18:00 UTC:
#     code: k7mq-p2xz-9fhd-wt4c
#     link: https://DOMAIN/register?code=k7mq-p2xz-9fhd-wt4c
dentatsu-register invite list [--all] [--json]     # open ones; --all: used (by whom), expired, revoked
dentatsu-register invite revoke 3                  # withdrawn, and its PDS code disabled

The code is shown once (the database keeps a hash). --expires takes 12h, 7d, 2w, at most 90d. Each invite gets a PDS invite code good for three accounts (pds-tries): one registration, and two tries more after a failure that was undone; the service's own rule makes it one account.

What a registration does (one at a time; the page shows each step):

  1. The account on the PDS under a random temporary handle on the PDS's own domain (r-XXXXXXXXXX.pds.DOMAIN; createAccount takes only a handle the PDS serves), with the invite's PDS code.
  2. The TXT record _atproto.NAME.DOMAIN "did=DID" (cf.py's upsert), after checking the zone again that nothing is at or under NAME.DOMAIN.
  3. Once public DNS answers it (Cloudflare's DoH, doh-url; up to dns-wait-s, 180 s), the handle NAME.DOMAIN, which the PDS takes only after resolving the record itself (tried again a few times while its resolver catches up).
  4. The check: the PDS resolves NAME.DOMAIN to the DID, the PLC document names at://NAME.DOMAIN, public DNS still answers. Then the invite is spent, the session revoked, and the page goes on to https://chat.DOMAIN/oauth/login?handle=NAME.DOMAIN: the chat's own sign-in, where the PDS asks for the password (the handle filled in) and to allow dentatsu, and the browser gets its device.

A failure undoes what was done, newest first: the handle switched back to the temporary one, the TXT record deleted, the person's email swapped for a placeholder (so they can use it again at once), the account deactivated, the invite usable again. The person sees what went wrong ("that name was taken a moment ago", "your name didn't show up in DNS in time", ...) and that nothing was kept. The deactivated account is deleted by the next sweep (hourly; its DID stays in the PLC directory, unused). A service stopped half-way deletes the job's TXT record at its next start and leaves the account to the sweep.

Names. 3 to 30 lowercase letters, digits and hyphens, not at either end and never two in a row. Reserved: the zone's services and the usual staff, mail and DNS names (admin, www, chat, pds, iroh, play, ntfy, flood, git, grafana, wiki, book, mail, mg, observer, ocapi, portal, thunder, sentry, unms, relay, register, help, support, no-email, … the list is RESERVED in register.py; reserved = in register.conf adds more), and any name with a record at or under it in the zone (genji.local.DOMAIN takes local). The page checks as you type; the zone is read from Cloudflare's API (kept 30 s; read again before anything is written).

How dentatsu finds a handle. A handle NAME.DOMAIN has only its TXT record (its well-known file isn't served: *.DOMAIN goes elsewhere), and atproto's resolver in dentatsu has no DNS of its own, so the hub (doh = in hub.conf, for the web sign-in and the handles the page shows) and the CLI and TUI (--doh) ask the record over DNS over HTTPS, https://cloudflare-dns.com/dns-query by default (none: the well-known file only, as before). Names under special-use TLDs (.test, .local, .example, ...) never go there.

No email yet. The PDS requires an email address. Without one the account gets NAME-XXXXXX@no-email.DOMAIN, an address in our own zone that receives nothing (the PDS sends no mail without SMTP anyway); the page says so. A forgotten password is reset by the admin (above, "The PDS"); when SMTP comes, the admin can set a real address (com.atproto.admin.updateAccountEmail). Optionally give no-email.DOMAIN a null MX record (MX 0 ., RFC 7505).

Caps (register.conf, per address as Caddy's X-Forwarded-For gives it, and for everyone): name checks rate-check = 30/min (rate-check-all = 600/min), registrations rate-create = 3/hour (rate-create-all = 20/hour), wrong, used or expired codes rate-invite = 10/hour. Past one: HTTP 429 with Retry-After, and the page says how long. Codes are 16 characters from 31 (about 79 bits), so guessing isn't the threat the cap is for.

What it logs (journalctl -u dentatsu-register): each step with the name, DID, invite number and address; never a password, an invite code, a PDS invite code or the token.

Backups

dentatsu-backup.timer runs dentatsu-backup.sh each night at about 04:40 with /etc/dentatsu/backup.conf:

  1. The hub, online. dentatsu hub backup (run as HUB_USER, the data's owner, so SQLite never makes files the hub can't open) copies the data directory that HUB_CONFIG (hub.conf) names while the hub runs: no stop, no dropped connections. It writes a staging copy to HUB_STAGING (/var/lib/dentatsu-backup, on the data's disk, where the data is in plaintext anyway). The script then streams the copy through tar and age into BACKUP_DIR as hub-STAMP.tar.zst.age and removes the staging copy. The backup disk never holds plaintext.
  2. Each other set (SETS): /etc/dentatsu (the configs and the Cloudflare token; nothing is stopped) and the PDS (/srv/pds with its env file and rotation key; the PDS's unit is stopped for the seconds the copy takes, and only if it runs). Each set's directories go through tar and age into NAME-STAMP.tar.zst.age.

Each archive gets a .sha256 beside it, and the newest KEEP of each name stay. The script refuses a BACKUP_DIR on the same file system as the data (REQUIRE_OTHER_DISK=no allows it). systemctl start dentatsu-backup runs one now, dentatsu-backup.sh --set hub backs up only the hub, and dentatsu-backup.sh --dry-run says what it would do. Add RequiresMountsFor=/srv/backup in a drop-in (systemctl edit dentatsu-backup) so that a missing disk fails the run.

What dentatsu hub backup DIR writes (by hand too: runuser -u dentatsu -- dentatsu hub backup /srv/backup/now --config /etc/dentatsu/hub.conf). DIR must be new or empty. It must be on another file system than the data, unless you give --same-disk. It holds:

  • data/: the data directory's tree. Every SQLite file (hub.db, spaces/*.db, the MLS vaults, the Conduit member's files) is copied with SQLite's online backup API: each copy is one moment of its file (one read transaction), made whole without a -wal file, and checked with quick_check. Every other file (hub.key, web-oauth.key, fed/, evidence/) is copied as it is. The backup leaves out SQLite's journals, files being written (.tmp, .part) and the health probe. hub.db is copied first, so every space it lists has its file in the copy. Each file is consistent by itself, not with the others. A restore makes the hub a new incarnation (below), so nothing it signs depends on two files agreeing.
  • config/hub.conf: the config file, when --config names one.
  • manifest.json, written last (a directory without it is an unfinished backup): format (dentatsu-hub-backup), version (1), id, created (UTC) and created_ms, hub (key: the hub's public key, its identity; version; commit), host, data (the directory it came from), config, spaces (the spaces hub.db lists) and files (each file's path, size, sha256 and kind: sqlite or file).
  • The copy's hub.db is marked as a copy of this backup (see "Restore").

The files are private (0700 directories, 0600 files): the copy holds the hub's key.

Restore

A hub is a voter in the spaces and rooms whose server list names it as a sequencer. A copy from a backup holds an older log than the hub signed for after the backup. Started as if it were the original, the copy could vote again in a term it already voted in, or sign a different entry at a sequence number that the original already signed: equivocation. So a restored hub always comes back as a new incarnation (the 0.3 engine's: a voter is a server and an incarnation). It gets a new random incarnation for every space log, room and Conduit room it holds, with no vote, no ballot and no released term. A new incarnation signs no ballot, ack or commit until a server list names it. Until then it follows: the other voters' appends bring its log up to date, and it serves its users from it.

A copy refuses to start as the original. A backup's hub.db carries a mark. A hub started on a directory with the mark exits 2 and points here. The hub refuses instead of only warning, because a warning in a unit's log is read after the copy has already voted. Use one of these two ways to start a copy:

  • dentatsu hub restore BACKUP --data DIR (or --config FILE) checks every file against the manifest. A file that is missing, a different size or a different SHA-256 fails the restore (exit 1), and the restore names the file. It copies the data into DIR, which must be empty, and makes it a new incarnation. Then start the hub as usual. The config file stays in the backup (config/hub.conf): put it back by hand if needed.
  • dentatsu hub --restored, once, for a copy made some other way (a tar of the data directory, a file system snapshot): the hub makes itself a new incarnation before it opens anything, then serves. Don't leave the flag in the unit: each start with it makes yet another incarnation.

On a stopped hub, with the private key from the password manager (user-only: the key never stays on the machine):

systemctl stop dentatsu-hub
mv /var/lib/dentatsu /var/lib/dentatsu.old                       # keep it until the hub runs again
mkdir -m 0700 /root/restore
age -d -i dentatsu-backup.key /srv/backup/dentatsu/hub-STAMP.tar.zst.age | tar -C /root/restore -x --zstd
dentatsu hub restore /root/restore --data /var/lib/dentatsu       # checks, copies, new incarnation
chown -R dentatsu:dentatsu /var/lib/dentatsu
systemctl start dentatsu-hub                                     # its start line says incarnation=…

dentatsu hub restore and the hub's log list the engines that have no other voter. These are spaces (and their rooms, and Conduit rooms) whose only sequencer is this hub, as on a one-machine setup. Nothing can name the new incarnation there by the usual way: a server list change needs a majority of the old list, and the old list is only the old incarnation. Until its owner recovers it, such a space keeps its history and serves reads, but it orders nothing more: no message is stamped and no control event commits.

The owner's recovery (decision 0055) brings it back. With the restored hub running, the owner runs, on any of their devices:

dentatsu space recover SPACE --dry-run        # what the hub would do: shown, nothing signed
dentatsu space recover SPACE                  # gather, then sign the recovery
  1. The hub asks every member device that is connected to it for what it holds past the hub's own copy (--wait seconds, default 15): the space's control events with the certificates the device took them by, and the messages it keeps. User-only: before you run it, ask the family to open dentatsu (the TUI or the web page) on their devices, so that their history counts. The CLI's one-shot commands keep no messages.
  2. The hub plans the recovery: the log goes on from the newest point any device can prove with a certificate the old hub signed; each room's messages come back at the rseqs the devices agree on; rseqs no device held, or two devices disagree on, are lost and marked as a gap.
  3. The owner's device signs that plan (a space.recover event, docs/wire.md "Recovery") and the hub applies it: it is the space's only sequencer again, as its new incarnation, and messages are stamped again. Every client of the space reconnects to the recovered log; one that held events the old hub signed after the copy rolls back to the recovered point, and shows "— N messages lost in a restore —" where the gap is.

What is lost: what no connected device held (messages, and control events past the hub's copy without a certificate a device holds); room membership changes (MLS commits) after the copy, whose payloads devices don't keep (a member that needs one is added again). The old incarnation never signs again: only the owner's key names the new one, and only for a one-sequencer space whose sequencer is the restored hub. The recovery is refused for a space with other sequencers (name the new incarnation as below) and on a hub that wasn't restored.

The hub's Conduit member (the account's MLS member in Conduit rooms, conduit = …) would send under MLS keys it already used after the copy, so a restore sets its vaults aside (conduit-member/*/mls.db.before-restore-INC, kept): those accounts' Conduit rooms need them added again by a member of each room.

Naming the new incarnation in a space with other voters (its owner, on any device):

dentatsu space servers SPACE --fallback wss://chat.DOMAIN/ --inc INC   # INC: the incarnation the restore printed

The command makes two server list changes, one voter at a time. First the other voters commit the list without the old incarnation. Then the hub catches up in full, and the list names the new incarnation. From then on the hub votes and signs as its new incarnation.

The restore drill

restore-drill.sh (installed in /usr/local/share/dentatsu/deploy/hub/) checks that the newest backup restores. It does these steps:

  1. It takes the newest hub-*.tar.* in BACKUP_DIR, checks its .sha256 and decrypts it with the identity you give it.
  2. It restores the backup with dentatsu hub restore into a scratch directory.
  3. It starts a hub there on 127.0.0.1, at a port the kernel picks, with nothing of the live config: no iroh, no voice, no web sign-in.
  4. It checks /healthz and that the hub holds as many spaces as the backup.
  5. It stops the hub by its pid and removes the scratch directory (--keep leaves it).

The copy holds the live hub's key, and its spaces name other servers. So the drill runs in a network namespace of its own with only loopback (unshare --net) when it can, and the drill hub can't reach other servers. With --isolate yes the drill fails when it can't make the namespace. The live hub, its data and its config are only read. User-only: run it now and then (monthly), as root, with the private key from the password manager, and delete the key file after:

/usr/local/share/dentatsu/deploy/hub/restore-drill.sh --identity /root/dentatsu-backup.key
shred -u /root/dentatsu-backup.key

--from FILE|DIR drills a particular archive or an unpacked backup directory, and --bin names the program. CI runs the drill on a backup that the test makes (tests/test_backup.nim). That test also runs the nightly script against a running hub and drills the encrypted archive.

Monitoring

Three watchers, so that a hub that stops, a disk that fills or a backup that stops running is noticed (all in deploy/monitor/; install.sh installs them and --enable turns on the timer):

  • dentatsu-check.timer runs dentatsu-check.sh every 5 minutes, as root, with /etc/dentatsu/monitor.conf (from monitor.conf.example; no secrets in it). It checks that:

    • each URL in HEALTH_URLS answers 200, and a /healthz URL also says "ok": true (default: the hub on loopback, http://127.0.0.1:7180/healthz; add https://chat.DOMAIN/healthz to check Caddy and the certificate from the machine, and https://pds.DOMAIN/xrpc/_health for the PDS);
    • each path in DISK_PATHS (the data, the PDS) keeps MIN_FREE_PCT (10) percent free;
    • the newest hub-*.age archive in BACKUP_DIR (by default the one /etc/dentatsu/backup.conf names) is younger than MAX_BACKUP_AGE_H (36) hours, and the directory is there (a backup disk that isn't mounted).

    A problem notifies when it starts or changes, again every REPEAT_H (6) hours while it lasts, and once more when everything passes again ("well again"). The unit fails while a problem lasts (systemctl --failed shows it); what was last notified is kept in /var/lib/dentatsu-monitor.

  • OnFailure=dentatsu-notify@%n.service in dentatsu-hub.service, dentatsu-backup.service and dentatsu-ddns.service: a unit that fails sends "UNIT failed on HOST (result: …)". Only its name and result leave the machine; its log stays there (journalctl -u UNIT -b). The hub restarts by itself on a crash (Restart=on-failure), so its OnFailure= fires only when systemd gives up restarting it; the 5-minute check sees a hub that is down sooner.

  • An outside check (user-only, below): the machine can't report its own power cut, a dead router or a lost address.

Notifications go through ntfy, by dentatsu-notify.sh. Its URL is the topic's (https://ntfy.example/TOPIC), and whoever knows it reads and posts to the topic, so it is a secret: it lives only in /etc/dentatsu/ntfy.url (the URL alone, mode 0600, root), never in a repository, a unit or a command line. A file others may read is refused. An access token for a server that needs one goes in /etc/dentatsu/ntfy.token (0600, root) and is sent as Authorization: Bearer. curl reads both from its standard input, so neither shows in ps. Without the URL file, problems are only logged (in the units' journals): nothing is sent anywhere. To try it:

/usr/local/lib/dentatsu/dentatsu-notify.sh --title "dentatsu test" "a test from $(hostname)"
systemctl start dentatsu-check.service; journalctl -u dentatsu-check.service -n 20

User-only steps:

  1. Pick an ntfy server and topic. Either a server you run (ntfy can run on this machine or another; with auth-default-access: deny-all and an access token), or the public ntfy.sh with a long random topic name (openssl rand -hex 16), knowing that its operator sees the messages. Subscribe to the topic on your phone.
  2. Write the URL file as root: install -m 600 /dev/null /etc/dentatsu/ntfy.url, then put the URL in it (an editor, not echo on a command line, which the shell history keeps). The same for ntfy.token if the server needs one. Then send the test above.
  3. Set up an outside check: a free uptime checker (UptimeRobot, Better Stack, healthchecks.io's or another service's HTTP monitor) checking https://chat.DOMAIN/healthz every 5 minutes for a 200 and the keyword "ok":true, alerting by mail or its app. It sees what the machine can't: the machine off, the line down, DNS pointing elsewhere, an expired certificate. /healthz gives nothing secret (version, commit, whether the store takes a write).
  4. Check monitor.conf: the hub's port if it isn't 7180, the PDS's directory, the backup disk.

CI tests the scripts against a fake endpoint on loopback (deploy/tests/test_monitor.sh: what is sent, the files' modes, when it notifies and when it doesn't); nothing in CI calls a real ntfy server.

Real-network smoke test

The checks before family use (pre-production W14), in order. tools/preprod-smoke.sh runs the scripted ones; the rest are by hand. User-only marks every step that needs the real machine, a real account, another network or a phone: nothing in this repository does those, and nothing here logs in to the machine. Each step says how to tell a pass from a fail. Write down the date and the result of each user-only step.

1. The rehearsal on the desktop

tools/preprod-smoke.sh local

On scratch only, nothing leaves the machine. It builds the program (nd build) and runs three checks:

  • The flood (tools/flood/flood.nim against a scratch hub on loopback, the caps at their defaults but max-connections 256): idle connections past max-connections, slowloris heads, 100 WebSocket upgrades, 30 web sign-ins and 100 /web/handle lookups from one address (198.51.100.7, through the tool's own proxy, which adds X-Forwarded-For as Caddy does). After each phase it checks /healthz and that the listed account logs in from another address (203.0.113.50); it also logs in during each flood but the idle-connection one. The suite runs the same flood every time (tests/test_flood.nim, with max-connections 64 and a 3 s head-timeout-ms).
  • The restore drill on a scratch directory: an online hub backup of a running scratch hub, then restore-drill.sh --from that backup (restore, a new incarnation, /healthz, the spaces counted).
  • A failing /healthz notifies: deploy/tests/test_monitor.sh, the check and the ntfy notifier against a fake endpoint on loopback.

Pass: preprod-smoke: 0 failed. Fail: a FAIL line names the check; the lines above it say why.

What the flood shows about the caps (the gate's "the abuse caps hold under a scripted flood"):

  • Upgrades: 60 a minute from one address get through (login-rate), the rest get 429 with Retry-After. Web sign-ins: 10 a minute reach the list check (unlisted DIDs are refused there, before any fetch), the rest are told to wait. Handle lookups: 60 a minute, then 429 with nothing fetched. In each, another address logs in at once.
  • Slowloris heads are closed at head-timeout-ms; a header byte a second doesn't extend it.
  • max-connections is one cap for everyone. One address that holds that many idle connections fills the hub until head-timeout-ms closes them (a new connection meanwhile is answered 503, a legitimate login too); it can renew them every 10 s. Behind Caddy that address's connections end at Caddy, which opens a connection to the hub only for a whole request, so the hub never sees idle ones; Caddy's own limits then decide. Consider servers { timeouts { read_header 10s } } in the Caddyfile's global options (not in Caddyfile.example yet, untested). A hub without a proxy in front has no per-address connection share yet.

2. From outside: the hub and the PDS answer (user-only)

On a laptop on another network (a phone's hotspot, not the home Wi-Fi):

tools/preprod-smoke.sh remote https://chat.DOMAIN --pds https://pds.DOMAIN

One GET each: TLS and /healthz, the web client's page, the OAuth client metadata (its client_id must be https://chat.DOMAIN/oauth/client-metadata.json), /metrics not reachable through Caddy, one /web/handle, the PDS's /xrpc/_health and its OAuth authorization server metadata. Pass: every line PASS. Fail: the FAIL line says which and the HTTP code (000: no connection: DNS, the port forward, or Caddy).

3. Hairpin NAT from inside the LAN (user-only)

Family members at home, and the hub and the PDS on the machine, reach the public names from inside the LAN.

  1. On a laptop on the home Wi-Fi: the same tools/preprod-smoke.sh remote … as step 2. Pass: every line PASS. Fail (000 or a timeout, while step 2 passed): the router doesn't hairpin; turn on "NAT loopback", or use split DNS (then read step 10 first).
  2. On the machine itself: curl -sS https://chat.DOMAIN/healthz and curl -sS https://pds.DOMAIN/xrpc/_health. Pass: both answer JSON. Fail: as above.
  3. Inside the PDS's container (it fetches the hub's client metadata at sign-in): podman exec dentatsu-pds wget -qO- https://chat.DOMAIN/oauth/client-metadata.json (or docker exec). Pass: the JSON. Fail: an error or a timeout: the PDS can't reach the hub by its public name, and web sign-in from the family's PDS fails.
  4. UDP: a call between two devices on the home Wi-Fi (step 9's check). Pass: they hear each other. Fail: silence while a call with an outside device works: the router doesn't hairpin UDP 7181.

4. The CLI signs in: our PDS and a listed bsky.social account (user-only)

With a scratch state directory, so nothing mixes with your own device:

export DENTATSU_PASSWORD=…        # the account's app password, typed, not in the shell's history
dentatsu --state /tmp/dt-family login NAME.DOMAIN --hub wss://chat.DOMAIN/ --password-env DENTATSU_PASSWORD --label smoke
dentatsu --state /tmp/dt-family whoami
dentatsu --state /tmp/dt-friend login FRIEND.bsky.social --hub wss://chat.DOMAIN/ --password-env DENTATSU_PASSWORD --label smoke

Pass: each login ends with the account signed in to the hub, and whoami names the account's DID and wss://chat.DOMAIN/. Fail: login exits non-zero; its message says where (the PDS, the device record, or the hub's "DID may not sign in to this hub": then the DID isn't in allow-accounts and its PDS isn't in allow-pds). After, remove the smoke devices from the web page's device list ("A lost device") and delete the state directories.

5. The web client signs in: our PDS and the listed bsky.social account (user-only)

In a private browser window, https://chat.DOMAIN/, sign in with NAME.DOMAIN, then (another private window) with the listed bsky.social account. Pass: the PDS's consent page, then back on the page signed in, the account's spaces shown, the new device in the device list. Fail: the page comes back with an error in its address (?error=…, shown on the page): "may not sign in" (the lists), "too many sign-ins" (signin-rate: wait a minute), or the PDS shows an error about the client or its metadata (step 10).

6. An unlisted account is refused (user-only)

With a bsky.social account that allow-accounts doesn't name: the CLI login as in step 4, and the web sign-in as in step 5. Pass: the CLI exits 1 with "DID may not sign in to this hub"; the web page comes back with the same reason before any PDS page opens; sudo -u dentatsu dentatsu hub admin accounts --config /etc/dentatsu/hub.conf doesn't list it. Fail: it signs in: the lists are wrong, or the hub runs accounts = any (check /etc/dentatsu/hub.conf).

7. Only an admin creates a space (user-only)

As the family member of step 4 (not in admins): dentatsu --state /tmp/dt-family space create smoke-test. Then as an admin, the same in your own state. Pass: the member's exits 1, refused by the hub (space-create = admins); the admin's prints the new space. Fail: the member's space is made. Remove the admin's test space after (or leave it: the next phase's reset removes it).

8. iroh: direct, relayed, or the WebSocket (user-only)

genji's hub.conf has iroh-relay = none, so iroh is either direct (UDP to the hub's forwarded port 7180) or not used at all: the client then falls back to the WebSocket through Caddy. Nothing in the program prints which way it went; tell it from the outside, on a laptop on another network with the state from step 4:

  1. dentatsu --state /tmp/dt-family tail SPACE ROOM --timeout 120 (it keeps one connection open), and in another terminal: ss -tnp | grep dentatsu and ss -unp | grep dial-iroh.
  2. The WebSocket: dentatsu has an established TCP connection to the hub's address, port 443. iroh: no such TCP connection, and a dial-iroh process (the CLI's bridge, a child of dentatsu) holds UDP sockets. The first command after login always uses the WebSocket (the hub's ready tells the client its iroh address); the second and later use iroh when it works.
  3. Direct or relayed (only with a relay in iroh-relay): with sudo tcpdump -ni any udp and host HUB-IP and port 7180 on the laptop while the client sends, packets flowing both ways mean direct; none, while messages still arrive over iroh, means the packets go through the relay (its TCP connection: ss -tnp | grep dial-iroh, to the relay's address on 443).

Pass: iroh from outside the LAN. Fail: always the WebSocket: UDP 7180 isn't forwarded or open in the firewall, or iroh-addrs names the wrong address (grep iroh= /var/log/… or journalctl -u dentatsu-hub | grep iroh= on the machine shows what the hub tells clients). DENTATSU_IROH=off forces the WebSocket, for comparison.

9. A call across NATs (user-only)

Two people on different networks (one on the home Wi-Fi, one on a phone's mobile data), each in the web client, join the call of a voice room (room create SPACE NAME --voice, or the page's button) for a minute and talk. On the machine: cat /run/dentatsu/voice.json during the call. Pass: both hear each other; voice.json shows 2 peers and frames forwarded rising. Fail: they join but hear nothing: UDP 7181 isn't forwarded, or voice-public doesn't name the line's public address (the hub's answer carries it as the one ICE candidate); a join refused: the room's permissions.

10. Does the PDS refuse the hub's client metadata at a private address?

Yes, by its code. The reference PDS (ghcr.io/bluesky-social/pds:0.4, @atproto/oauth-provider 0.25.1, read in its image) fetches a client's metadata with its safeFetch: allowIpHost: false (no IP literal as the host) and SSRF protection on, which resolves the name and refuses loopback, private and link-local addresses. Only PDS_DISABLE_SSRF_PROTECTION=true, or PDS_DEV_MODE=true (its default for that setting), turns it off; deploy/pds's env sets neither, and it shouldn't. CI's web sign-in test runs the PDS in dev mode (tests/e2e/services.sh), so it doesn't see this. So on the machine chat.DOMAIN must resolve, inside the PDS's container, to the public address (hairpin NAT), not to a LAN or loopback address (split DNS, an /etc/hosts line).

User-only check: podman exec dentatsu-pds getent hosts chat.DOMAIN (or nslookup chat.DOMAIN). Pass: the public address, and step 5's web sign-in with NAME.DOMAIN works. Fail: a private address: the sign-in stops at the PDS with an error about the client's metadata; fix DNS (public answers, hairpin in the router), not the PDS.

11. The restore drill (user-only)

The rehearsal (step 1) proves the scripts; this proves the real backups. As root on the machine, with the backup's private key from the password manager:

/usr/local/share/dentatsu/deploy/hub/restore-drill.sh --identity /root/dentatsu-backup.key
shred -u /root/dentatsu-backup.key

Pass: it ends "the drill passed" with the backup's spaces counted. Fail: a sum that doesn't match, a key that doesn't decrypt, or a hub that doesn't answer: see "The restore drill".

12. A /healthz failure notifies (user-only)

After ntfy is set up (Monitoring's user-only steps), on the machine:

systemctl stop dentatsu-hub; systemctl start dentatsu-check.service
journalctl -u dentatsu-check.service -n 5
systemctl start dentatsu-hub; systemctl start dentatsu-check.service

Pass: a notification about the hub's /healthz reaches the phone within a minute, then "well again" after the second check; the outside uptime check alerts too if the hub stays down past its interval. Fail: no notification: journalctl says "logged only" (no /etc/dentatsu/ntfy.url) or why the post failed. Do it when nobody is using the hub.

13. The flood against the real hub (user-only, optional)

Only with the hub idle and nobody depending on it. From the desktop:

tools/preprod-smoke.sh flood https://chat.DOMAIN --phases logins,signins,handles,heads

During it, sign in from a phone on mobile data (another address). Pass: every check passes (/healthz after each phase), the 61st upgrade gets 429, the phone signs in at once. The desktop's own address is refused for up to a minute after, as it should be. --login-cmd 'dentatsu --state DIR whoami' runs a login of yours after each phase (from the flooding address, so it fails while the per-address caps hold it: run that one from another network). The conns phase measures Caddy, not the hub (step 1).