A class for querying Source game servers (e.g., GoldSource, Source Engine) using the A2S protocol. Supports retrieving server information, player information, and server rules.

const source = new Source('127.0.0.1', 27015);
const info = await source.getInfo();
console.log(info);

Constructors

  • Creates a new Source server query instance.

    Parameters

    • params: SourceParams

      A JSON object containing the configuration for the Source instance.

      • Optionaldebug?: boolean

        Enables debug logging if set to true. If not provided, the default value is false.

      • host: string

        The IP address or hostname of the server. This is a required property.

      • port: number

        The port number of the server. This is a required property.

      • Optionaltimeout?: number

        The timeout duration (in milliseconds) for server queries. If not provided, the default value is 5000.

    Returns Source

Methods

  • Retrieves server rules.

    Returns Promise<Record<string, string>>

    A promise that resolves with a map of server rules.