[PR #6668] horizon-gateway: a self-hostable public address for a world at home (prototype, #6667) #7024

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/6668
Author: @apeirs
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: feat/public-hostname-frontend


📝 Commits (2)

  • 2390304 horizon-gateway: a self-hostable public address for a world at home (prototype)
  • dd76d9d Merge remote-tracking branch 'upstream/main' into feat/public-hostname-frontend

📊 Changes

12 files changed (+1798 additions, -1 deletions)

View changed files

📝 AGENTS.md (+1 -0)
📝 Cargo.lock (+11 -0)
📝 Cargo.toml (+1 -0)
➕ crates/horizon-gateway/Cargo.toml (+21 -0)
➕ crates/horizon-gateway/src/agent.rs (+188 -0)
➕ crates/horizon-gateway/src/handshake.rs (+320 -0)
➕ crates/horizon-gateway/src/lib.rs (+678 -0)
➕ crates/horizon-gateway/src/main.rs (+169 -0)
➕ crates/horizon-gateway/tests/gateway.rs (+281 -0)
📝 docs/README.md (+1 -0)
📝 docs/play-with-friends.md (+2 -1)
➕ docs/public-address.md (+125 -0)

📄 Description

🤖 Opened by apeirs's AI agent (Claude Code, Claude Opus 5.5), not by apeirs personally.

Draft for discussion. This is the prototype from #6667. The shape it should take in Horizon is the open question there, so please answer on the issue. If you want it, I'll split it into reviewable pieces (it's ~1,200 lines of non-test code, over the 500-line guideline).

What and why

Fixes #6667 (once a shape is agreed).

A new crate, horizon-gateway: a self-hostable frontend that gives a world at home a public address any 26.3 client can join (pullmon.mc.example.net), without port forwarding. It's the Feather-style address, without a project-run proxy.

  • horizon-gateway serve (GATEWAY_DOMAIN=…): players connect on 25565. It reads only their handshake (ClientIntentionPacket) and routes by the first DNS label under the domain. On the control port it asks the registered host for a fresh connection, replays the handshake and copies bytes both ways under the relay's per-player and total caps. Unknown names and offline hosts get the gateway's own status and login-disconnect answers.
  • horizon-gateway expose <gateway:7001> <name> --to 127.0.0.1:25565: the host-side agent. It only makes outbound connections and reconnects with its claim.
  • Names are 3–32 of a-z0-9- and stay reserved for 24 h for the host's claim after it leaves. GATEWAY_HOST_KEYS optionally limits registration to admission keys. Per-address rate limits, the 10 s opening deadline and /health reuse horizon-relay::limits and horizon_friends::{wire, deadline}.
  • docs/public-address.md: who sees what (offline mode exposes the game to the operator; online mode only the handshake and player name), running one, DNS (wildcard A/AAAA, not SRV), the protocol, and what's not done. Also a line each in docs/README.md, play-with-friends.md and the AGENTS crate table.

No game, launcher or server code changes.

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

Horizon-only (vanilla has no gateway). It follows vanilla's wire formats, checked with javap on the 26.3 server jar:

  • ClientIntentionPacket.STREAM_CODEC: readVarInt protocol, readUtf(255) host, readUnsignedShort port, readVarInt → ClientIntent.byId (1 status, 2 login, 3 transfer).
  • ClientboundLoginDisconnectPacket: the reason as JSON (JsonOps).
  • The status response and ping/pong as vanilla's server sends them.

The SRV note follows #5096: vanilla's ConnectScreen sends the resolved SRV target in the login handshake.

Other projects' code

none

Self-check

pr_ready.py wasn't run. The new workspace member changes the root Cargo.toml, which makes it select the whole workspace's tests, and the owner's machine is limited to short local runs right now. What did run:

cargo fmt -p horizon-gateway -- --check                              ok
cargo clippy -p horizon-gateway --all-targets -- -D warnings         ok (on a build machine, after merging main 20c6194da)
cargo test -p horizon-gateway                                        12 passed (7 unit, 5 integration), 3 runs in a row
python3 tools/check_public_tree.py                                   passed

CI's verify job (workspace-wide fmt, clippy and tests) and launcher job passed on dd76d9db5.

End to end by hand (2026-11-01, scratch dirs, nightly d91cab6), with GATEWAY_DOMAIN=mc.localhost on loopback in front of horizon-server:

  • a vanilla-protocol server list ping of pullmon.mc.localhost:25590 returned the server's own status (A Minecraft Server, 0/20) and the pong, the same as a direct ping;
  • nobody.mc.localhost got the gateway's "No world has this address";
  • a Horizon client (horizon-ctl connect pullmon.mc.localhost:25590 Alice) joined (the server logged Alice joined the game); chat went both ways (<Alice> hello through the gateway in the server log, [Server] hi Alice in the client's chat), and /health counted 431 KB bridged.

🔄 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/6668 **Author:** [@apeirs](https://github.com/apeirs) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/public-hostname-frontend` --- ### 📝 Commits (2) - [`2390304`](https://github.com/horizon-rust/horizon/commit/2390304db1342b85d6cc114448d7736a00087bfb) horizon-gateway: a self-hostable public address for a world at home (prototype) - [`dd76d9d`](https://github.com/horizon-rust/horizon/commit/dd76d9db5bd738d0fff52431a207efa2ceb0c616) Merge remote-tracking branch 'upstream/main' into feat/public-hostname-frontend ### 📊 Changes **12 files changed** (+1798 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `AGENTS.md` (+1 -0) 📝 `Cargo.lock` (+11 -0) 📝 `Cargo.toml` (+1 -0) ➕ `crates/horizon-gateway/Cargo.toml` (+21 -0) ➕ `crates/horizon-gateway/src/agent.rs` (+188 -0) ➕ `crates/horizon-gateway/src/handshake.rs` (+320 -0) ➕ `crates/horizon-gateway/src/lib.rs` (+678 -0) ➕ `crates/horizon-gateway/src/main.rs` (+169 -0) ➕ `crates/horizon-gateway/tests/gateway.rs` (+281 -0) 📝 `docs/README.md` (+1 -0) 📝 `docs/play-with-friends.md` (+2 -1) ➕ `docs/public-address.md` (+125 -0) </details> ### 📄 Description > 🤖 Opened by apeirs's AI agent (Claude Code, Claude Opus 5.5), not by apeirs personally. **Draft for discussion.** This is the prototype from #6667. The shape it should take in Horizon is the open question there, so please answer on the issue. If you want it, I'll split it into reviewable pieces (it's ~1,200 lines of non-test code, over the 500-line guideline). ## What and why Fixes #6667 (once a shape is agreed). A new crate, `horizon-gateway`: a self-hostable frontend that gives a world at home a public address any 26.3 client can join (`pullmon.mc.example.net`), without port forwarding. It's the Feather-style address, without a project-run proxy. - `horizon-gateway serve` (`GATEWAY_DOMAIN=…`): players connect on 25565. It reads only their handshake (`ClientIntentionPacket`) and routes by the first DNS label under the domain. On the control port it asks the registered host for a fresh connection, replays the handshake and copies bytes both ways under the relay's per-player and total caps. Unknown names and offline hosts get the gateway's own status and login-disconnect answers. - `horizon-gateway expose <gateway:7001> <name> --to 127.0.0.1:25565`: the host-side agent. It only makes outbound connections and reconnects with its claim. - Names are 3–32 of `a-z0-9-` and stay reserved for 24 h for the host's claim after it leaves. `GATEWAY_HOST_KEYS` optionally limits registration to admission keys. Per-address rate limits, the 10 s opening deadline and `/health` reuse `horizon-relay::limits` and `horizon_friends::{wire, deadline}`. - `docs/public-address.md`: who sees what (offline mode exposes the game to the operator; online mode only the handshake and player name), running one, DNS (wildcard A/AAAA, not SRV), the protocol, and what's not done. Also a line each in `docs/README.md`, `play-with-friends.md` and the AGENTS crate table. No game, launcher or server code changes. ## 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) - [x] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only (vanilla has no gateway). It follows vanilla's wire formats, checked with `javap` on the 26.3 server jar: - `ClientIntentionPacket.STREAM_CODEC`: `readVarInt` protocol, `readUtf(255)` host, `readUnsignedShort` port, `readVarInt` → `ClientIntent.byId` (1 status, 2 login, 3 transfer). - `ClientboundLoginDisconnectPacket`: the reason as JSON (`JsonOps`). - The status response and ping/pong as vanilla's server sends them. The SRV note follows #5096: vanilla's `ConnectScreen` sends the resolved SRV target in the login handshake. ## Other projects' code none ## Self-check `pr_ready.py` wasn't run. The new workspace member changes the root `Cargo.toml`, which makes it select the whole workspace's tests, and the owner's machine is limited to short local runs right now. What did run: ``` cargo fmt -p horizon-gateway -- --check ok cargo clippy -p horizon-gateway --all-targets -- -D warnings ok (on a build machine, after merging main 20c6194da) cargo test -p horizon-gateway 12 passed (7 unit, 5 integration), 3 runs in a row python3 tools/check_public_tree.py passed ``` CI's `verify` job (workspace-wide fmt, clippy and tests) and `launcher` job passed on dd76d9db5. End to end by hand (2026-11-01, scratch dirs, nightly d91cab6), with `GATEWAY_DOMAIN=mc.localhost` on loopback in front of `horizon-server`: - a vanilla-protocol server list ping of `pullmon.mc.localhost:25590` returned the server's own status (`A Minecraft Server`, 0/20) and the pong, the same as a direct ping; - `nobody.mc.localhost` got the gateway's "No world has this address"; - a Horizon client (`horizon-ctl connect pullmon.mc.localhost:25590 Alice`) joined (the server logged `Alice joined the game`); chat went both ways (`<Alice> hello through the gateway` in the server log, `[Server] hi Alice` in the client's chat), and `/health` counted 431 KB bridged. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7024
No description provided.