[PR #603] [MERGED] Integrated server: Open to LAN #2668

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

📋 Pull Request Information

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

Base: main ← Head: perf/sp-open-to-lan


📝 Commits (3)

  • dc42425 Integrated server: Open to LAN
  • bbed107 Merge main into perf/sp-open-to-lan
  • c2f2e15 Merge main into perf/sp-open-to-lan

📊 Changes

14 files changed (+571 additions, -118 deletions)

View changed files

📝 crates/horizon-client/examples/lan_flat.rs (+1 -0)
📝 crates/horizon-client/src/game.rs (+4 -1)
📝 crates/horizon-client/src/game/commands/extra.rs (+20 -6)
📝 crates/horizon-client/src/game/debug_keys.rs (+1 -1)
📝 crates/horizon-client/src/game/dedicated.rs (+1 -0)
📝 crates/horizon-client/src/game/integrated.rs (+268 -17)
📝 crates/horizon-client/src/game/lan.rs (+88 -34)
📝 crates/horizon-client/src/game/lan_actions.rs (+25 -0)
📝 crates/horizon-client/src/game/lan_screen.rs (+68 -18)
📝 crates/horizon-client/src/lan/conn.rs (+2 -1)
📝 crates/horizon-client/src/lan/hub.rs (+13 -2)
📝 crates/horizon-client/src/lan/mod.rs (+75 -38)
📝 crates/horizon-client/tests/lan_bot.rs (+1 -0)
📝 crates/horizon-protocol/src/connection.rs (+4 -0)

📄 Description

What and why

On its server thread (#544), single player could not be opened to the LAN. The window is a client of its own server. So Open to LAN, /publish and horizon-ctl lan open all tried to start a second hub on the window's side. This is gap 4 of the server-thread default (#494/#495).

The server thread now publishes itself, the way IntegratedServer.publishServer / unpublishServer do.

How the window talks to its server

  • New Integrated::call, the equivalent of executeBlocking. The window hands the server thread a task, which runs between two ticks (even while paused), and gets its answer back.
  • New Lan::listen / listen_on / stop_listening, so the hub can start and stop accepting network connections while the in-memory connection stays up.

Publishing

  • The port is bound at once, so a busy port fails right away.
  • The hub then listens and announces the world (LanServerPinger). The MOTD is <owner> - <world>, as in IntegratedServer.initServer.
  • Until the world is published, only the owner may log in. After that, anyone may, and status pings are answered.

Unpublishing

  • It stops the listener and sends every player but the owner away (multiplayer.disconnect.server_shutdown).

Commands and permissions

  • /publish and /unpublish run on the server, for the player who types them.
  • Players get the integrated server's command tree: publish is included and the dedicated-only commands are not.
  • Every player's command runs at their own permission level.
  • The owner's level follows Allow Commands.
  • Other players get game master commands only when guests may use commands and the world allows them (getCustomPermissionLevel).

Screens and pausing

  • The world options screen reads and applies its settings on the server: difficulty, default and personal game mode, Allow Commands and the LAN section. The window shows the outcome.
  • A published world does not pause (Minecraft.pause requires !isPublished). F3+Escape follows the same rule.

Compression

  • Memory connections are never compressed (Connection.isMemoryConnection), so network players get the usual threshold of 256.

Checked by hand (--server-thread)

  • horizon-ctl lan open publishes on a free port. A status ping gets Player - lanA, 1/8 players.
  • A second client (--server 127.0.0.1:<port> --name Guesty) joins and is placed.
  • horizon-ctl lan close sends the guest back to the title. The owner keeps playing, and the port refuses connections.
  • /unpublish and /publish typed as the owner work.
  • With the pause menu open and the world published, the world keeps running.

Checks

  • cargo fmt --all --check: ok
  • cargo clippy -p horizon-client --all-targets -- -D warnings: ok
  • cargo test -p horizon-client --lib: 772 passed, 0 failed
  • Local parity, run once on the stack top (this PR, the next one and #602): 83 passed, 1 failed in 77.6 min. The failure is world_spawn, on 2 of its 60 seeds (-9075835740570717616, -2080727421395798566), where vanilla itself gives several spawns: it varies between 125 and 129, and between 64, 66 and 72. Rerun on those seeds: Horizon spawns where one of vanilla's runs does, so both pass. The stack below (#596) was 84/84.

The game rules view of the world options screen still edits the window's copy of the rules. It is not covered here.

Stacked on #596. skip-release until single player uses the server thread by default.

🤖 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/603 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `perf/sp-open-to-lan` --- ### 📝 Commits (3) - [`dc42425`](https://github.com/horizon-rust/horizon/commit/dc42425c0197c5918ba3739d5aa20b8678af6199) Integrated server: Open to LAN - [`bbed107`](https://github.com/horizon-rust/horizon/commit/bbed107a6a4bad766117cab388449e77aab931de) Merge main into perf/sp-open-to-lan - [`c2f2e15`](https://github.com/horizon-rust/horizon/commit/c2f2e15643e4dae251dc1f75bdfd10f7218fbd78) Merge main into perf/sp-open-to-lan ### 📊 Changes **14 files changed** (+571 additions, -118 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/lan_flat.rs` (+1 -0) 📝 `crates/horizon-client/src/game.rs` (+4 -1) 📝 `crates/horizon-client/src/game/commands/extra.rs` (+20 -6) 📝 `crates/horizon-client/src/game/debug_keys.rs` (+1 -1) 📝 `crates/horizon-client/src/game/dedicated.rs` (+1 -0) 📝 `crates/horizon-client/src/game/integrated.rs` (+268 -17) 📝 `crates/horizon-client/src/game/lan.rs` (+88 -34) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+25 -0) 📝 `crates/horizon-client/src/game/lan_screen.rs` (+68 -18) 📝 `crates/horizon-client/src/lan/conn.rs` (+2 -1) 📝 `crates/horizon-client/src/lan/hub.rs` (+13 -2) 📝 `crates/horizon-client/src/lan/mod.rs` (+75 -38) 📝 `crates/horizon-client/tests/lan_bot.rs` (+1 -0) 📝 `crates/horizon-protocol/src/connection.rs` (+4 -0) </details> ### 📄 Description ## What and why On its server thread (#544), single player could not be opened to the LAN. The window is a client of its own server. So Open to LAN, `/publish` and `horizon-ctl lan open` all tried to start a second hub on the window's side. This is gap 4 of the server-thread default (#494/#495). The server thread now publishes itself, the way `IntegratedServer.publishServer` / `unpublishServer` do. **How the window talks to its server** - New `Integrated::call`, the equivalent of `executeBlocking`. The window hands the server thread a task, which runs between two ticks (even while paused), and gets its answer back. - New `Lan::listen` / `listen_on` / `stop_listening`, so the hub can start and stop accepting network connections while the in-memory connection stays up. **Publishing** - The port is bound at once, so a busy port fails right away. - The hub then listens and announces the world (`LanServerPinger`). The MOTD is `<owner> - <world>`, as in `IntegratedServer.initServer`. - Until the world is published, only the owner may log in. After that, anyone may, and status pings are answered. **Unpublishing** - It stops the listener and sends every player but the owner away (`multiplayer.disconnect.server_shutdown`). **Commands and permissions** - `/publish` and `/unpublish` run on the server, for the player who types them. - Players get the integrated server's command tree: `publish` is included and the dedicated-only commands are not. - Every player's command runs at their own permission level. - The owner's level follows Allow Commands. - Other players get game master commands only when guests may use commands *and* the world allows them (`getCustomPermissionLevel`). **Screens and pausing** - The world options screen reads and applies its settings on the server: difficulty, default and personal game mode, Allow Commands and the LAN section. The window shows the outcome. - A published world does not pause (`Minecraft.pause` requires `!isPublished`). F3+Escape follows the same rule. **Compression** - Memory connections are never compressed (`Connection.isMemoryConnection`), so network players get the usual threshold of 256. ## Checked by hand (`--server-thread`) - `horizon-ctl lan open` publishes on a free port. A status ping gets `Player - lanA`, 1/8 players. - A second client (`--server 127.0.0.1:<port> --name Guesty`) joins and is placed. - `horizon-ctl lan close` sends the guest back to the title. The owner keeps playing, and the port refuses connections. - `/unpublish` and `/publish` typed as the owner work. - With the pause menu open and the world published, the world keeps running. ## Checks - `cargo fmt --all --check`: ok - `cargo clippy -p horizon-client --all-targets -- -D warnings`: ok - `cargo test -p horizon-client --lib`: 772 passed, 0 failed - Local parity, run once on the stack top (this PR, the next one and #602): 83 passed, 1 failed in 77.6 min. The failure is `world_spawn`, on 2 of its 60 seeds (-9075835740570717616, -2080727421395798566), where vanilla itself gives several spawns: it varies between 125 and 129, and between 64, 66 and 72. Rerun on those seeds: Horizon spawns where one of vanilla's runs does, so both pass. The stack below (#596) was 84/84. The game rules view of the world options screen still edits the window's copy of the rules. It is not covered here. Stacked on #596. `skip-release` until single player uses the server thread by default. 🤖 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:58:05 +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#2668
No description provided.