[PR #1009] [MERGED] horizon-server config: change server.toml's settings from the command line, live where vanilla can #2982

Closed
opened 2026-11-02 16:00:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: feat/server-config-command


📝 Commits (3)

  • 42bb310 horizon-server config: read and change server.toml's settings, live where vanilla can
  • 43287c1 horizon-server whitelist add: the offline UUID on a running offline server
  • a4b7ac4 horizon-server update: unpack as the user, not the archive's owners

📊 Changes

8 files changed (+446 additions, -13 deletions)

View changed files

📝 crates/horizon-server/src/cli.rs (+17 -2)
📝 crates/horizon-server/src/config.rs (+10 -2)
📝 crates/horizon-server/src/lists.rs (+38 -0)
📝 crates/horizon-server/src/main.rs (+12 -3)
➕ crates/horizon-server/src/settings.rs (+330 -0)
📝 crates/horizon-server/src/update.rs (+18 -1)
📝 docs/hosting.md (+14 -2)
📝 docs/server.md (+7 -3)

📄 Description

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

What

horizon-server config, so a front end (the launcher's new Servers page, next PRs) changes a server's settings without its own copy of the rules:

  • horizon-server config [--json]: the settings in server.toml.
  • horizon-server config set KEY=VALUE... [--json], for example config set world.difficulty=hard server.max_players=10.
    • Values take the type of the setting (on/off work for booleans). properties.<vanilla-key> works for any other key.
    • Vanilla's clamps are checked: view and simulation distance 2 to 32. Max players must be 1 to 1000.
    • The result is checked as server.toml is checked. If any value is wrong, nothing is written.
    • Edits go through toml_edit, so comments and order stay.
  • Running server. It sends what vanilla changes live through its console: difficulty, defaultgamemode and whitelist on|off. The [backups] (and [updates]) settings apply at once because the supervisor reads them each time. Everything else waits for the next start.
    • The output says what applied now and what needs a restart.
    • --json gives {"saved", "applied", "restart", "running"}.
  • Also backups --json (name, bytes, modified) and update --check --json (installed, newest, available, previous).

docs/server.md and docs/hosting.md describe the command.

Also: horizon-server whitelist add on a running offline server.

  • The game resolves names as vanilla does (CachedUserNameToIdResolver: Mojang first, offline only if Mojang doesn't know the name). So on an offline server, a name someone owns at Mojang got that account's UUID.
  • The player joins under the offline UUID, so they were still refused (not_whitelisted). This hit the launcher's default (friends only, offline).
  • Now, when the server runs offline, horizon-server whitelist add writes the offline entry and sends whitelist reload. The game's own console command is unchanged (parity).
  • Live on the Mac mini: before, bot Friend0 was refused after whitelist add (whitelist.json had a v4 UUID). After, it got 07e507b8-823c-3118-… (offline v3), and the bot and then a real Horizon client joined.

Also: horizon-server update unpacks as the user (tar --no-same-owner).

  • As root in a user namespace (an unprivileged LXC or rootless container), GNU tar keeps the archive's owners by default and fails on IDs it can't map. The update then stopped at "tar couldn't unpack … (exit status: 2)", and the server stayed on its old release.
  • Found by pressing the launcher's Update now on the ThinkPad, with the launcher in its own user and network namespace. With the fix, the same button updated v2026.10.19.09 to the real v2026.10.19.10 release. It backed up first (…-before-v2026-10-19-10.zip), and a bot joined after the update.
  • --no-same-owner is also what tar does for a normal user, and bsdtar (macOS, Windows) accepts it.

Why

Brief launcher-server-1 (Ludovic: "people who want a Rust server never have to touch code or read a doc"). The launcher's Settings form drives horizon-server rather than editing server.toml itself.

How tested

  • Unit tests: typed parsing and the range/format errors, the live command per setting, and a stopped-server set that keeps comments and writes nothing on a bad value.
  • Live on the Mac mini, with a scratch server on the v2026.10.19.09 engine:
    $ horizon-server --dir srv1 config set world.difficulty=hard server.max_players=8 world.game_mode=creative backups.every=1h --json
    {"applied":["world.difficulty","world.game_mode","backups.every"],"restart":["server.max_players"],"running":true,"saved":[...]}
    $ horizon-server --dir srv1 config set server.whitelist=true
    Applied now: server.whitelist
    [Server thread/INFO]: System chat: The difficulty has been set to Hard
    [Server thread/INFO]: System chat: The default game mode is now Creative Mode
    [Server thread/INFO]: System chat: Whitelist is now turned on
    $ horizon-server --dir srv1 backups --json
    [{"bytes":5292542,"modified":1792409339,"name":"2026-10-19_11-28-57-manual.zip"}]
    

Self-check:

  • cargo fmt --all -- --check: clean.
  • cargo clippy -p horizon-server --all-targets -- -D warnings: clean.
  • cargo test -p horizon-server: 40 passed (the lists test covers the running-offline case; the update tests unpack a real tarball).
  • tools/parity.py --changed origin/main: 0 of 323 harnesses depend on these files.

#990 adds [updates] keep. config set updates.keep=2 works with it as is, because keys are read from the configuration itself.

Nothing needs Ludovic.

🤖 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/1009 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/server-config-command` --- ### 📝 Commits (3) - [`42bb310`](https://github.com/horizon-rust/horizon/commit/42bb310df9176745c839167a3090a103772c9c72) horizon-server config: read and change server.toml's settings, live where vanilla can - [`43287c1`](https://github.com/horizon-rust/horizon/commit/43287c18c24b6acc21e6e03dc45f6dc3154d075b) horizon-server whitelist add: the offline UUID on a running offline server - [`a4b7ac4`](https://github.com/horizon-rust/horizon/commit/a4b7ac4a9b85fe890e7e0221946534a7595005f9) horizon-server update: unpack as the user, not the archive's owners ### 📊 Changes **8 files changed** (+446 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-server/src/cli.rs` (+17 -2) 📝 `crates/horizon-server/src/config.rs` (+10 -2) 📝 `crates/horizon-server/src/lists.rs` (+38 -0) 📝 `crates/horizon-server/src/main.rs` (+12 -3) ➕ `crates/horizon-server/src/settings.rs` (+330 -0) 📝 `crates/horizon-server/src/update.rs` (+18 -1) 📝 `docs/hosting.md` (+14 -2) 📝 `docs/server.md` (+7 -3) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `horizon-server config`, so a front end (the launcher's new Servers page, next PRs) changes a server's settings without its own copy of the rules: - `horizon-server config [--json]`: the settings in `server.toml`. - `horizon-server config set KEY=VALUE... [--json]`, for example `config set world.difficulty=hard server.max_players=10`. - Values take the type of the setting (`on`/`off` work for booleans). `properties.<vanilla-key>` works for any other key. - Vanilla's clamps are checked: view and simulation distance 2 to 32. Max players must be 1 to 1000. - The result is checked as `server.toml` is checked. If any value is wrong, nothing is written. - Edits go through `toml_edit`, so comments and order stay. - **Running server.** It sends what vanilla changes live through its console: `difficulty`, `defaultgamemode` and `whitelist on|off`. The `[backups]` (and `[updates]`) settings apply at once because the supervisor reads them each time. Everything else waits for the next start. - The output says what applied now and what needs a restart. - `--json` gives `{"saved", "applied", "restart", "running"}`. - Also `backups --json` (name, bytes, modified) and `update --check --json` (installed, newest, available, previous). docs/server.md and docs/hosting.md describe the command. **Also: `horizon-server whitelist add` on a running offline server.** - The game resolves names as vanilla does (`CachedUserNameToIdResolver`: Mojang first, offline only if Mojang doesn't know the name). So on an offline server, a name someone owns at Mojang got that account's UUID. - The player joins under the offline UUID, so they were still refused (`not_whitelisted`). This hit the launcher's default (friends only, offline). - Now, when the server runs offline, `horizon-server whitelist add` writes the offline entry and sends `whitelist reload`. The game's own console command is unchanged (parity). - Live on the Mac mini: before, bot `Friend0` was refused after `whitelist add` (whitelist.json had a v4 UUID). After, it got `07e507b8-823c-3118-…` (offline v3), and the bot and then a real Horizon client joined. **Also: `horizon-server update` unpacks as the user (`tar --no-same-owner`).** - As root in a user namespace (an unprivileged LXC or rootless container), GNU tar keeps the archive's owners by default and fails on IDs it can't map. The update then stopped at "tar couldn't unpack … (exit status: 2)", and the server stayed on its old release. - Found by pressing the launcher's **Update now** on the ThinkPad, with the launcher in its own user and network namespace. With the fix, the same button updated v2026.10.19.09 to the real v2026.10.19.10 release. It backed up first (`…-before-v2026-10-19-10.zip`), and a bot joined after the update. - `--no-same-owner` is also what tar does for a normal user, and bsdtar (macOS, Windows) accepts it. ## Why Brief launcher-server-1 (Ludovic: "people who want a Rust server never have to touch code or read a doc"). The launcher's Settings form drives `horizon-server` rather than editing `server.toml` itself. ## How tested - Unit tests: typed parsing and the range/format errors, the live command per setting, and a stopped-server `set` that keeps comments and writes nothing on a bad value. - Live on the Mac mini, with a scratch server on the v2026.10.19.09 engine: ``` $ horizon-server --dir srv1 config set world.difficulty=hard server.max_players=8 world.game_mode=creative backups.every=1h --json {"applied":["world.difficulty","world.game_mode","backups.every"],"restart":["server.max_players"],"running":true,"saved":[...]} $ horizon-server --dir srv1 config set server.whitelist=true Applied now: server.whitelist [Server thread/INFO]: System chat: The difficulty has been set to Hard [Server thread/INFO]: System chat: The default game mode is now Creative Mode [Server thread/INFO]: System chat: Whitelist is now turned on $ horizon-server --dir srv1 backups --json [{"bytes":5292542,"modified":1792409339,"name":"2026-10-19_11-28-57-manual.zip"}] ``` Self-check: - `cargo fmt --all -- --check`: clean. - `cargo clippy -p horizon-server --all-targets -- -D warnings`: clean. - `cargo test -p horizon-server`: 40 passed (the lists test covers the running-offline case; the update tests unpack a real tarball). - `tools/parity.py --changed origin/main`: 0 of 323 harnesses depend on these files. #990 adds `[updates] keep`. `config set updates.keep=2` works with it as is, because keys are read from the configuration itself. Nothing needs Ludovic. 🤖 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 16:00:37 +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#2982
No description provided.