[PR #5416] [MERGED] horizon-server: RCON, the vanilla remote console #6274

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

📋 Pull Request Information

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

Base: main ← Head: feat/rcon


📝 Commits (5)

  • 42b500a horizon-server: RCON, the vanilla remote console
  • 74862c7 Merge main into feat/rcon
  • 9a4d8f2 Merge main into feat/rcon
  • b49e817 Merge main into feat/rcon
  • 8424089 Merge main into feat/rcon

📊 Changes

8 files changed (+748 additions, -16 deletions)

View changed files

📝 crates/horizon-server/src/main.rs (+1 -0)
➕ crates/horizon-server/src/rcon.rs (+689 -0)
📝 crates/horizon-server/src/supervisor.rs (+1 -0)
📝 docs/api/server.md (+3 -0)
📝 docs/hosting.md (+27 -0)
📝 docs/server.md (+11 -0)
📝 tools/port_map/rest-017.tsv (+2 -2)
📝 tools/port_map/rest-020.tsv (+14 -14)

📄 Description

🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane himself after his review.

What and why

Fixes #5389.

enable-rcon, rcon.port and rcon.password were read from server.properties but nothing listened, so hosting panels, Discord bridges and scripts written for vanilla's remote console couldn't talk to a Horizon server. The supervisor now serves RCON (crates/horizon-server/src/rcon.rs, started next to the management server in supervisor.rs), so it answers while the game restarts. A command goes to the game as horizon-server cmd sends it (console <line> on the control endpoint): no engine change.

  • Settings as RconThread.create reads them: it listens on server-ip (every address when empty) and rcon.port. A port outside 1 to 65535 or an empty rcon.password leaves it off with vanilla's warning, and a port that can't be bound is a warning, not a server that doesn't start. Off by default.
  • Protocol as RconClient speaks it: login (3), command (2), replies of at most 4096 characters per packet (one, even when empty), -1 for a refused login (the connection stays open), Unknown request <hex> for another type, Error executing: <command> (<reason>) for a command that failed. The output of the console's messages is joined with no separator, as RconConsoleSource appends them.
  • Where it differs, on purpose (named in rcon.rs and in the docs): packets are read from the stream (vanilla takes one read as one packet, so a command TCP splits closes the connection); the password is compared in constant time; a connection that hasn't logged in within 30 seconds is closed and at most 16 are open (vanilla has neither limit); a reply is cut at 4096 characters where vanilla cuts at 4096 UTF-16 units.
  • Known gap, for a follow-up: a command shows as the console's ([Server]), not Rcon, and broadcast-rcon-to-ops isn't honoured (the feedback of a command from cmd doesn't go to operators today either).
  • Docs: docs/hosting.md (how to turn it on, the clear-text warning, how to turn it off again), docs/server.md section 8, docs/api/server.md.

The size: 689 lines in rcon.rs, of which 342 are tests. I couldn't see a way to ship the protocol, the listener and the settings in separate pull requests that each do something.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

net.minecraft.server.rcon.thread.RconThread (create, run, stop), RconClient (run, send, sendCmdResponse), RconConsoleSource and PktUtils, read with javap -p -c on server-game.jar 26.3, and DedicatedServer.runCommand. The ledger rows in tools/port_map/rest-017.tsv and rest-020.tsv now point at the Rust functions (port_ledger.py map-check: 256 rows, no problems). There is no comparison against the vanilla server.jar yet: a harness like tools/test_management_protocol_parity.py would be its own pull request.

Other projects' code

none

Self-check

pr_ready (tools/pr_ready.py --quick on DESKTOP-6PU1HU6, against origin/main at c27101174, 2 min 2 s)

Check Result
Scope ⚠️ 8 files, +747 −16; 723 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 500 run, FAILED (errors=1, skipped=2) (1 min 22 s)
rustfmt ✅ (12 s)
clippy ❌ failed (16 s)
tests: horizon-server ✅ 77 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 ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Two failures here are not from this change:

  • clippy fails on horizon-threads alone on Windows (cargo clippy -p horizon-threads alone fails the same way, and this pull request doesn't touch that crate): boot_paint.rs uses windows_sys::Win32::UI and Graphics, which its Cargo.toml doesn't enable. cargo clippy -p horizon-server --all-targets -- -D warnings is clean.
  • Python tests: the one error is test_port_ledger importing tests.test_class_index, shadowed by a global tests package on this machine; the other 499 pass.

Proof

No game code changes. The diff touches crates/horizon-server (the supervisor), the docs and the port-ledger rows, and nothing in horizon-client, saves, the network protocol or world generation. Single-player, LAN and the dedicated engine run the same code as before, so lan_e2e has nothing new to exercise: a command reaches the game through the console request that horizon-server cmd already uses.

Unit tests: 9 new ones in rcon.rs (the packet bytes, login and commands with a wrong and an empty password, a command before login, an unknown type, a failing command, empty output, a reply of 4096 characters in two packets, a request split by TCP and two in one write, the lengths vanilla closes on, the login deadline and the connection cap, the settings and their three warnings, and server.toml to a listening RCON that reaches a stand-in for the game's control endpoint). horizon-server: 79 pass after merging main.

On a real server (horizon-server start, online mode, RCON on 127.0.0.1:25575 with a random test password), with a small stdlib Python RCON client. Each reply is (request id, type, payload):

command before login  -> (-1, 2, '')
wrong password        -> (-1, 2, '')
right password        -> (3, 2, '')
'list'                -> (10, 0, 'There are 0 of a max of 20 players online: ')
'say RCON works'      -> (11, 0, '[Not Secure] [Server] RCON works')
'nonsense'            -> (13, 0, 'Unknown or incomplete command. See below for errornonsense<--[HERE]')
unknown type 7        -> (99, 0, 'Unknown request 7')

The error line has no separator between the console's two messages, as RconConsoleSource appends them. With a player online, list answered There are 1 of a max of 20 players online: Akirabane, and a say sent over RCON showed in that player's chat as [Server] ....

The supervisor's log for that run:

[19:54:14] [Supervisor/INFO]: RCON running on 127.0.0.1:25575
[19:56:24] [Supervisor/WARN]: RCON login refused from 127.0.0.1
[19:56:24] [Server thread/INFO]: System chat: There are 0 of a max of 20 players online: 
[19:56:24] [Server thread/INFO]: [Not Secure] [Server] RCON works

The server was then stopped with horizon-server stop (worlds saved, no process left).


🔄 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/5416 **Author:** [@Akirabane](https://github.com/Akirabane) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/rcon` --- ### 📝 Commits (5) - [`42b500a`](https://github.com/horizon-rust/horizon/commit/42b500a769d6f3fcf3ca67fd4aade91f2c53623f) horizon-server: RCON, the vanilla remote console - [`74862c7`](https://github.com/horizon-rust/horizon/commit/74862c7996d61f47c901b4361d8c16793b5ce585) Merge main into feat/rcon - [`9a4d8f2`](https://github.com/horizon-rust/horizon/commit/9a4d8f2beaf8061bf21cac0dd9bcfaab60731954) Merge main into feat/rcon - [`b49e817`](https://github.com/horizon-rust/horizon/commit/b49e81782196f7b743873ef5769e9ba73b0bb7c1) Merge main into feat/rcon - [`8424089`](https://github.com/horizon-rust/horizon/commit/84240899437506d1b2cea97ca73c62abc7199c4e) Merge main into feat/rcon ### 📊 Changes **8 files changed** (+748 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-server/src/main.rs` (+1 -0) ➕ `crates/horizon-server/src/rcon.rs` (+689 -0) 📝 `crates/horizon-server/src/supervisor.rs` (+1 -0) 📝 `docs/api/server.md` (+3 -0) 📝 `docs/hosting.md` (+27 -0) 📝 `docs/server.md` (+11 -0) 📝 `tools/port_map/rest-017.tsv` (+2 -2) 📝 `tools/port_map/rest-020.tsv` (+14 -14) </details> ### 📄 Description > 🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane himself after his review. ## What and why Fixes #5389. `enable-rcon`, `rcon.port` and `rcon.password` were read from `server.properties` but nothing listened, so hosting panels, Discord bridges and scripts written for vanilla's remote console couldn't talk to a Horizon server. The supervisor now serves RCON (`crates/horizon-server/src/rcon.rs`, started next to the management server in `supervisor.rs`), so it answers while the game restarts. A command goes to the game as `horizon-server cmd` sends it (`console <line>` on the control endpoint): no engine change. - **Settings** as `RconThread.create` reads them: it listens on `server-ip` (every address when empty) and `rcon.port`. A port outside 1 to 65535 or an empty `rcon.password` leaves it off with vanilla's warning, and a port that can't be bound is a warning, not a server that doesn't start. Off by default. - **Protocol** as `RconClient` speaks it: login (3), command (2), replies of at most 4096 characters per packet (one, even when empty), `-1` for a refused login (the connection stays open), `Unknown request <hex>` for another type, `Error executing: <command> (<reason>)` for a command that failed. The output of the console's messages is joined with no separator, as `RconConsoleSource` appends them. - **Where it differs, on purpose** (named in `rcon.rs` and in the docs): packets are read from the stream (vanilla takes one `read` as one packet, so a command TCP splits closes the connection); the password is compared in constant time; a connection that hasn't logged in within 30 seconds is closed and at most 16 are open (vanilla has neither limit); a reply is cut at 4096 characters where vanilla cuts at 4096 UTF-16 units. - **Known gap, for a follow-up**: a command shows as the console's (`[Server]`), not `Rcon`, and `broadcast-rcon-to-ops` isn't honoured (the feedback of a command from `cmd` doesn't go to operators today either). - **Docs**: `docs/hosting.md` (how to turn it on, the clear-text warning, how to turn it off again), `docs/server.md` section 8, `docs/api/server.md`. The size: 689 lines in `rcon.rs`, of which 342 are tests. I couldn't see a way to ship the protocol, the listener and the settings in separate pull requests that each do something. ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `net.minecraft.server.rcon.thread.RconThread` (`create`, `run`, `stop`), `RconClient` (`run`, `send`, `sendCmdResponse`), `RconConsoleSource` and `PktUtils`, read with `javap -p -c` on `server-game.jar` 26.3, and `DedicatedServer.runCommand`. The ledger rows in `tools/port_map/rest-017.tsv` and `rest-020.tsv` now point at the Rust functions (`port_ledger.py map-check`: 256 rows, no problems). There is no comparison against the vanilla `server.jar` yet: a harness like `tools/test_management_protocol_parity.py` would be its own pull request. ## Other projects' code none ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-6PU1HU6, against origin/main at c27101174, 2 min 2 s) | Check | Result | | --- | --- | | Scope | ⚠️ 8 files, +747 −16; 723 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 500 run, FAILED (errors=1, skipped=2) (1 min 22 s) | | rustfmt | ✅ (12 s) | | clippy | ❌ failed (16 s) | | tests: horizon-server | ✅ 77 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 | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Two failures here are not from this change: - **clippy** fails on `horizon-threads` alone on Windows (`cargo clippy -p horizon-threads` alone fails the same way, and this pull request doesn't touch that crate): `boot_paint.rs` uses `windows_sys::Win32::UI` and `Graphics`, which its `Cargo.toml` doesn't enable. `cargo clippy -p horizon-server --all-targets -- -D warnings` is clean. - **Python tests**: the one error is `test_port_ledger` importing `tests.test_class_index`, shadowed by a global `tests` package on this machine; the other 499 pass. ## Proof **No game code changes.** The diff touches `crates/horizon-server` (the supervisor), the docs and the port-ledger rows, and nothing in `horizon-client`, saves, the network protocol or world generation. Single-player, LAN and the dedicated engine run the same code as before, so `lan_e2e` has nothing new to exercise: a command reaches the game through the `console` request that `horizon-server cmd` already uses. **Unit tests**: 9 new ones in `rcon.rs` (the packet bytes, login and commands with a wrong and an empty password, a command before login, an unknown type, a failing command, empty output, a reply of 4096 characters in two packets, a request split by TCP and two in one write, the lengths vanilla closes on, the login deadline and the connection cap, the settings and their three warnings, and `server.toml` to a listening RCON that reaches a stand-in for the game's control endpoint). `horizon-server`: 79 pass after merging main. **On a real server** (`horizon-server start`, online mode, RCON on `127.0.0.1:25575` with a random test password), with a small stdlib Python RCON client. Each reply is (request id, type, payload): ``` command before login -> (-1, 2, '') wrong password -> (-1, 2, '') right password -> (3, 2, '') 'list' -> (10, 0, 'There are 0 of a max of 20 players online: ') 'say RCON works' -> (11, 0, '[Not Secure] [Server] RCON works') 'nonsense' -> (13, 0, 'Unknown or incomplete command. See below for errornonsense<--[HERE]') unknown type 7 -> (99, 0, 'Unknown request 7') ``` The error line has no separator between the console's two messages, as `RconConsoleSource` appends them. With a player online, `list` answered `There are 1 of a max of 20 players online: Akirabane`, and a `say` sent over RCON showed in that player's chat as `[Server] ...`. The supervisor's log for that run: ``` [19:54:14] [Supervisor/INFO]: RCON running on 127.0.0.1:25575 [19:56:24] [Supervisor/WARN]: RCON login refused from 127.0.0.1 [19:56:24] [Server thread/INFO]: System chat: There are 0 of a max of 20 players online: [19:56:24] [Server thread/INFO]: [Not Secure] [Server] RCON works ``` The server was then stopped with `horizon-server stop` (worlds saved, no process left). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:17:16 +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#6274
No description provided.