[PR #5163] [MERGED] horizon-server: players, moderation and Prometheus metrics in the control API #6110

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

📋 Pull Request Information

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

Base: main ← Head: server-admin/api


📝 Commits (1)

  • c50f97e horizon-server: players, moderation and Prometheus metrics in the control API

📊 Changes

7 files changed (+793 additions, -11 deletions)

View changed files

➕ crates/horizon-server/src/admin.rs (+446 -0)
📝 crates/horizon-server/src/api.rs (+105 -2)
📝 crates/horizon-server/src/main.rs (+1 -0)
📝 docs/api/server-reference.md (+12 -0)
📝 docs/api/server.md (+16 -6)
📝 docs/server.md (+8 -3)
➕ tools/server_admin_e2e.py (+205 -0)

📄 Description

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

Roadmap server-admin, part 1 of the admin API: what the official server's moderators asked for (kick, ban and op from outside the game) and what a Discord !ban bridge needs, without scraping the console.

What it adds to the control API

  • GET /api/v1/players: online players (name, uuid, address, ping, op level), max_players, and vanilla's lists (ops, whitelist with on/off, bans and IP bans with reason, source, created, expires).
  • POST /api/v1/players/{kick,ban,pardon,ban-ip,pardon-ip,op,deop}, POST /api/v1/whitelist {enabled}, POST /api/v1/whitelist/{add,remove}. Each one runs vanilla's console command on the running game (the code from #4680 / #4796), so it kicks, logs and saves the JSON files exactly as an operator's command does. The reply is {"changed": bool, "output": [...]}: whether the list file (or, for a kick, who is online) changed, and the console's lines. Names and reasons are checked first (no spaces in a name, one line of reason), so no body can add words or lines to the command.
  • GET /api/v1/metrics/prometheus: the latest sample as Prometheus text (horizon_up, horizon_tps, horizon_mspt{stat=average|p50|p95|p99}, horizon_players_online, horizon_chunks_loaded, horizon_memory_rss_bytes, horizon_cpu_percent...).

Same auth as today: the token in .horizon/api.json, 127.0.0.1 only. The web panel goes through the same routes. Next PRs: a fixed address and token in server.toml (for a bot that runs elsewhere), config GET/PATCH and backup download/delete; then the SSE event stream, horizon-server console, horizon-server mcp and vanilla's management protocol.

Tests

  • Unit: actions → console lines (and the refused inputs), players and Prometheus text without a game.
  • tools/server_admin_e2e.py (new): horizon-server run supervises a real dedicated server, two horizon-bots join, and every endpoint is checked against the reply, vanilla's files and the server log (op/deop, whitelist, ban-ip/pardon-ip, kick, ban/pardon, whitelist on/off, Prometheus, 401 without the token, 400 for a bad name). Passed on the Mac mini:
server_admin_e2e: the admin API listed, opped, whitelisted, banned, pardoned and kicked as vanilla does

Scope: pr_ready counts 759 lines of code; ~310 of them are unit tests and ~205 the e2e. The CLI commands (players, kick, ban...) are split into their own PR.

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

Check Result
Scope ⚠️ 7 files, +793 −11; 759 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 53 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 8 s)
tests: horizon-server ✅ 62 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 (3 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/5163 **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/api` --- ### 📝 Commits (1) - [`c50f97e`](https://github.com/horizon-rust/horizon/commit/c50f97ec8fe299965e828f8f646f4e5695230351) horizon-server: players, moderation and Prometheus metrics in the control API ### 📊 Changes **7 files changed** (+793 additions, -11 deletions) <details> <summary>View changed files</summary> ➕ `crates/horizon-server/src/admin.rs` (+446 -0) 📝 `crates/horizon-server/src/api.rs` (+105 -2) 📝 `crates/horizon-server/src/main.rs` (+1 -0) 📝 `docs/api/server-reference.md` (+12 -0) 📝 `docs/api/server.md` (+16 -6) 📝 `docs/server.md` (+8 -3) ➕ `tools/server_admin_e2e.py` (+205 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Roadmap `server-admin`, part 1 of the admin API: what the official server's moderators asked for (kick, ban and op from outside the game) and what a Discord `!ban` bridge needs, without scraping the console. ## What it adds to the control API - `GET /api/v1/players`: online players (name, uuid, address, ping, op level), `max_players`, and vanilla's lists (ops, whitelist with on/off, bans and IP bans with reason, source, created, expires). - `POST /api/v1/players/{kick,ban,pardon,ban-ip,pardon-ip,op,deop}`, `POST /api/v1/whitelist {enabled}`, `POST /api/v1/whitelist/{add,remove}`. Each one runs **vanilla's console command** on the running game (the code from #4680 / #4796), so it kicks, logs and saves the JSON files exactly as an operator's command does. The reply is `{"changed": bool, "output": [...]}`: whether the list file (or, for a kick, who is online) changed, and the console's lines. Names and reasons are checked first (no spaces in a name, one line of reason), so no body can add words or lines to the command. - `GET /api/v1/metrics/prometheus`: the latest sample as Prometheus text (`horizon_up`, `horizon_tps`, `horizon_mspt{stat=average|p50|p95|p99}`, `horizon_players_online`, `horizon_chunks_loaded`, `horizon_memory_rss_bytes`, `horizon_cpu_percent`...). Same auth as today: the token in `.horizon/api.json`, 127.0.0.1 only. The web panel goes through the same routes. Next PRs: a fixed address and token in `server.toml` (for a bot that runs elsewhere), config GET/PATCH and backup download/delete; then the SSE event stream, `horizon-server console`, `horizon-server mcp` and vanilla's management protocol. ## Tests - Unit: actions → console lines (and the refused inputs), players and Prometheus text without a game. - `tools/server_admin_e2e.py` (new): `horizon-server run` supervises a real dedicated server, two horizon-bots join, and every endpoint is checked against the reply, vanilla's files and the server log (op/deop, whitelist, ban-ip/pardon-ip, kick, ban/pardon, whitelist on/off, Prometheus, 401 without the token, 400 for a bad name). Passed on the Mac mini: ``` server_admin_e2e: the admin API listed, opped, whitelisted, banned, pardoned and kicked as vanilla does ``` Scope: pr_ready counts 759 lines of code; ~310 of them are unit tests and ~205 the e2e. The CLI commands (`players`, `kick`, `ban`...) are split into their own PR. **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at bd541458c, 3 min 23 s) | Check | Result | | --- | --- | | Scope | ⚠️ 7 files, +793 −11; 759 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 53 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 8 s) | | tests: horizon-server | ✅ 62 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 (3 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:11:57 +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#6110
No description provided.