a2s-protocol 0.1.0

A protocol core for building A2S server query clients
Documentation
a2s-protocol-0.1.0 has been yanked.

a2s-protocol

A Rust protocol core for building A2S server query clients.

It parses Source and GoldSrc server responses, including legacy multipacket formats. Feed it UDP datagrams; it assembles fragments and decompresses compressed responses. You manage the socket and decide whether your client is blocking or async.

Features

  • Parses A2S_INFO, A2S_PLAYER, and A2S_RULES responses
  • Supports Source and GoldSrc response formats
  • Reassembles Source and GoldSrc multipacket responses, including legacy and Orange Box variants
  • Decompresses bzip2-compressed responses
  • Borrows string fields from the input packet where possible; convert parsed values to owned data when needed
  • Leaves networking and runtime choices to your application

Compatibility

Response format Support
Source single-packet responses Yes
GoldSrc single-packet responses Yes
Source multipacket responses Yes
GoldSrc multipacket responses Yes
Legacy and Orange Box fragment formats Yes
Compressed multipacket responses Yes

How it fits into a client

The crate handles packet processing and payload parsing. Your client sends requests, receives datagrams, and responds to challenges.

use protocol::{PacketProcessor, Response, parse_payload};

let mut processor = PacketProcessor::new();

// For each UDP datagram received:
let Some(payload) = processor.process(addr, datagram)? else {
    // More fragments are needed before the response is complete.
    continue;
};

match parse_payload(&payload)? {
    Response::Challenge(challenge) => {
        // Resend the relevant request with this challenge.
    }
    response => {
        // Handle the parsed response.
    }
}

See examples/query.rs for a complete blocking UDP client.

Scope

The crate implements the documented A2S protocol and includes support for The Ship's additional server information. It does not currently implement unofficial game-specific extensions such as Arma or DayZ extensions.

API overview

  • info_request, players_request, rules_request build request packets.
  • PacketProcessor accepts datagrams and returns a complete packet when one is ready.
  • parse_payload parses the completed payload into a Response.