GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - gamespice-platform/server-query: Godot 4 addon that lets a game server answer who is on it and what it runs. Speaks two protocols from one snapshot: DQP (JSON over UDP or WebSocket, extensible, conditional polling) and A2S (UDP, off by default), so they never disagree on the player count. Part of GameSpice.

BranchesTags
Open more actions menu

Latest commit

 

History

47 Commits
47 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
addons/gs_server_query
addons/gs_server_query
 
 
ci/efficiency
ci/efficiency
 
 
docs
docs
 
 
examples
examples
 
 
.gitignore
.gitignore
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
project.godot
project.godot
 
 

Repository files navigation

Server Query - GameSpice addon

Lets a game server answer "who is on you, what are you running, and is it worth joining". It speaks two protocols from one snapshot, so they never disagree about the player count.

This is a GameSpice addon, MIT licensed and built with Claude Code. examples/query_selftest.tscn runs headless and exercises both protocols. The query port is live on the servers of the games in Zee's Games, which are all built on GameSpice addons. Bug reports go to the issue tracker.

DQP (the GS query protocol) A2S
Default on off
Transport UDP, and WebSocket when enabled UDP only
Body JSON packed bytes
Extensible add a field breaks parsers
Game state a whole section substrings in keywords
Conditional polling yes (if_rev) no
Reachable from a browser yes no
Existing tooling none twenty years of it

Server-list sites, chat bots and uptime monitors speak A2S, so all of A2S is implemented, every request and every extra-data field.

Install

  1. Get Godot 4.7.
  2. Either use GameSpice Bootstrap, which clones every project and links the addons, or copy addons/gs_server_query/, GameSpice Core's addons/gs_core/ and GameSpice Server's addons/gs_server/ into your project and enable gs-server-query in Project > Project Settings > Plugins.

GameSpice Stats is optional.

Use

var host := GSQueryHost.new()
host.app_url = "your-app-url"   # the app's URL segment on the website
server.add_child(host)          # finds the server and plugs itself in

A server with no host attached answers nothing on the query port.

One socket, or two

The protocols are told apart by their first four bytes (FF FF FF FF is A2S, DQP1 is DQP), so both can answer on one UDP port. The game port is the only port a tracker will try.

config.query_enabled = true
config.a2s_enabled = true
config.query_port = 0      # 0 = the A2S port, so one socket serves both
config.a2s_port = 0        # 0 = the game port

Different ports bind separately. On the game port with GameSpice Server's default transport (GSTransportDual) both protocols share the transport's UDP socket and nothing binds a second one. If another process or a plain ENet transport holds the port, the bind fails and the log says so. Then set query_port to a free port, though most trackers will not look there.

Every query is challenged

UDP source addresses are easy to forge, and a query is a small request with a large reply, which is how amplification attacks work. An unchallenged request gets a cookie smaller than the request. The cookie is an HMAC of the address, port and time, so a forger never receives one. The server stores nothing per request, only one 32-byte secret.

What a query can ask for

Section Content
info Identity, counts, addresses. info.connecting shows players still joining.
players One row per player, governed by query_player_detail.
rules Server variables a querier may see.
game Whatever the game contributes through a GSQueryProvider.
teams Sides and their sizes.
rotation What is playing, what is next, what else this server runs.
perf Tick, frame time, memory, uptime.
build Engine, server and platform versions.
stats Declared statistics, their schema and server-wide totals.
player_stats Per-player statistics. Off unless an operator configures it.

Every response carries a revision that changes only when something meaningful did. Send the one you hold and get a few bytes back when nothing moved:

{"sections": ["info", "players"], "if_rev": 41}

From a browser

With query_websocket on, the same protocol is served as JSON text frames:

const ws = new WebSocket("ws://example.com:27018");
ws.onopen = () => ws.send(JSON.stringify({ sections: ["info", "players"] }));
ws.onmessage = e => console.log(JSON.parse(e.data));

Adding your game's state

class FcQuery extends GSQueryProvider:
    func _provider_name() -> String:
        return "fc"

    func _contribute(snapshot: GSQuerySnapshot) -> void:
        snapshot.info["bots"] = match_state.bot_count()
        snapshot.contribute_game({
            "phase": match_state.phase_name(),
            "round": match_state.round_number,
            "time_left": match_state.seconds_remaining(),
        })

GSRegistry.get_service(&"gs_query_source").add_provider(FcQuery.new())

Only a provider can report the bot count, because the server never sees a bot connect. The map shown in info.map is GameSpice Server's GSGameManager.reported_map(): the map the game reported with set_current_map, or the game's display name. Reporting a map drops the cached snapshot.

Statistics

GSQueryStats bridges GameSpice Stats without depending on it.

Kind Default
What this server has done since it booted On, identifies nobody.
Published stats totalled across everyone On, identifies nobody.
One row per player Off. Also needs player_key_format (or a resolver). Rows carry the display name and userid only, never the stats key.

Protocol

addons/gs_server_query/PROTOCOL.md is enough to write a client in any language and ends with one in about thirty lines of Python. GameSpice Browser is the client for a Godot project.

Testing

Import the project once, then run examples/query_selftest.tscn headless with Godot. It runs both protocols without a socket and also binds the listeners for real.

Used by

Zee's Games

Zee's Games is a collection of games I made on GameSpice, for demonstration and for fun. They show what the platform can do, and they run on live servers you can join. Anybody can create games on GameSpice, and each addon is its own repository and can be used separately from the games and from the rest of GameSpice.

These games vendor this addon:

  • Fatal Contact
  • Airdrift
  • Playlot
  • Hungario
  • Buses From Hell
  • Smash Copter
  • Zombie Zone
  • Hide n Seek
  • Prop Hunt
  • Murder Mystery
  • Deathrun
  • Dangerous Delivery
  • Look At Me

The whole collection is at zeesgames.com.

Licence

MIT licence, see LICENSE. The only closed part of the GameSpice platform is the web back end; you can use your own instead of GameSpice's.

About

Godot 4 addon that lets a game server answer who is on it and what it runs. Speaks two protocols from one snapshot: DQP (JSON over UDP or WebSocket, extensible, conditional polling) and A2S (UDP, off by default), so they never disagree on the player count. Part of GameSpice.

gamespice.net

Topics

a2sa2s-infoa2s-packetsa2s-querygamedevgamedevelopmentgamespicegdscriptgodotgodot-4godot-addongodot-enginegodot-game-enginegodot-plugingodot4godotenginequeryserver-queriesserver-query

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.