[PR #5165] [MERGED] horizon-server: config and backups in the control API, and a fixed address and token #6114

Closed
opened 2026-11-03 06:12:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: server-admin/config-backups


📝 Commits (1)

  • d9c7334 horizon-server: config and backups in the control API, and a fixed address and token

📊 Changes

11 files changed (+527 additions, -68 deletions)

View changed files

📝 crates/horizon-server/src/api.rs (+287 -9)
📝 crates/horizon-server/src/config.rs (+65 -16)
📝 crates/horizon-server/src/http.rs (+32 -4)
📝 crates/horizon-server/src/panel.rs (+3 -3)
📝 crates/horizon-server/src/reference.rs (+1 -1)
📝 crates/horizon-server/src/settings.rs (+52 -21)
📝 docs/api/server-reference.md (+12 -0)
📝 docs/api/server.md (+10 -5)
📝 docs/hosting.md (+22 -0)
📝 docs/server.md (+9 -4)
📝 tools/server_admin_e2e.py (+34 -5)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Roadmap server-admin, part 2 of the admin API. Stacked on #5163 (based on its branch; retarget to main once it merges).

What it adds

  • A fixed address and token for programs that run elsewhere or keep their settings (bunchy's Discord !ban bridge, a monitoring tool): a new [api] section in server.toml:
    [api]
    bind = ""            # "" a free port on 127.0.0.1 (as today); or 127.0.0.1:8131, or a tailnet address
    token = ""           # 16+ characters; "" a new random one at every start (as today)
    allow_public = false # true lets bind be any address; warns at every start
    
    Same rules as [panel]: loopback or tailnet only unless allow_public. Nothing changes for an existing server.
  • GET /api/v1/config (server.toml by section, api.token hidden) and PATCH /api/v1/config {"changes": {"world.difficulty": "hard"}}: the same code as horizon-server config set (validated, comments kept, live where vanilla can: difficulty, default game mode, whitelist). The API can't change [engine] (what program runs), [panel], [api], nor RCON/query/management keys, so a token can't widen who reaches the server.
  • DELETE /api/v1/backups?name= and GET /api/v1/backups/download?name= (exact names from the list only; the zip is streamed from the file, not read into memory: http::Response::stream).
  • The panel now wants its X-Horizon CSRF header on every non-GET call (PATCH and DELETE are new methods).

Tests

  • Unit: fixed bind + token (right token 200, a near miss 401), config GET/PATCH (token hidden, refused sections 403, bad value 400 and nothing written), backup download headers and delete (a ../ name is 404).
  • tools/server_admin_e2e.py now runs the API on the [api] address and token, and checks a live difficulty change (The difficulty is Hard from the game, server.toml updated), engine.path refused, and a backup made, downloaded byte for byte and deleted. Passed on the Mac mini.

pr_ready below ran against main, so its scope counts #5163 too; this PR alone is +527 −68.

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at bd541458c, 2 min 33 s)

Check Result
Scope ⚠️ 13 files, +1311 −70; 1280 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 31 s)
rustfmt ✅ (5 s)
clippy ✅ (43 s)
tests: horizon-server ✅ 64 passed (10 s)
doc tests ➖ no library touched
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ✅ 1 affected, all passed already with these inputs (1 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/5165 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `server-admin/config-backups` --- ### 📝 Commits (1) - [`d9c7334`](https://github.com/horizon-rust/horizon/commit/d9c733419c9610185a82d36371ac66c39b7565ee) horizon-server: config and backups in the control API, and a fixed address and token ### 📊 Changes **11 files changed** (+527 additions, -68 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-server/src/api.rs` (+287 -9) 📝 `crates/horizon-server/src/config.rs` (+65 -16) 📝 `crates/horizon-server/src/http.rs` (+32 -4) 📝 `crates/horizon-server/src/panel.rs` (+3 -3) 📝 `crates/horizon-server/src/reference.rs` (+1 -1) 📝 `crates/horizon-server/src/settings.rs` (+52 -21) 📝 `docs/api/server-reference.md` (+12 -0) 📝 `docs/api/server.md` (+10 -5) 📝 `docs/hosting.md` (+22 -0) 📝 `docs/server.md` (+9 -4) 📝 `tools/server_admin_e2e.py` (+34 -5) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Roadmap `server-admin`, part 2 of the admin API. **Stacked on #5163** (based on its branch; retarget to main once it merges). ## What it adds - **A fixed address and token** for programs that run elsewhere or keep their settings (bunchy's Discord `!ban` bridge, a monitoring tool): a new `[api]` section in `server.toml`: ```toml [api] bind = "" # "" a free port on 127.0.0.1 (as today); or 127.0.0.1:8131, or a tailnet address token = "" # 16+ characters; "" a new random one at every start (as today) allow_public = false # true lets bind be any address; warns at every start ``` Same rules as `[panel]`: loopback or tailnet only unless `allow_public`. Nothing changes for an existing server. - `GET /api/v1/config` (server.toml by section, `api.token` hidden) and `PATCH /api/v1/config {"changes": {"world.difficulty": "hard"}}`: the same code as `horizon-server config set` (validated, comments kept, live where vanilla can: difficulty, default game mode, whitelist). The API can't change `[engine]` (what program runs), `[panel]`, `[api]`, nor RCON/query/management keys, so a token can't widen who reaches the server. - `DELETE /api/v1/backups?name=` and `GET /api/v1/backups/download?name=` (exact names from the list only; the zip is streamed from the file, not read into memory: `http::Response::stream`). - The panel now wants its `X-Horizon` CSRF header on every non-GET call (PATCH and DELETE are new methods). ## Tests - Unit: fixed bind + token (right token 200, a near miss 401), config GET/PATCH (token hidden, refused sections 403, bad value 400 and nothing written), backup download headers and delete (a `../` name is 404). - `tools/server_admin_e2e.py` now runs the API on the `[api]` address and token, and checks a live difficulty change (`The difficulty is Hard` from the game, `server.toml` updated), `engine.path` refused, and a backup made, downloaded byte for byte and deleted. Passed on the Mac mini. pr_ready below ran against main, so its scope counts #5163 too; this PR alone is +527 −68. **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at bd541458c, 2 min 33 s) | Check | Result | | --- | --- | | Scope | ⚠️ 13 files, +1311 −70; 1280 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 31 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (43 s) | | tests: horizon-server | ✅ 64 passed (10 s) | | doc tests | ➖ no library touched | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ✅ 1 affected, all passed already with these inputs (1 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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-03 06:12:06 +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#6114
No description provided.