home-hosted 0.9.10 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -114,7 +114,8 @@ workspace config guard, so a busy default port turns config tests red for the wr
114
114
  - **A metric with no reading is absent, never zero.** A scrape has no page to qualify a number, so an
115
115
  alerted-on gauge published as `0` from an unsampled view is indistinguishable from a healthy one
116
116
  and silences the rule that exists to catch it. Omit the series (`src/api/metrics.ts`), and never
117
- suffix `_total` a value that a user action resets.
117
+ suffix `_total` a value that a user action resets — no series here is a counter, and
118
+ `test/api/panel.test.ts` enumerates the scrape and fails on a `_total` name or a `counter` type.
118
119
  - **Name the cause the fix follows, not the one the code path suggests.** Node reports a missing
119
120
  working directory and a missing program with the same `ENOENT`, so `describeSpawnError` checks the
120
121
  resolved `cwd` **and** whether the field holds a whole command line before it blames the command —
@@ -131,6 +132,26 @@ workspace config guard, so a busy default port turns config tests red for the wr
131
132
  the card beside it prints that sentence in full. Read both in **one** helper
132
133
  (`failureMessage`, `src/shared/api-client.ts`) and scan for the hand-rolled fallback — a unit test
133
134
  cannot see a call site that has not been written yet.
135
+ - **A state and the streak behind it are written together.** `health`, `healthFailures` and
136
+ `unhealthySince` describe one process's run, so a path that resets one and leaves the others
137
+ reports a duration that keeps counting while nothing is measured — measured as `status=crashed
138
+ health=unknown` beside `Unhealthy for 3m 17s` and a `Not Probed` row, on the card and the page.
139
+ The explicit stop had that shape and was fixed alone once; the exit paths behind it were the same
140
+ defect. One helper decides the trio (`setHealth`/`resetHealth` in `src/services/supervisor.ts`)
141
+ and a scan fails a direct assignment. **A client cannot assume the server got there** — a newer
142
+ UI is served against an older panel, so a UI rendering a *duration* gates it on the verdict it
143
+ prints beside it, not on whether the timestamp is present.
144
+ - **A measurement belongs to the process that produced it, and goes when that process does.**
145
+ `pid`, `responseMs` and `resources` are one run's numbers; a path that detaches the pid and keeps
146
+ them reports a stopped entry with a live CPU, RSS and probe (`Probe 2 Ms / RSS 64.2 MB / Procs 1`
147
+ beside `Stopped`, and `hh_server_cpu_percent` in the scrape). The two **exit** paths cleared them
148
+ and the explicit stop did not — and an **adopted** successor has no exit event at all, because the
149
+ panel is not its parent, so one helper (`endProcessReadings`) owns all four and a scan fails a
150
+ clear outside it. The rule is general: ask which **lifecycle** clears a field, not which function
151
+ happened to. `portState` is the deliberate exception — a port's occupancy outlives its process.
152
+ The client half is the same predicate as the paragraph above: both UIs read a reading through
153
+ `liveReadings` (`src/shared/server-readings.ts`), never off the frame, and never `?? 0` (a zero
154
+ is the value that looks like a measured idle process).
134
155
  - **A list card and its detail page answer the same question; fix both.** The card is a summary of a
135
156
  page someone opens *precisely because the summary was not enough* — so a fact the card states and
136
157
  the page omits is worse than either alone. A stopped entry's card learned to say "not running"
@@ -140,6 +161,14 @@ workspace config guard, so a busy default port turns config tests red for the wr
140
161
  explanation on the way in. When you give a surface an empty state, a reason or a qualifier, grep
141
162
  for the other surface that renders the same field and land it there too — and prefer a shared
142
163
  component or a scan test over two call sites remembering in parallel.
164
+ - **A replaced list is sent only when *this form* changed it, and merged against what it was
165
+ filled with.** `destinations` and `routes` are lists a patch replaces, so a save writes the
166
+ sender's whole view — including entries it never saw. Deciding that against live state makes
167
+ another client's save look like this form's own edit: measured with two tabs on one workspace
168
+ settings page, a destination added in one tab was removed from `settings.json` by the other
169
+ saving an unrelated toggle. Keep the baseline the block was filled with and compare the draft to
170
+ *that* (`mergeReplacedList`); a list that was never filled must not travel, because `[]` on a
171
+ replaced list means "delete every entry".
143
172
  - **A refused operation is a failure, never an empty success.** The backup service answers a *plan*
144
173
  for every archive, including ones it cannot read: `plan.error` carries the refusal and `items` is
145
174
  empty. A caller that reads only `items` reports "restored 0 items" with exit 0, which on a blank
@@ -192,6 +221,13 @@ These prevent defects if broken. The *why* for the non-obvious ones is in
192
221
  local command must not open an unauthenticated `/api` route.
193
222
  - **A server id is only unique inside its workspace.** Anything keyed by id alone — SSE, log buffers,
194
223
  series, route params — must key on `(workspaceId, serverId)`, or same-named servers mix frames.
224
+ **So must "what this panel owns."** A per-workspace service answering a panel-wide question — "is
225
+ this pid ours?" — asks its own workspace and silently gets the wrong answer for the others: a port
226
+ held by a sibling workspace's server read as a stranger, so `free-port` terminated it and `follow`
227
+ adopted it into the wrong workspace (two workspaces then claimed one pid). The panel is the only
228
+ thing that can see every workspace, so it injects the answer (`SupervisorOptions.siblingServers`)
229
+ and a lone supervisor has none. Such a refusal must also say **where** the holder lives: "stop that
230
+ server instead" is a dead end when that server is on a page this workspace cannot show.
195
231
  - **A workspace is the ownership boundary.** Servers, secrets, logs and nanny state belong to exactly
196
232
  one; only listener, auth, TLS, host vitals, backups, UI and `run.json` are panel-wide. Reach a
197
233
  per-workspace service through `PanelService.requireWorkspace(id)`, never a module global.
package/README.md CHANGED
@@ -228,9 +228,12 @@ curl -N -H "Authorization: Bearer hh_9uA2…" 'http://127.0.0.1:3999/api/servers
228
228
  home-hosted status --json # machine-readable: running, liveness, degraded, pid, url, paths
229
229
  ```
230
230
 
231
- A token has the same authority as a signed-in browser and outlives restarts; `set-token --clear`
232
- revokes it instantly. Workspace-scoped routes take `?workspace=<id>`; omitting it means the panel's
233
- default workspace.
231
+ A token has the same authority as a signed-in browser and outlives restarts, with two exceptions:
232
+ it may not clear the panel password, and it may not restore an archive that carries the panel's own
233
+ credentials — both of which would end with the panel armed by whoever holds the token. Treat a token
234
+ as a password: rotate it with `set-token --generate` if it may have leaked, and see
235
+ [Security](#-security) for the rest. Workspace-scoped routes take `?workspace=<id>`; omitting it
236
+ means the panel's default workspace.
234
237
 
235
238
  <details>
236
239
  <summary><b>🌐 The endpoints worth knowing</b></summary>
@@ -262,10 +265,19 @@ default workspace.
262
265
  `hh_host_load1_per_cpu` beside it is a **count of runnable tasks per core**, not a percentage:
263
266
  `1.0` means one core's worth of work waiting, so it is fine on a busy box and not comparable with the
264
267
  percentage above. A host gauge appears only once the host has been sampled, so a series that is
265
- *absent* means "no reading", never "zero": do not let a dashboard fill that in. `hh_server_restarts_total`
268
+ *absent* means "no reading", never "zero": do not let a dashboard fill that in. `hh_server_restarts`
266
269
  counts the retry attempts spent on a server's **current** crash sequence and drops back to `0` when
267
270
  someone starts it, so it is a state, not a counter to `rate()` — `hh_server_crashes_24h` is the one
268
- that only grows within its window.
271
+ that only grows within its window. No series here is a Prometheus counter: every one is a snapshot a
272
+ stop, a delete or a manual start can lower, so no name ends in `_total`.
273
+
274
+ > **Upgrading from 0.9.x — a dashboard needs one edit.** The series formerly named
275
+ > `hh_server_restarts_total` is now `hh_server_restarts` (a gauge, unchanged in meaning and labels).
276
+ > It was never a valid counter: a start you asked for reset it to `0`, so `rate()` reported a phantom
277
+ > counter reset. Replace every query on `hh_server_restarts_total` with `hh_server_restarts`, and use
278
+ > the gauge directly (`hh_server_restarts > 2`) rather than `rate()`/`increase()`. The count series
279
+ > `hh_servers_total` is now `hh_servers` for the same reason. Old dashboards will show *no data*
280
+ > for those two series after the upgrade — the panel publishes neither old name.
269
281
 
270
282
  `GET /openapi/spec.json` describes all of it, `/openapi/ui` is the browsable version, and every error
271
283
  comes back as one envelope (`{ message, code, detail }`) with a stable `code` a tool can branch on. The
@@ -296,24 +308,24 @@ can be told what to be: *"Help me build a UI for home-hosted: nostalgic game the
296
308
 
297
309
  | | |
298
310
  | --- | --- |
299
- | 🗂 **Workspaces** | One panel, many scopes: pick a workspace in the header and it owns its servers, secrets, logs and settings. Create, rename and delete them there. Panel-wide things — listener, auth, host vitals, backups, TLS, UI — stay in **Global settings**. |
311
+ | 🗂 **Workspaces** | One panel, many scopes. A workspace owns its servers, secrets, logs and settings; listener, auth, backups, TLS and UI stay panel-wide in **Global settings**. |
300
312
  | 🚦 **Lifecycle** | Start, stop, restart from the panel or the API; `autostart` entries come up with it. A process left behind by a renamed or removed entry is listed on **Servers** with a stop button, instead of running invisible. |
301
- | 📝 **Hand edits welcome** | Change a workspace's `servers.config.json` in an editor, a `git checkout` or a config tool: the panel notices within seconds, no restart. A file it cannot read is reported in the panel, and the running servers are left alone. |
313
+ | 📝 **Hand edits welcome** | Edit `servers.config.json` in an editor or a `git checkout` — the panel notices in seconds, no restart. A file it cannot read is reported, and running servers are left alone. |
302
314
  | ♻️ **Auto-restart** | Exponential backoff on crash, with the counter reset once a process stays up. The budget is remembered across a restart of the panel. |
303
- | 🩺 **Health that acts** | TCP or HTTP probes per server: warn on the card, force a restart after a timeout (bounded by the same retry budget as a crash, so a permanently sick entry stops instead of restarting forever), check ports before starting — and [follow or replace](./docs/SERVERS.md#when-a-program-restarts-itself) a program that restarts itself. |
315
+ | 🩺 **Health that acts** | TCP or HTTP probes per server: warn, then force a restart — bounded by the same retry budget as a crash, so a sick entry stops instead of looping. Ports are checked before starting, and a program that [restarts itself](./docs/SERVERS.md#when-a-program-restarts-itself) can be followed or replaced. |
304
316
  | 🔗 **Ordered startup** | `dependsOn` waits for a dependency to be *healthy* — not merely spawned. `stop-all`/`down` stop dependents before their dependencies; stopping one server names the dependents it leaves running. [SERVERS.md](./docs/SERVERS.md#field-reference) |
305
317
  | 📜 **Logs** | Live per-server stream, buffer plus rotated files on disk, search, filter to one stream, download, one click to clear. |
306
- | 📈 **Resources** | CPU and RSS of the whole process tree, with an optional memory ceiling that triggers a restart. |
318
+ | 📈 **Resources** | CPU and RSS per process tree — the summed containers for a compose entry — with an optional memory ceiling that restarts the entry. |
307
319
  | 🌡️ **Host vitals** | CPU usage, memory, swap, disk and CPU temperature, plus the load average as a per-cpu count, with thresholds that notify once and again on recovery. |
308
320
  | 🤖 **Token API** | Scripts and agents drive it with `Authorization: Bearer` — no browser, no session. [↑](#-agents-scripts-and-tools) |
309
- | 🔔 **Notifications** | One list of **destinations** — Telegram chats and webhooks (ntfy, Discord, Slack, your own endpoint) — on crash, unhealthy, forced restart, recovery, host thresholds and DNS changes. The event toggles and throttle are set once, and each destination may inherit them or carry its own. [Setup here](./docs/NOTIFICATIONS.md). |
321
+ | 🔔 **Notifications** | Telegram and webhooks (ntfy, Discord, Slack, anything) on crash, unhealthy, recovery, host thresholds and DNS changes. Toggles and throttle set once; each destination inherits or overrides. [Setup](./docs/NOTIFICATIONS.md). |
310
322
  | 🌐 **Dynamic DNS** | Keep hostnames pointed at your public IP — Cloudflare, Namecheap, Spaceship, Porkbun, GoDaddy, Gandi and more. [DDNS.md](./docs/DDNS.md) |
311
- | 🔀 **Reverse proxy** | One engine in front of everything, with automatic HTTPS: `git.example.com` → a Gitea entry, `media.example.com` → a service on another box, `panel.example.com` → the panel. Caddy, installed and supervised by the panel. [REVERSE_PROXY.md](./docs/REVERSE_PROXY.md) |
312
- | 💾 **Backups** | Global settings, TLS, workspaces, and inside each one its settings, servers, secrets and declared data — plain `.zip`, or AES-256 with a password. Each secret is picked separately, and a restore can be customized. |
323
+ | 🔀 **Reverse proxy** | One Caddy engine in front of everything, with automatic HTTPS: `git.example.com` → a Gitea entry, `panel.example.com` → the panel itself. Installed and supervised by it. [Details](./docs/REVERSE_PROXY.md) |
324
+ | 💾 **Backups** | One `.zip` of the panel and the workspaces you pick — plain or AES-256, picked per item, from the panel or the CLI. [Details](#-backups). |
313
325
  | 🌍 **Nine languages** | English, Vietnamese, Chinese, Japanese, Spanish, Korean, Russian, French, German — picked on the login page or in **Global settings → Language**, kept per browser. |
314
326
  | 🎨 **BYOU — Bring Your Own UI** | Upload a static build, `ui-update` to follow its releases, `ui-revert` to go back. [UI_CREATION.md](./docs/UI_CREATION.md) |
315
327
  | 🔐 **Security** | Cookie sessions, API tokens, scrypt hashes, per-IP lockout, optional TLS, and a refusal to expose itself without a password. |
316
- | 🧩 **Bring any program** | A server is `command` + `args` + `env` + `cwd` — if it runs in a shell, it runs here. Presets fill the form in for common ones; nothing requires one. |
328
+ | 🧩 **Bring any program** | A server is a `command`, its args and a working directory — plus optional `dataEnvs`, `dependsOn` and `dump`/`load` hooks. Presets fill the form; nothing requires one. [Fields](./docs/SERVERS.md) |
317
329
  | 🖥 **Cross-platform** | Linux, macOS and Windows: `/proc`, `ps` or Win32_Process, process groups or `taskkill /T`, no shell dependencies. |
318
330
 
319
331
  ---
@@ -374,12 +386,13 @@ restarts itself), and how hand-edits are validated: [SERVERS.md](./docs/SERVERS.
374
386
  | `home-hosted up` | start the panel detached, and keep it alive in the background |
375
387
  | `home-hosted down` | stop it cleanly — supervised processes included, persistent entries left running |
376
388
  | `home-hosted restart` | `down`, then `up` — or `restart <id>` to restart one server, leaving the panel up |
377
- | `home-hosted status` | pid, URL, health, uptime, state and log paths — the panel's console *and* the per-server directory, naming the `<id>.log` convention once logs exist (`--json` for scripts; stopped answers `{ running: false, initialised }`, where `initialised: false` means nothing was ever set up here, plus `liveness` — `gone`, or `recycled` when the OS has handed the recorded pid to another process and the record is stale) |
378
- | `home-hosted start <id>` | start one server in the default workspace — and anything it `dependsOn` (`--workspace <id>`) |
389
+ | `home-hosted status` | pid, URL, health, uptime, state and log paths (`--json` for scripts). Edge cases are under [what `status` tells you](#-cli). |
390
+ | `home-hosted start <id>` | start one server in the default workspace — and anything it `dependsOn` (`--workspace <id>`). `--free-port` frees the port first, then starts |
379
391
  | `home-hosted stop <id>` | stop one server, nothing else (`--workspace <id>`) |
392
+ | `home-hosted free-port <id>` | ask whatever holds that server's port to stop — the panel's **Free port** button. Anything this panel supervises is refused, not signalled (`--workspace <id>`) |
380
393
  | `home-hosted restart <id>` | restart one server, nothing else (`--workspace <id>`) — the same as the panel's per-server Restart |
381
394
  | `home-hosted logs` | read the panel's own console output — the file `up` redirects it into (`--lines`, `--follow`, `--json`) |
382
- | `home-hosted backup` | list, create or restore an archive without a browser, **and without the panel running** (`create --all --exclude global:secrets --confirm`, `restore <name> --all --confirm`, `--password`, `--include`, `--exclude`) — see [RESTORE_DEMO.md](./docs/RESTORE_DEMO.md), and `dump`/`load` hooks in [SERVERS.md](./docs/SERVERS.md) |
395
+ | `home-hosted backup` | list, create or restore an archive — **without the panel running** (`--password`, `--include`, `--exclude`). See [Backups](#-backups) and [RESTORE_DEMO.md](./docs/RESTORE_DEMO.md) |
383
396
  | `home-hosted set-password` | set the panel password without opening a browser; a running panel picks it up at once and signs every existing session out |
384
397
  | `home-hosted set-token` | set the API token scripts and agents use (`--generate`, `--clear`) |
385
398
  | `home-hosted migrate` | bring every config up to the schema this release understands (`--dry-run`, `--yes`) |
@@ -399,7 +412,7 @@ up -p/--port --host --open --no-autostart --foreground --print-co
399
412
  down (no flags)
400
413
  status --json
401
414
  logs --lines <n> --follow --json
402
- backup [list|create|restore] [<name>] (--include <ids> | --all) [--exclude <ids>] --password --confirm --json
415
+ backup [list|create|restore] [<name> | --from <path>] (--include <ids> | --all) [--exclude <ids>] --password --confirm --json
403
416
  start, stop <id> [-w/--workspace <id>] (both need the panel up)
404
417
  restart [<id>] [-w/--workspace <id>] (no id: the panel; with one: that server)
405
418
  init --dir --name --pm --no-install -y/--yes
@@ -447,6 +460,24 @@ or a config whose schema is newer than the running release stops `up` with the e
447
460
  than starting with defaults that quietly differ from your file. Fix the file, or install the release
448
461
  that wrote it.
449
462
 
463
+ ### Two things `migrate` cannot fix
464
+
465
+ `migrate` moves a config file. Two changes in this release are *outside* the config, so read these
466
+ before upgrading — a stale one fails quietly, which is the worst way to fail.
467
+
468
+ **A dashboard on `/api/metrics`.** Two series were renamed in the release that made every metric
469
+ honest about being a gauge: `hh_server_restarts_total` is now `hh_server_restarts`, and
470
+ `hh_servers_total` is now `hh_servers`. The old names are not published, so a query still on one
471
+ shows *no data* rather than a stale number. Compare the gauge directly (`hh_server_restarts > 2`);
472
+ do not wrap it in `rate()`/`increase()`, because a start you asked for resets it.
473
+
474
+ **A script that holds only an API token.** Three operations now require a signed-in session, because
475
+ each would otherwise let a stolen token end up holding the panel: clearing the password, switching
476
+ authentication off, and restoring an archive that carries `global:secrets`. Each answers 403
477
+ `SESSION_REQUIRED`. Scripts should either sign in first, pass `--exclude global:secrets` to a
478
+ restore, or run the command on the machine (`home-hosted set-password --clear`,
479
+ `home-hosted backup restore`, which both go through the local channel).
480
+
450
481
  ### Coming from 0.6.x
451
482
 
452
483
  **Install the latest 0.7.x first, and run it once.** 0.7.0 moved all state from `$HHOSTED_HOME` itself
@@ -460,42 +491,98 @@ the move on its first run; 0.8.0 then starts against the result.
460
491
 
461
492
  </details>
462
493
 
494
+ <details>
495
+ <summary><b>🤔 What <code>status</code> tells you when things are not simple</b></summary>
496
+
497
+ `home-hosted status` prints the panel's console path *and* the per-server log directory, naming the
498
+ `<id>.log` convention once logs exist.
499
+
500
+ `--json` is for scripts. A stopped panel answers `{ running: false, initialised }` —
501
+ `initialised: false` means nothing was ever set up in this state directory — plus `liveness`:
502
+
503
+ | `liveness` | Means |
504
+ | --- | --- |
505
+ | `alive` | the recorded pid is this panel |
506
+ | `gone` | it is not running; the record is stale and may be cleared |
507
+ | `recycled` | the OS has handed the recorded pid to **another** process. The record is stale, but a signal would hit a stranger, so only the token-authenticated shutdown touches it |
508
+
509
+ </details>
510
+
463
511
  ---
464
512
 
465
513
  ## 🔐 Security
466
514
 
467
- Everything binds `127.0.0.1` until you say otherwise.
468
-
469
- - **A password is required to expose the panel.** Replace the default, then bind to `lan` — in the
470
- UI, in the config, or with `--host lan`. The same guard applies in all three places.
471
- - **Sessions** live in memory only; the cookie is `HttpOnly` and `SameSite=Strict`, and it is an
472
- **idle** timeout — every request slides both the session and the cookie, so a panel in regular use
473
- stays signed in and one left alone for the configured lifetime does not. The login route locks out
474
- repeated failures per IP — see the `trustProxy` note below for when that is advisory.
475
- - **API tokens** for scripts and agents: `home-hosted set-token --generate` prints one once, and a
476
- request proves itself with `Authorization: Bearer …` — the same access as a signed-in browser,
477
- stored as a SHA-256 hash, revoked with `set-token --clear`. Changing the panel password does
478
- **not** revoke a token, so rotate it with `set-token --generate` if one may have leaked.
479
- - **Port conflicts** are named — `port 4010 is already in use (pid 4242)` — and can be resolved from
480
- a confirmation popover on that banner or card. The process is looked up again at that moment,
481
- never taken from the message, and anything the panel supervises is refused, not killed. A server
482
- that [restarts itself](./docs/SERVERS.md#when-a-program-restarts-itself) can be followed, or replaced
483
- with a supervised copy.
484
- - **Secrets never enter the config**: the password hash and API token hash live in the global
485
- `.hh/.control-secrets.json`, each workspace's Telegram bot token and DDNS credentials in its own
486
- `.hh/<workspace>/.secrets.json`, all mode `0600`; the TLS pair sits in `.hh/.tls/`. DDNS credentials
487
- are sealed with AES-256-GCM under `HHOSTED_DDNS_SECRET` (default `hh` — set your own).
488
- - **Behind a proxy** pick how far to trust it, and let `cookieSecure: auto` add `Secure` on https — or
489
- upload a PEM pair and let home-hosted terminate TLS itself.
490
- - **`loopback`** trusts `x-forwarded-*` only when the request came from this machine. Right for a
491
- proxy on the same host: the panel gets the real client address for its lockout and the logs, and
492
- a forged header from anywhere else is ignored.
493
- - **on** trusts the header from *any* peer. Only when the proxy is the only way in: the client
494
- address then comes from the caller's own header, so the per-IP lockout counts per *forged*
495
- address and stops throttling brute force. The panel warns at startup when that combination is
496
- exposed.
497
- - **off** ignores the header entirely. Use it when nothing sits in front, or when the proxy does not set
498
- one.
515
+ **Safe out of the box.** The panel answers on `127.0.0.1` only. It will not listen anywhere else —
516
+ not while the password is still the default one, not without a password, not with authentication
517
+ switched off — and a proxy route pointing back at the panel answers to the same rule. Nothing is
518
+ exposed until you decide it should be.
519
+
520
+ One setting only warns: turning on **trust a proxy from any peer** while the panel is also exposed
521
+ weakens the login lockout, and the panel says so at startup rather than refusing, because a proxy on
522
+ another machine is a legitimate setup.
523
+
524
+ <details>
525
+ <summary><b>🛡️ The three things you actually have to do</b></summary>
526
+
527
+ 1. **Set your own password before you expose it.** Change it, then bind to `lan` — in the UI, in the
528
+ config, or with `--host lan`. All three go through the same check.
529
+ 2. **Treat an API token like the password.** It works as you, it survives restarts, and changing the
530
+ password does *not* revoke it. If one may have leaked, rotate it: `set-token --generate`.
531
+ 3. **If you forget the password, clear it from the machine.** `home-hosted set-password --clear`
532
+ edits the secrets file directly, so it needs no login — that is the way back in. Signed in, the
533
+ same thing is *Global settings → Authentication → Clear password*.
534
+
535
+ </details>
536
+
537
+ <details>
538
+ <summary><b>🔍 The details — sessions, tokens, secrets on disk, proxies</b></summary>
539
+
540
+ **Sessions.** Kept in memory only, never on disk. The cookie is `HttpOnly` and `SameSite=Strict`, and
541
+ it is an **idle** timeout: every request slides both the session and the cookie, so a panel in regular
542
+ use stays signed in while one left alone signs out. Repeated login failures lock out per IP — see
543
+ *behind a proxy* below for when that is advisory.
544
+
545
+ **Tokens.** `home-hosted set-token --generate` prints one once and stores only its SHA-256 hash;
546
+ `set-token --clear` revokes it. Three operations need a signed-in session rather than a token, because
547
+ each would otherwise let a stolen token end up holding the panel:
548
+
549
+ | Operation | Instead |
550
+ | --- | --- |
551
+ | clearing the password | sign in, or `set-password --clear` on the machine |
552
+ | switching authentication off | sign in |
553
+ | restoring an archive carrying `global:secrets` | `--exclude global:secrets`, or the CLI on the machine |
554
+
555
+ All three answer `403 SESSION_REQUIRED`. Commands run on the machine use the local channel, so they
556
+ need no session.
557
+
558
+ **Where secrets live.** Never in a config file — every one of these is mode `0600`:
559
+
560
+ | What | Where |
561
+ | --- | --- |
562
+ | panel password hash, API token hash | `.hh/.control-secrets.json` |
563
+ | each workspace's notification tokens and DDNS credentials | `.hh/<workspace>/.secrets.json` |
564
+ | TLS certificate and key | `.hh/.tls/` |
565
+
566
+ DDNS credentials are sealed with AES-256-GCM under `HHOSTED_DDNS_SECRET` (default `hh` — set your
567
+ own) because they are the one thing replayed to a third party.
568
+
569
+ **Behind a proxy.** Choose how far to trust it; `cookieSecure: auto` adds `Secure` on https, or upload
570
+ a PEM pair and let home-hosted terminate TLS itself.
571
+
572
+ | Setting | Trusts `x-forwarded-*` from | Use when |
573
+ | --- | --- | --- |
574
+ | `loopback` | this machine only | a proxy on the same host — real client address in logs and lockout, forged headers ignored |
575
+ | `on` | any peer | the proxy is the only way in. **The client address is then the caller's own header**, so the per-IP lockout counts per *forged* address and stops throttling brute force; the panel warns at startup if that panel is exposed |
576
+ | `off` | nobody | nothing in front, or the proxy sets no header |
577
+
578
+ **Port conflicts.** A busy port is named — `port 4010 is already in use (pid 4242)` — and can be
579
+ resolved from a confirmation popover. The holder is looked up again at that moment, never taken from
580
+ the message, and anything the panel supervises is refused rather than killed. A server that
581
+ [restarts itself](./docs/SERVERS.md#when-a-program-restarts-itself) can be followed, or replaced with
582
+ a supervised copy.
583
+
584
+ </details>
585
+
499
586
 
500
587
  ---
501
588
 
@@ -525,52 +612,60 @@ Provider tokens stay in the workspace's secrets file. **Providers and the config
525
612
 
526
613
  ## 💾 Backups
527
614
 
528
- **Global settings → Backups** archives the panel's own settings, its secrets and the TLS pair — plus
529
- every workspace you pick. It is two-level: *Create backup…* lists the global items and each workspace;
530
- opening one lists its **settings**, **servers**, **secrets** and every data directory its entries
531
- declare, and you can drop any single piece. Each secret has its own checkbox. *Restore…* shows the
532
- same list from an archive before anything is written. Either way it is an ordinary `.zip`, or WinZip
533
- AES-256 with a password, restored per path. Build output and dependency directories (`node_modules`,
534
- `dist`, `.next`, framework caches) are skipped per entry; `backupIgnoreGenerated: false` captures them
535
- anyway.
536
-
537
- **Automatic backups** write one archive on a schedule you set — the page asks in hours, the config
538
- stores `intervalMs` — with a retention of its own (`Keep automatic`). The two counts are independent:
539
- `Keep` bounds the archives you take by hand, and a scheduled pass never prunes one of yours to make
540
- room for its own. Both land in the same directory, and an automatic archive is named `auto-…` so you
541
- can tell them apart — a name you drop in by hand with that prefix is treated as one, so do not use it.
542
-
543
- **What an automatic backup contains** is yours to choose: *What an automatic backup contains →
544
- Choose…* offers the same two-level list as *Create backup…*, and writes the result into the schedule
545
- as `scope`. Two modes, the same two the CLI has:
546
-
547
- - **Only these** — the archive carries only what you tick. The command-line spelling is
548
- `--include <ids>`.
549
- - **Everything except** — the archive carries everything but what you tick, *including workspaces you
550
- add later*. The command-line spelling is `--all --exclude <ids>`.
551
-
552
- Leave it at **Everything** (no `scope` in the file) and the schedule keeps taking the whole default
553
- scope — every workspace plus `includePaths` — which is exactly what a schedule written before this
554
- existed means. That is also the only setting that follows a workspace you add tomorrow; a stored list
555
- of ids does not, because it names today's ids. Ticking everything in the dialog is therefore saved as
556
- no scope at all, not as the list it currently amounts to. An empty selection is refused: it cannot be
557
- told apart from "everything" in the file, and it would capture nothing.
615
+ **Global settings → Backups** takes one `.zip` of the panel and the workspaces you pick — settings,
616
+ servers, secrets, declared data — and puts it back. Plain, or AES-256 with a password.
617
+
618
+ Both directions are **two-level**: pick whole workspaces, or open one and drop any single piece (its
619
+ settings, servers, secrets, or one data directory). Each secret has its own tick.
620
+
621
+ ```bash
622
+ home-hosted backup create --all --confirm # everything
623
+ home-hosted backup create --all --exclude global:secrets --confirm
624
+ home-hosted backup restore <name> --all --confirm # see `backup list`
625
+ home-hosted backup restore --from /media/usb/x.zip --all --confirm
626
+ ```
627
+
628
+ Both work with the panel **stopped**, which is when you actually need them.
558
629
 
559
630
  <details>
560
- <summary><b>🔑 Restoring a secret</b></summary>
631
+ <summary><b>⏱️ Automatic backups, and choosing what they contain</b></summary>
561
632
 
562
- An archive records **which release wrote it and the config schema it understood**; a restore refuses
563
- a newer schema outright rather than restoring the parts it recognizes.
633
+ A schedule writes one archive every N hours, with its own retention (`Keep automatic`). The two counts
634
+ are independent: `Keep` bounds the ones you take by hand, and a scheduled pass never prunes yours to
635
+ make room. Automatic archives are named `auto-…` so you can tell them apart.
564
636
 
565
- Ticking a **single secret** merges by field: it lands and the others in that file are left alone. So
566
- restoring the Telegram token does not clear the DDNS credentials. Ticking the whole **Secrets** entry
567
- replaces the file with the archive's copy instead, which is what makes the two worth telling apart.
637
+ **What it contains** is yours to choose, in the same two-level dialog, saved into the schedule as
638
+ `scope`:
639
+
640
+ | Mode | Carries | CLI spelling |
641
+ | --- | --- | --- |
642
+ | **Everything** *(default)* | every workspace, plus `includePaths` | *no flag* |
643
+ | **Only these** | only what you tick | `--include <ids>` |
644
+ | **Everything except** | everything but what you tick, **including workspaces you add later** | `--all --exclude <ids>` |
645
+
646
+ Only **Everything** follows a workspace you add tomorrow — a stored list names today's ids. Ticking
647
+ everything in the dialog is therefore saved as *no scope*, not as the list it currently amounts to.
648
+ An empty selection is refused, because it cannot be told apart from "everything" in the file.
649
+
650
+ Generated directories (`node_modules`, `dist`, `.next`, framework caches) are skipped per entry;
651
+ `backupIgnoreGenerated: false` captures them anyway.
652
+
653
+ </details>
654
+
655
+ <details>
656
+ <summary><b>🔑 Restoring a secret, and what not to restore</b></summary>
657
+
658
+ An archive records the release and config schema that wrote it; a restore refuses a newer schema
659
+ outright rather than restoring the parts it recognizes.
660
+
661
+ Ticking a **single secret** merges by field — restoring the Telegram token leaves the DDNS
662
+ credentials alone. Ticking the whole **Secrets** entry replaces that file with the archive's copy.
568
663
 
569
664
  Two things to know before restoring onto a machine already in use:
570
665
 
571
- - **The password hash and API token hash are secrets like any other.** Restoring them reinstates the
572
- old machine's password and long-lived token, so anyone holding that token keeps access. Leave them
573
- unticked, or rotate afterwards with `home-hosted set-token --generate`.
666
+ - **The password hash and API token hash are secrets too.** Restoring them reinstates the old
667
+ machine's password and long-lived token, so whoever holds that token keeps access. Leave them
668
+ unticked, or rotate afterwards.
574
669
  - **`HHOSTED_DDNS_SECRET` is not in the archive.** DDNS credentials travel sealed under it, so a host
575
670
  with a different value cannot open them. Supply the same secret, or re-enter the credentials.
576
671
 
@@ -584,11 +679,9 @@ archive and restore. Definitions come back, workspaces the target has never hear
584
679
  their labels, data lands where *this* machine's config says, and `autostart` entries come up
585
680
  immediately.
586
681
 
587
- It works because an archive carries the workspace registry, each workspace's `settings.json` and
588
- `servers.config.json`, and paths are matched by the **declaration** (`omniroute:DATA_DIR`), not by an
589
- absolute path from the source machine. A declaration using `{projectDir}`, `{dataRoot}` or `{home}`
590
- follows the restoring panel (`{projectDir}` is `HHOSTED_PROJECT` or the panel's cwd, not
591
- `HHOSTED_HOME`); a literal absolute path is restored to that same path.
682
+ Path matching is by **declaration** (`omniroute:DATA_DIR`), not by an absolute path from the source
683
+ machine. A declaration using `{projectDir}`, `{dataRoot}` or `{home}` follows the restoring panel; a
684
+ literal absolute path is restored to that same path.
592
685
 
593
686
  **A restore never writes where no config declares, and never across workspaces.** A data path is only
594
687
  placed under a workspace the archive says it belongs to — if that workspace's `servers.config.json` is
@@ -597,7 +690,7 @@ not part of the restore, its data is reported as skipped rather than guessed at.
597
690
  </details>
598
691
 
599
692
  <details>
600
- <summary><b>✅ What comes back, and what you still have to do</b></summary>
693
+ <summary><b>✅ What comes back, and what is still yours to do</b></summary>
601
694
 
602
695
  | | Restored | Still yours to do |
603
696
  | --- | --- | --- |
@@ -608,7 +701,7 @@ not part of the restore, its data is reported as skipped rather than guessed at.
608
701
  | Telegram bots and chats, webhook targets | ✅ | Send a test from *Notifications* if the chat id came from another account |
609
702
  | DDNS hostnames and their accounts | ✅ | Credentials only open under the same `HHOSTED_DDNS_SECRET`; otherwise re-enter them |
610
703
  | Panel password and API token | ⬜ ticked per secret | Leave unticked, or rotate with `home-hosted set-token --generate` |
611
- | Reverse-proxy routes | ✅ | Automatic HTTPS certificates are reissued by the engine on the new host. A pair **you uploaded** for a `tls: "manual"` route is not in the archive — re-upload it |
704
+ | Reverse-proxy routes | ✅ | Automatic HTTPS certificates are reissued on the new host. A pair **you uploaded** for a `tls: "manual"` route is not in the archive — re-upload it |
612
705
  | Reverse-proxy engine binary | ❌ | Installed again from *Global settings → Reverse proxy* |
613
706
  | Server logs, crash history, nanny state | ❌ | These describe the old box; the new one starts a fresh history |
614
707
  | A server's `envFile` | ❌ not archived | It is the machine-local layer by design — copy it yourself, or declare its directory in `backupPaths` |
@@ -620,25 +713,26 @@ not part of the restore, its data is reported as skipped rather than guessed at.
620
713
  <summary><b>⚠️ A backup of a running database may not be restorable</b></summary>
621
714
 
622
715
  Data directories are copied file by file while your servers keep running — the panel does not stop or
623
- freeze anything to take an archive, because doing so would mean a backup could take your services down.
716
+ freeze anything, because that would mean a backup could take your services down.
624
717
 
625
- That is fine for files, uploads and most app data. It is **not** a consistent snapshot of a live
626
- database: SQLite mid-transaction, a Postgres data directory, or a WAL in the middle of a write can all
627
- be captured torn, and the copy will look complete while failing to open.
718
+ Fine for files, uploads and most app data. **Not** a consistent snapshot of a live database: SQLite
719
+ mid-transaction, a Postgres data directory, or a WAL mid-write can be captured torn, and the copy will
720
+ look complete while failing to open.
628
721
 
629
- For anything with a real database, do one of these before relying on the archive:
722
+ For anything with a real database, do one of these first:
630
723
 
631
- - **Quiesce it** — stop that entry from the panel, take the backup, start it again; or
724
+ - **Quiesce it** — stop that entry, take the backup, start it again; or
632
725
  - **dump it properly** (`sqlite3 app.db ".backup out.db"`, `pg_dump`, `mysqldump`) into a directory you
633
726
  declare in `backupPaths`, so the archive carries the dump rather than the live files.
634
727
 
635
728
  **Restoring** has the mirror-image hazard, and the plan names it: a data path copied over while its
636
- server is running is replaced under a live process, which keeps its old view and loses whatever it
637
- wrote since. The restore reports those entries — `Data was replaced under a running server` — and
638
- the fix is to stop and start each one, or stop them before applying.
729
+ server is running is replaced under a live process, which keeps its old view and loses what it wrote
730
+ since. The restore reports those entries — `Data was replaced under a running server` — and the fix is
731
+ to stop them before applying, or stop and start each one.
639
732
 
640
733
  </details>
641
734
 
735
+
642
736
  ---
643
737
 
644
738
  ## 🎨 Bring your own UI (BYOU)