horizon-server: the web panel

One page embedded in the binary (crates/horizon-server/panel: HTML, CSS and JS, no framework or CDN): status,
live TPS, MSPT, RAM and CPU graphs over the last 10 minutes, players with op and kick, the console, and
backups with restore, plus restart and stop.

It listens on [panel] bind, 127.0.0.1:8130 by default; a tailnet address reaches it from the owner's
devices, and any other address is refused unless allow_public is set. `horizon-server panel` prints a
one-time login link (10 minutes) that becomes an HttpOnly, SameSite=Strict session cookie. The Host header
must name the panel, every POST needs X-Horizon: 1, failed logins are rate-limited, and the page is served
with a strict Content-Security-Policy. The control API gains GET /api/v1/metrics and, with the token
only, POST /api/v1/panel/login.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-16 22:18:46 +02:00
parent ed6af00ff8
commit 7f77772e15
10 changed files with 1029 additions and 18 deletions
+18
View File
@@ -158,6 +158,24 @@ pub fn command(dir: &Path, words: &[String]) -> Result<(), String> {
Ok(())
}
/// `panel`: a one-time login link for the web panel.
pub fn panel(dir: &Path) -> Result<(), String> {
let reply = running(dir)?.call("POST", "/api/v1/panel/login", None)?;
let url = reply["url"].as_str().unwrap_or_default();
println!(
"Open this link in your browser (it works once, for 10 minutes):\n {url}\n\
From another computer: put a tailnet address in [panel] bind, or forward the port first:\n \
ssh -L {port}:{target} <this server>",
port = url
.split('/')
.nth(2)
.and_then(|h| h.rsplit_once(':'))
.map_or("8130", |(_, p)| p),
target = url.split('/').nth(2).unwrap_or("127.0.0.1:8130"),
);
Ok(())
}
/// `status [--json]`.
pub fn status(dir: &Path, as_json: bool) -> Result<(), String> {
let Some(client) = Client::open(dir)? else {