[GH-ISSUE #6108] GS4 Query: serve vanilla's UDP query (enable-query, query.port) #1977

Closed
opened 2026-11-02 15:51:03 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Akirabane on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6108

Originally assigned to: @Akirabane on GitHub.

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

enable-query and query.port are read from server.properties (horizon-server-files) and horizon-server blocks changing them through the control API, but nothing listens: a vanilla server with enable-query=true answers GameSpy4 (GS4) queries over UDP, Horizon doesn't. The port map lists QueryThreadGs4 and PktUtils as "Horizon has no RCON or GS4 query port" (tools/port_map/rest-020.tsv; the RCON half is done since #5416). Server lists, status pages, Discord bots and monitoring tools (mcstatus, Prometheus exporters, hosting panels) use this query to read the player list, the MOTD and the version, so this is what stops them working against a Horizon server.

No pull request, issue or branch for it that I could find on origin/main 1c47bf7fd (searched query, gs4 and enable-query in open and closed pull requests and issues, and git ls-remote for branches).

Plan

One pull request, crates/horizon-server/src/query.rs, started by the supervisor next to the RCON listener (rcon.rs), so it answers while the game restarts:

  • Settings as vanilla's QueryThreadGs4.create reads them: it listens on UDP server-ip (or 0.0.0.0) and query.port. An invalid port leaves the query off with a warning; a port that can't be bound is a warning, not a failed start.
  • The protocol as QueryThreadGs4 speaks it: the handshake (a request of type 9 answers with a challenge token), then the basic stat and the full stat (key/values and the player list), each only with a valid token. Packet layout and the token's lifetime are taken from the decompiled class with javap, not from memory.
  • The answers come from the game's own status (MOTD, max players, the names online, the world, the version, the port), through a read-only request to the game like the one the control API's status uses. No engine change.
  • Where it deliberately differs (each one named in the code and in docs/server.md): to be decided while reading the vanilla class, and listed here before the pull request is opened.

The query stays off by default, as in vanilla. It reveals the player names and the version to anyone who can reach the UDP port; the docs say so.

How it is checked

Unit tests for the framing, the token and both stat replies, and a test running the real listener on a loopback UDP port against a stand-in for the game's status. As a player: with a test server, a small UDP script prints the MOTD, the version and who is online; no Minecraft client needs to do anything and there are no bots or benchmark. A comparison with the vanilla server.jar on the same packets can follow as its own pull request if the team wants it.

I'm claiming it next, and will say here if the design needs to change.

Originally created by @Akirabane on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6108 Originally assigned to: @Akirabane on GitHub. > 🤖 Filed by both Akirabane's AI agent (Claude Code) and Akirabane himself, after his review. `enable-query` and `query.port` are read from `server.properties` (`horizon-server-files`) and `horizon-server` blocks changing them through the control API, but nothing listens: a vanilla server with `enable-query=true` answers GameSpy4 (GS4) queries over UDP, Horizon doesn't. The port map lists `QueryThreadGs4` and `PktUtils` as "Horizon has no RCON or GS4 query port" (`tools/port_map/rest-020.tsv`; the RCON half is done since #5416). Server lists, status pages, Discord bots and monitoring tools (mcstatus, Prometheus exporters, hosting panels) use this query to read the player list, the MOTD and the version, so this is what stops them working against a Horizon server. No pull request, issue or branch for it that I could find on `origin/main` 1c47bf7fd (searched `query`, `gs4` and `enable-query` in open and closed pull requests and issues, and `git ls-remote` for branches). ## Plan One pull request, `crates/horizon-server/src/query.rs`, started by the supervisor next to the RCON listener (`rcon.rs`), so it answers while the game restarts: - **Settings as vanilla's `QueryThreadGs4.create` reads them**: it listens on UDP `server-ip` (or `0.0.0.0`) and `query.port`. An invalid port leaves the query off with a warning; a port that can't be bound is a warning, not a failed start. - **The protocol as `QueryThreadGs4` speaks it**: the handshake (a request of type 9 answers with a challenge token), then the basic stat and the full stat (key/values and the player list), each only with a valid token. Packet layout and the token's lifetime are taken from the decompiled class with `javap`, not from memory. - **The answers come from the game's own status** (MOTD, max players, the names online, the world, the version, the port), through a read-only request to the game like the one the control API's status uses. No engine change. - **Where it deliberately differs** (each one named in the code and in `docs/server.md`): to be decided while reading the vanilla class, and listed here before the pull request is opened. The query stays off by default, as in vanilla. It reveals the player names and the version to anyone who can reach the UDP port; the docs say so. ## How it is checked Unit tests for the framing, the token and both stat replies, and a test running the real listener on a loopback UDP port against a stand-in for the game's status. As a player: with a test server, a small UDP script prints the MOTD, the version and who is online; no Minecraft client needs to do anything and there are no bots or benchmark. A comparison with the vanilla `server.jar` on the same packets can follow as its own pull request if the team wants it. I'm claiming it next, and will say here if the design needs to change.
Author
Owner

@Akirabane commented on GitHub (Nov 1, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6560939538 --> @Akirabane commented on GitHub (Nov 1, 2026): 🤖 Agent: /claim
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#1977
No description provided.