RCON v0.4.0 RCON.Packet View Source

Module for handling RCON packets.

Link to this section Summary

Functions

Returns the packet ID used for auth failure.

Returns the body for a packet.

Returns the body length in bytes for a packet.

Creates and encodes a packet in one step.

Decodes a packet payload from transmission.

Decodes a packet size.

Encodes a packet to a binary for transmission.

Returns from what side the packet was sent from.

Returns the ID for a packet.

Returns the length in bytes of the packet id part.

Returns the initial packet ID value.

Returns the kind for a packet.

Returns the packet kind for a code.

Returns the length in bytes of the packet kind part.

Returns the code for a packet kind.

Returns the maximum size a body may have.

Returns the max possible value a packet ID may have.

The smallest value packet size may be.

Returns the length in bytes of the packet size part.

Link to this section Types

Specs

body() :: binary()

Specs

from() :: :client | :server

Specs

id() :: integer()

Specs

kind() :: :exec | :exec_resp | :auth | :auth_resp

Specs

kind_code() :: 0 | 2 | 3

Specs

raw() :: binary()

Specs

size() :: integer()

Specs

t() :: {kind(), id(), body(), from()}

Link to this section Functions

Specs

auth_failed_id() :: id()

Returns the packet ID used for auth failure.

Specs

body(t()) :: body()

Returns the body for a packet.

Specs

body_len(t()) :: integer()

Returns the body length in bytes for a packet.

Does not include the null character.

Link to this function

create(kind, body, id \\ 0, from \\ :client)

View Source

Specs

create(kind(), body(), id(), from()) :: {:ok, t()} | {:error, binary()}

Creates a packet.

Link to this function

create_and_encode(kind, body, id \\ 0, from \\ :client)

View Source

Specs

create_and_encode(kind(), body(), id(), from()) ::
  {:ok, raw()} | {:error, binary()}

Creates and encodes a packet in one step.

Link to this function

decode_payload(size, payload, from \\ :server)

View Source

Specs

decode_payload(size(), binary(), from()) :: {:ok, t()} | {:error, binary()}

Decodes a packet payload from transmission.

Specs

decode_size(binary()) :: {:ok, size()} | {:error, binary()}

Decodes a packet size.

Specs

encode(t()) :: {:ok, raw()} | {:error, binary()}

Encodes a packet to a binary for transmission.

Specs

from(t()) :: from()

Returns from what side the packet was sent from.

Specs

id(t()) :: id()

Returns the ID for a packet.

Specs

id_part_len() :: integer()

Returns the length in bytes of the packet id part.

Specs

initial_id() :: id()

Returns the initial packet ID value.

Specs

kind(t()) :: kind()

Returns the kind for a packet.

Link to this function

kind_from_code(kind_code, from)

View Source

Specs

kind_from_code(kind_code(), from()) :: {:ok, kind()} | {:error, binary()}

Returns the packet kind for a code.

Specs

kind_part_len() :: integer()

Returns the length in bytes of the packet kind part.

Link to this function

kind_to_code(kind, from)

View Source

Specs

kind_to_code(kind(), from()) :: {:ok, kind_code()} | {:error, binary()}

Returns the code for a packet kind.

Specs

max_body_len() :: integer()

Returns the maximum size a body may have.

Minecraft only supports a request payload length of max 1446 byte. However some tests showed that only requests with a payload length of 1413 byte or lower work reliably.

Specs

max_id() :: id()

Returns the max possible value a packet ID may have.

Value from signed int32 max (2^31 - 1).

Specs

min_size() :: size()

The smallest value packet size may be.

Specs

size_part_len() :: integer()

Returns the length in bytes of the packet size part.