# rcon package

## Subpackages

- rcon.battleye package
  - Submodules
  - rcon.battleye.client module
    - `Client`
      - `Client.communicate()`
      - `Client.handle_server_message()`
      - `Client.login()`
      - `Client.receive()`
      - `Client.run()`
  - rcon.battleye.proto module
    - `CommandRequest`
      - `CommandRequest.command`
      - `CommandRequest.from_command()`
      - `CommandRequest.from_string()`
      - `CommandRequest.header`
      - `CommandRequest.payload`
      - `CommandRequest.seq`
    - `CommandResponse`
      - `CommandResponse.from_bytes()`
      - `CommandResponse.header`
      - `CommandResponse.message`
      - `CommandResponse.payload`
      - `CommandResponse.seq`
    - `Header`
      - `Header.crc32`
      - `Header.create()`
      - `Header.from_bytes()`
      - `Header.type`
    - `LoginRequest`
      - `LoginRequest.header`
      - `LoginRequest.payload`
    - `LoginResponse`
      - `LoginResponse.from_bytes()`
      - `LoginResponse.header`
      - `LoginResponse.success`
    - `ServerMessage`
      - `ServerMessage.from_bytes()`
      - `ServerMessage.header`
      - `ServerMessage.message`
      - `ServerMessage.payload`
      - `ServerMessage.seq`
    - `ServerMessageAck`
      - `ServerMessageAck.payload`
      - `ServerMessageAck.seq`
  - Module contents
    - `Client`
      - `Client.communicate()`
      - `Client.handle_server_message()`
      - `Client.login()`
      - `Client.receive()`
      - `Client.run()`
    - `ServerMessage`
      - `ServerMessage.from_bytes()`
      - `ServerMessage.header`
      - `ServerMessage.message`
      - `ServerMessage.payload`
      - `ServerMessage.seq`
- rcon.source package
  - Submodules
  - rcon.source.async_rcon module
    - `rcon()`
  - rcon.source.client module
    - `Client`
      - `Client.communicate()`
      - `Client.login()`
      - `Client.read()`
      - `Client.run()`
      - `Client.send()`
  - rcon.source.proto module
    - `LittleEndianSignedInt32`
      - `LittleEndianSignedInt32.MAX`
      - `LittleEndianSignedInt32.MIN`
      - `LittleEndianSignedInt32.aread()`
      - `LittleEndianSignedInt32.read()`
    - `Packet`
      - `Packet.aread()`
      - `Packet.id`
      - `Packet.make_command()`
      - `Packet.make_login()`
      - `Packet.payload`
      - `Packet.read()`
      - `Packet.terminator`
      - `Packet.type`
    - `Type`
      - `Type.SERVERDATA_AUTH`
      - `Type.SERVERDATA_AUTH_RESPONSE`
      - `Type.SERVERDATA_EXECCOMMAND`
      - `Type.SERVERDATA_RESPONSE_VALUE`
      - `Type.aread()`
      - `Type.read()`
    - `random_request_id()`
  - Module contents
    - `Client`
      - `Client.communicate()`
      - `Client.login()`
      - `Client.read()`
      - `Client.run()`
      - `Client.send()`
    - `rcon()`

## Submodules

## rcon.client module

Common base client.

class rcon.client.BaseClient(host: str, port: int, *, timeout: float | None = None, passwd: str | None = None)

  Bases: `object`

  A common RCON client.

  close() → None

    Close the socket connection.

  connect(login: bool = False) → None

    Connect the socket and attempt a login if wanted and a password is set.

  login(passwd: str) → bool

    Perform a login.

  run(command: str, *args: str) → str

    Run a command.

  property timeout: float

    Return the socket timeout.

## rcon.config module

RCON server configuration.

class rcon.config.Config(host: str, port: int, passwd: str | None = None)

  Bases: `NamedTuple`

  Represents server configuration.

  classmethod from_config_section(section: SectionProxy) → Config

    Create a credentials tuple from the respective config section.

  classmethod from_string(string: str) → Config

    Read the credentials from the given string.

  host: str

    Alias for field number 0

  passwd: str | None

    Alias for field number 2

  port: int

    Alias for field number 1

rcon.config.from_args(args: Namespace) → Config

  Get the credentials for a server from the respective arguments.

## rcon.console module

An interactive console.

rcon.console.rconcmd(client_cls: Type[BaseClient], host: str, port: int, passwd: str, *, timeout: float | None = None, prompt: str = 'RCON {host}:{port}> ')

  Initialize the console.

## rcon.errorhandler module

Common errors handler.

class rcon.errorhandler.ErrorHandler(logger: Logger)

  Bases: `object`

  Handles common errors and exits.

  exit_code
  logger

## rcon.exceptions module

Common exceptions.

exception rcon.exceptions.ConfigReadError

  Bases: `Exception`

  Indicates an error while reading the configuration.

exception rcon.exceptions.EmptyResponse

  Bases: `Exception`

  Indicates an empty response from the server.

exception rcon.exceptions.SessionTimeout

  Bases: `Exception`

  Indicates that the session timed out.

exception rcon.exceptions.UserAbort

  Bases: `Exception`

  Indicates that a required action has been aborted by the user.

exception rcon.exceptions.WrongPassword

  Bases: `Exception`

  Indicates a wrong password.

## rcon.gui module

GTK based GUI.

rcon.gui.main() → None

  Start the GUI.

## rcon.rconclt module

RCON client CLI.

rcon.rconclt.main() → int

  Run the main script with exceptions handled.

## rcon.rconshell module

An interactive RCON shell.

rcon.rconshell.get_args() → Namespace

  Parse and returns the CLI arguments.

rcon.rconshell.main() → int

  Run the main script with exceptions handled.

## rcon.readline module

Wrapper for readline support.

class rcon.readline.CommandHistory(logger: Logger, file: Path = PosixPath('/sbuild-nonexistent/.rconshell_history'))

  Bases: `object`

  Context manager for the command line history.

## Module contents

RCON client library.

class rcon.Client(*args, **kwargs)

  Bases: `Client`

  Wrapper for the rcon.source.Client for backwards compatibility.

exception rcon.EmptyResponse

  Bases: `Exception`

  Indicates an empty response from the server.

exception rcon.SessionTimeout

  Bases: `Exception`

  Indicates that the session timed out.

exception rcon.WrongPassword

  Bases: `Exception`

  Indicates a wrong password.

rcon.rcon(*args, **kwargs) → Coroutine[Any, Any, str]

  Wrapper for rcon.source.rcon() for backwards compatibility.