# rcon.source package

## Submodules

## rcon.source.async_rcon module

Asynchronous RCON.

async rcon.source.async_rcon.rcon(command: str, *arguments: str, host: str, port: int, passwd: str, encoding: str = 'utf-8', frag_threshold: int = 4096, frag_detect_cmd: str = '') → str

  Run a command asynchronously.

## rcon.source.client module

Synchronous client.

class rcon.source.client.Client(*args, frag_threshold: int = 4096, frag_detect_cmd: str = '', **kwargs)

  Bases: `BaseClient`

  An RCON client.

  communicate(packet: Packet) → Packet

    Send and receive a packet.

  login(passwd: str, *, encoding: str = 'utf-8') → bool

    Perform a login.

  read() → Packet

    Read a packet from the server.

  run(command: str, *args: str, encoding: str = 'utf-8') → str

    Run a command.

  send(packet: Packet) → None

    Send a packet to the server.

## rcon.source.proto module

Low-level protocol stuff.

class rcon.source.proto.LittleEndianSignedInt32(*_)

  Bases: `int`

  A little-endian, signed int32.

  MAX = 2147483647
  MIN = -2147483648
  async classmethod aread(reader: StreamReader) → LittleEndianSignedInt32

    Read the integer from an asynchronous file-like object.

  classmethod read(file: IO) → LittleEndianSignedInt32

    Read the integer from a file-like object.

class rcon.source.proto.Packet(id: LittleEndianSignedInt32, type: Type, payload: bytes, terminator: bytes = b'\x00\x00')

  Bases: `NamedTuple`

  An RCON packet.

  async classmethod aread(reader: StreamReader) → Packet

    Read a packet from an asynchronous file-like object.

  id: LittleEndianSignedInt32

    Alias for field number 0

  classmethod make_command(*args: str, encoding: str = 'utf-8') → Packet

    Create a command packet.

  classmethod make_login(passwd: str, *, encoding: str = 'utf-8') → Packet

    Create a login packet.

  payload: bytes

    Alias for field number 2

  classmethod read(file: IO) → Packet

    Read a packet from a file-like object.

  terminator: bytes

    Alias for field number 3

  type: Type

    Alias for field number 1

class rcon.source.proto.Type(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

  Bases: `LittleEndianSignedInt32`, `Enum`

  RCON packet types.

  SERVERDATA_AUTH = 3
  SERVERDATA_AUTH_RESPONSE = 2
  SERVERDATA_EXECCOMMAND = 2
  SERVERDATA_RESPONSE_VALUE = 0
  async classmethod aread(reader: StreamReader, *, prefix: str = '') → Type

    Read the type from an asynchronous file-like object.

  classmethod read(file: IO, *, prefix: str = '') → Type

    Read the type from a file-like object.

rcon.source.proto.random_request_id() → LittleEndianSignedInt32

  Generate a random request ID.

## Module contents

Source RCON implementation.

class rcon.source.Client(*args, frag_threshold: int = 4096, frag_detect_cmd: str = '', **kwargs)

  Bases: `BaseClient`

  An RCON client.

  communicate(packet: Packet) → Packet

    Send and receive a packet.

  login(passwd: str, *, encoding: str = 'utf-8') → bool

    Perform a login.

  read() → Packet

    Read a packet from the server.

  run(command: str, *args: str, encoding: str = 'utf-8') → str

    Run a command.

  send(packet: Packet) → None

    Send a packet to the server.

async rcon.source.rcon(command: str, *arguments: str, host: str, port: int, passwd: str, encoding: str = 'utf-8', frag_threshold: int = 4096, frag_detect_cmd: str = '') → str

  Run a command asynchronously.