View Source A2S (elixir_a2s v0.4.3)

A collection of pure functions for forming A2S challenges, requests, and parsing responses.

Summary

Functions

Returns the challenge request packet for the given query type.

Parses a challenge response packet. Some game servers don't implement the challenge flow and will immediately respond with the requested data. In that case :immediate will be returned with the data.

Functions

@spec challenge_request(:info | :players | :rules) :: binary()

Returns the challenge request packet for the given query type.

@spec parse_challenge(binary()) ::
  {:challenge, binary()}
  | {:immediate, {:info, A2S.Info.t()}}
  | {:immediate, {:players, A2S.Players.t()}}
  | {:immediate, {:rules, A2S.Rules.t()}}
  | {:multipacket, {A2S.MultiPacketHeader.t(), binary()}}
  | {:error, A2S.ParseError.t()}

Parses a challenge response packet. Some game servers don't implement the challenge flow and will immediately respond with the requested data. In that case :immediate will be returned with the data.

If the server returns data immediately, and that data is multipacket, :multipacket will be returned.

Link to this function

parse_challenge!(packet)

View Source
@spec parse_challenge!(binary()) ::
  {:challenge, binary()}
  | {:immediate, {:info, A2S.Info.t()}}
  | {:immediate, {:players, A2S.Players.t()}}
  | {:immediate, {:rules, A2S.Rules.t()}}
  | {:multipacket, {A2S.MultiPacketHeader.t(), binary()}}
Link to this function

parse_multipacket_response(packets)

View Source
@spec parse_multipacket_response([{A2S.MultiPacketHeader.t(), binary()}]) ::
  {:info, A2S.Info.t()}
  | {:players, A2S.Player.t()}
  | {:rules, A2S.Rules.t()}
  | {:error, A2S.ParseError.t()}
Link to this function

parse_multipacket_response!(packets)

View Source
@spec parse_multipacket_response!([{A2S.MultiPacketHeader.t(), binary()}]) ::
  {:info, A2S.Info.t()} | {:players, A2S.Player.t()} | {:rules, A2S.Rules.t()}
@spec parse_response(binary()) ::
  {:info, A2S.Info.t()}
  | {:multipacket, {A2S.MultiPacketHeader.t(), binary()}}
  | {:players, A2S.Players.t()}
  | {:rules, A2S.Rules.t()}
  | {:error, A2S.ParseError.t()}
@spec parse_response!(binary()) ::
  {:info, A2S.Info.t()}
  | {:players, A2S.Player.t()}
  | {:rules, A2S.Rules.t()}
  | {:multipacket, {A2S.MultiPacketHeader.t(), binary()}}
Link to this function

sign_challenge(term, challenge)

View Source
@spec sign_challenge(:info | :players | :rules, challenge :: binary()) :: binary()