[PR #555] [MERGED] horizon-server: the web panel #2640

Closed
opened 2026-11-02 15:57:50 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/555
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: feat/horizon-server-panel


📝 Commits (10+)

  • 9d21209 horizon-server: server.toml, init, and a supervisor that runs the game
  • e883219 horizon-server: start, stop, status, cmd and logs through a local control API
  • 3510764 horizon-server: backups, restore and automatic backups
  • ed6af00 horizon-server: install scripts, a Docker image, and boot services
  • 7f77772 horizon-server: the web panel
  • 07f7e3a Merge remote-tracking branch 'origin/main' into srv-fix
  • 2483f90 Merge feat/horizon-server into feat/horizon-server-control
  • 500241c Merge feat/horizon-server-control into feat/horizon-server-backups
  • 9497516 Merge feat/horizon-server-backups into feat/horizon-server-packaging
  • b9d4ef3 Merge feat/horizon-server-packaging into feat/horizon-server-panel

📊 Changes

36 files changed (+5093 additions, -17 deletions)

View changed files

📝 .github/workflows/release.yml (+5 -4)
📝 Cargo.lock (+27 -0)
📝 Cargo.toml (+1 -1)
📝 crates/horizon-client/Cargo.toml (+2 -0)
📝 crates/horizon-client/src/game/dedicated.rs (+30 -0)
➕ crates/horizon-client/src/game/dedicated/status.rs (+100 -0)
📝 crates/horizon-client/src/lib.rs (+1 -1)
➕ crates/horizon-server-files/Cargo.toml (+16 -0)
📝 crates/horizon-server-files/src/eula.rs (+6 -1)
📝 crates/horizon-server-files/src/java_properties.rs (+0 -0)
📝 crates/horizon-server-files/src/json.rs (+0 -0)
📝 crates/horizon-server-files/src/lib.rs (+3 -3)
📝 crates/horizon-server-files/src/properties.rs (+0 -0)
📝 crates/horizon-server-files/src/user_lists.rs (+0 -0)
➕ crates/horizon-server/Cargo.toml (+29 -0)
➕ crates/horizon-server/panel/index.html (+78 -0)
➕ crates/horizon-server/panel/panel.css (+128 -0)
➕ crates/horizon-server/panel/panel.js (+270 -0)
➕ crates/horizon-server/src/api.rs (+497 -0)
➕ crates/horizon-server/src/backup.rs (+332 -0)

...and 16 more files

📄 Description

PR 4 of docs/server.md (section 11), stacked on #554: the web panel MVP.

What it does

  • One page in the binary (crates/horizon-server/panel/: HTML, CSS and JS with no framework, build step or CDN, embedded with include_str!). It shows:

    • status: phase, uptime, version, crashes;
    • live graphs of TPS, MSPT, RAM and CPU over the last 10 minutes, one sample a second;
    • players, with ping, op and kick;
    • the console: the live log and a command line;
    • backups: list, back up now, restore with confirmation;
    • restart and stop.

    It uses horizon-theme's colours, light and dark.

  • Where it listens: [panel] bind = "127.0.0.1:8130", this computer only. A tailnet address (100.64.0.0/10 or fd7a:115c:a1e0::/48) reaches it from the owner's devices. Any other address is refused unless allow_public = true, and "" turns the panel off.

  • Login: horizon-server panel prints a one-time link, good for 10 minutes, made through the token API. Opening it swaps the code for an HttpOnly; SameSite=Strict session cookie. So anyone who can read the server folder's token can sign in, and nobody else.

  • Protection:

    • Host checks against DNS rebinding: the panel's own address, localhost on loopback, or a tailnet name.
    • Every POST needs X-Horizon: 1 (against CSRF).
    • Failed logins are limited to 10 a minute.
    • A strict Content-Security-Policy (nothing loads from elsewhere), and the page can't be framed.
    • The panel uses the control API's own routes; login links can't be made from a browser session.
  • API: GET /api/v1/metrics?since= returns the samples behind the graphs (10 minutes kept), and POST /api/v1/panel/login makes a link (token only).

Tested

  • Unit tests:
    • host rules;
    • which bind addresses are allowed;
    • a full sign-in over real HTTP: the page is public, the API is not; a link works once; a cookie gives access; a POST without the header is refused and doesn't act; links can't be made from a session; a rate limit after 10 bad codes.
  • By hand on a running world (curl): login 303 with the cookie; status and metrics through the session; list ran with the header and was refused without it; a reused link got 403.
  • In a browser (headless Chromium, on a live server with bots): the graphs fill, the players list shows ping with op and kick, and backups, the console and the signed-out page all render. One bug was found and fixed: the hidden views showed under display: grid.

Checks

  • cargo fmt --all --check: clean.
  • cargo clippy --workspace --all-targets -- -D warnings: clean on every branch of the stack.
  • Tests: cargo test -p horizon-server -p horizon-server-files pass on every branch (16 server tests in 2a, 24 at the tip). horizon-server also passes clippy and its tests on Linux (the ThinkPad).
  • Parity at the stack's tip (2a–3), rebased on b4ad6538:
    • tools/parity.py dedicated_server online_mode server_files server_player_combat server_player_damage: 5 passed, 0 failed. dedicated_server includes vanilla's protocol client joining Horizon's server.
    • The full --changed origin/main set (309 harnesses, because the client crate changes) had 60 passed, 0 failed when it was stopped. The Mac mini was running out of disk, and at about 1 harness a minute the run needed 4 more hours. CI's parity covers the rest.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/555 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/horizon-server-panel` --- ### 📝 Commits (10+) - [`9d21209`](https://github.com/horizon-rust/horizon/commit/9d21209ae8c4e6f788955abab69e7b96d1ef3237) horizon-server: server.toml, init, and a supervisor that runs the game - [`e883219`](https://github.com/horizon-rust/horizon/commit/e8832190d1017de6d23eb66c0b8dc75ca35cc95f) horizon-server: start, stop, status, cmd and logs through a local control API - [`3510764`](https://github.com/horizon-rust/horizon/commit/3510764cc645989ca3cd993310cbcaa1787e7e94) horizon-server: backups, restore and automatic backups - [`ed6af00`](https://github.com/horizon-rust/horizon/commit/ed6af00ff8c5482bbd7fe6f53dfeade354f1b651) horizon-server: install scripts, a Docker image, and boot services - [`7f77772`](https://github.com/horizon-rust/horizon/commit/7f77772e152b86edf82cd7ba72dd54d062bdbf17) horizon-server: the web panel - [`07f7e3a`](https://github.com/horizon-rust/horizon/commit/07f7e3aeab80a1d3d3c76ef5b643eaaf1fa48fde) Merge remote-tracking branch 'origin/main' into srv-fix - [`2483f90`](https://github.com/horizon-rust/horizon/commit/2483f90779fa37882f4a3ceb3073fb9947e5e22b) Merge feat/horizon-server into feat/horizon-server-control - [`500241c`](https://github.com/horizon-rust/horizon/commit/500241cbc6563fdf0ff27cf4dbd36e57fccd9f71) Merge feat/horizon-server-control into feat/horizon-server-backups - [`9497516`](https://github.com/horizon-rust/horizon/commit/949751656a3cac04371b56fc3a1cd4b49796e9cf) Merge feat/horizon-server-backups into feat/horizon-server-packaging - [`b9d4ef3`](https://github.com/horizon-rust/horizon/commit/b9d4ef3194bced0584f552837b8126c98549cc48) Merge feat/horizon-server-packaging into feat/horizon-server-panel ### 📊 Changes **36 files changed** (+5093 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/release.yml` (+5 -4) 📝 `Cargo.lock` (+27 -0) 📝 `Cargo.toml` (+1 -1) 📝 `crates/horizon-client/Cargo.toml` (+2 -0) 📝 `crates/horizon-client/src/game/dedicated.rs` (+30 -0) ➕ `crates/horizon-client/src/game/dedicated/status.rs` (+100 -0) 📝 `crates/horizon-client/src/lib.rs` (+1 -1) ➕ `crates/horizon-server-files/Cargo.toml` (+16 -0) 📝 `crates/horizon-server-files/src/eula.rs` (+6 -1) 📝 `crates/horizon-server-files/src/java_properties.rs` (+0 -0) 📝 `crates/horizon-server-files/src/json.rs` (+0 -0) 📝 `crates/horizon-server-files/src/lib.rs` (+3 -3) 📝 `crates/horizon-server-files/src/properties.rs` (+0 -0) 📝 `crates/horizon-server-files/src/user_lists.rs` (+0 -0) ➕ `crates/horizon-server/Cargo.toml` (+29 -0) ➕ `crates/horizon-server/panel/index.html` (+78 -0) ➕ `crates/horizon-server/panel/panel.css` (+128 -0) ➕ `crates/horizon-server/panel/panel.js` (+270 -0) ➕ `crates/horizon-server/src/api.rs` (+497 -0) ➕ `crates/horizon-server/src/backup.rs` (+332 -0) _...and 16 more files_ </details> ### 📄 Description PR 4 of [docs/server.md](https://github.com/ludovic111/horizon/pull/557) (section 11), stacked on #554: the web panel MVP. ## What it does - **One page in the binary** (`crates/horizon-server/panel/`: HTML, CSS and JS with no framework, build step or CDN, embedded with `include_str!`). It shows: - status: phase, uptime, version, crashes; - live graphs of TPS, MSPT, RAM and CPU over the last 10 minutes, one sample a second; - players, with ping, op and kick; - the console: the live log and a command line; - backups: list, back up now, restore with confirmation; - restart and stop. It uses horizon-theme's colours, light and dark. - **Where it listens:** `[panel] bind = "127.0.0.1:8130"`, this computer only. A tailnet address (100.64.0.0/10 or fd7a:115c:a1e0::/48) reaches it from the owner's devices. Any other address is refused unless `allow_public = true`, and `""` turns the panel off. - **Login:** `horizon-server panel` prints a one-time link, good for 10 minutes, made through the token API. Opening it swaps the code for an `HttpOnly; SameSite=Strict` session cookie. So anyone who can read the server folder's token can sign in, and nobody else. - **Protection:** - Host checks against DNS rebinding: the panel's own address, `localhost` on loopback, or a tailnet name. - Every POST needs `X-Horizon: 1` (against CSRF). - Failed logins are limited to 10 a minute. - A strict Content-Security-Policy (nothing loads from elsewhere), and the page can't be framed. - The panel uses the control API's own routes; login links can't be made from a browser session. - **API:** `GET /api/v1/metrics?since=` returns the samples behind the graphs (10 minutes kept), and `POST /api/v1/panel/login` makes a link (token only). ## Tested - Unit tests: - host rules; - which bind addresses are allowed; - a full sign-in over real HTTP: the page is public, the API is not; a link works once; a cookie gives access; a POST without the header is refused and doesn't act; links can't be made from a session; a rate limit after 10 bad codes. - By hand on a running world (curl): login 303 with the cookie; `status` and `metrics` through the session; `list` ran with the header and was refused without it; a reused link got 403. - In a browser (headless Chromium, on a live server with bots): the graphs fill, the players list shows ping with op and kick, and backups, the console and the signed-out page all render. One bug was found and fixed: the hidden views showed under `display: grid`. ## Checks - `cargo fmt --all --check`: clean. - `cargo clippy --workspace --all-targets -- -D warnings`: clean on every branch of the stack. - Tests: `cargo test -p horizon-server -p horizon-server-files` pass on every branch (16 server tests in 2a, 24 at the tip). horizon-server also passes clippy and its tests on Linux (the ThinkPad). - Parity at the stack's tip (2a–3), rebased on b4ad6538: - `tools/parity.py dedicated_server online_mode server_files server_player_combat server_player_damage`: **5 passed, 0 failed**. `dedicated_server` includes vanilla's protocol client joining Horizon's server. - The full `--changed origin/main` set (309 harnesses, because the client crate changes) had **60 passed, 0 failed** when it was stopped. The Mac mini was running out of disk, and at about 1 harness a minute the run needed 4 more hours. CI's parity covers the rest. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:57:50 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2640
No description provided.