theislercon

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 22, 2025 License: AGPL-3.0 Imports: 7 Imported by: 0

README

The Isle RCON Client

This is a RCON client library for The Isle Evrima dedicated servers.

The Client type

Client is the main interface of this library. It contains methods for all known RCON commands. To create a new client, use Connect(addr). Make sure to call Client.Close() when you're done with it.

These are the methods that are currently supported:

  • AddWhitelistID
  • Announce
  • Auth
  • DisableAIClasses
  • GetPlayerData
  • GetPlayerList
  • GetServerDetails
  • KickPlayer
  • RemoveWhitelistID
  • Save
  • SendDirectMessage
  • SetAIDensity
  • ToggleAI
  • ToggleGlobalChat
  • ToggleHumans
  • ToggleWhitelist
  • UpdatePlayables
  • WipeCorpses

Example: Get a list of connected players

import (
    "fmt"
    rcon "github.com/butt4cak3/theislercon"
)

func main() {
    client, err := rcon.Connect("127.0.0.1:8888")
    if err != nil {
        fmt.Println("Could not connect")
        return
    }
    defer client.Close()

    err = client.Auth("YourSecurePasswordHere")
    if err != nil {
        fmt.Println("Could not authenticate")
        return
    }

    players, err := client.GetPlayerList()
    if err != nil {
        fmt.Println("Failed to get player list")
        return
    }

    for _, player := range players {
        fmt.Printf("%s\n", player.Name)
    }
}

The RCON protocol

What follows is a somewhat technical description of the underlying protocol. It may contain errors or misconceptions, because (apart from the command table below) it was mostly reverse engineered.

The communication between client and server happens in a request-response-format. The client sends a request to the server and the server then responds to that request. The server never sends any data without first receiving a request and it only responds at most once to every request.

Authentication

The first message that must be sent to the server after the connection has been established is the authentication request. It consists of the byte 0x01 and the RCON password as defined in the server's Game.ini config file.

On successful authentication, the server will respond with the string "Password Accepted". Otherwise, it will respond with "Incorrect Password".

Sending commands

A request frame consists of three parts: The ExecCommand byte, a command byte from the list below, and arguments. The command byte can be one of the values in the table below. The arguments are a list of zero or more strings, separated by commas. The command does not need to be terminated by anything, although some client libraries append a NULL byte (0x00).

Server responses

A response usually consists of three parts:

  1. A timestamp, enclosed in brackets ([ and ])
  2. The name of the type of response as a string
  3. Data, depending on the type of response

For some reason, all of these components are optional. Most, but not all of the times, there is a timestamp. Sometimes the type of response is there, sometimes not.

If present, the closing bracket of the timestamp is followed by a space. However, there is no space between the response type name and the data.

[!NOTE] The authentication response is special and does not contain a timestamp nor the response type name.

Commands
Special bytes
Command Byte Arguments
Auth 0x01 RCON password
ExecCommand 0x02 Command byte, arguments...
ResponseValue 0x03 Unknown
Commands
Command Byte Response name Arguments
Announce 0x10 Announce Message
DirectMessage 0x11 DirectMessage PlayerID, Message
GetServerDetails 0x12 ServerDetails
WipeCorpses 0x13 WipeCorpses
UpdatePlayables 0x15 UpdatePlayables
BanPlayer 0x20 BanPlayer Unknown
KickPlayer 0x30 KickPlayer PlayerID
GetPlayerList 0x40 PlayerList
Save 0x50 Save
GetPlayerData 0x77 PlayerData
ToggleWhitelist 0x81 ToggleWhitelist
AddWhitelistID 0x82 AddWhitelistID PlayerID
RemoveWhitelistID 0x83 RemoveWhitelistID PlayerID
ToggleGlobalChat 0x84 ToggleGlobalChat
ToggleHumans 0x86 ToggleHumans
ToggleAI 0x90 ToggleAI
DisableAIClasses 0x91 DisableAIClasses AIClasses
AIDensity 0x92 AIDensity Density

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIncorrectPassword = errors.New("incorrect password")
View Source
var ErrMalformedResponse = errors.New("malformed response")

Functions

func IsAIClass

func IsAIClass(s string) bool

func IsClass

func IsClass(s string) bool

Types

type AIClass

type AIClass string
const (
	Boar          AIClass = "Boar"
	Compsognathus AIClass = "Compsognathus"
	Deer          AIClass = "Deer"
	Goat          AIClass = "Goat"
	Pterodactylus AIClass = "Pterodactylus"
	Seaturtle     AIClass = "Seaturtle"
)

type Client

type Client struct {
	// contains filtered or unexported fields
}

The Client type contains methods for all RCON commands.

func Connect

func Connect(addr string) (*Client, error)

Connect tries to connect to the specified address.

func (*Client) AddWhitelistID

func (client *Client) AddWhitelistID(playerID ...string) error

AddWhitelistID adds one or more PlayerIDs to the whitelist.

func (*Client) Announce

func (client *Client) Announce(message string) error

Announce sends a message to all currently connected players.

The message will be displayed in a large text box at the top of the screen.

func (*Client) Auth

func (client *Client) Auth(password string) error

Auth tries to authenticate with the gameserver.

If the reason for failure is an incorrect password, the function will return ErrIncorrectPassword.

func (*Client) Close

func (client *Client) Close() error

Close closes the connection to the server.

func (*Client) DisableAIClasses

func (client *Client) DisableAIClasses(classes []AIClass) error

DisableAIClasses defines the list of AI classes that cannot spawn.

func (*Client) ExecCommand

func (client *Client) ExecCommand(command byte, params ...string) (string, error)

ExecCommand formats a command and sends it to the server.

The client should have a corresponding method for every supported command. However, there may be undocumented features in the RCON protocol or this library may become out-of-date. In those cases, you can use ExecCommand directly to send commands that the client does not support (yet).

While command can be any byte, you should normally use one of the MessageType constants.

This function returns the server's response as a string.

func (*Client) GetPlayerData

func (client *Client) GetPlayerData() ([]Player, error)

GetPlayerData returns a list of all players that have spawned in.

In contrast to Client.GetPlayerList, this function returns complete Player structs and not just IDs and names. However, it excludes players that are still in the class selection screen.

func (*Client) GetPlayerList

func (client *Client) GetPlayerList() ([]Player, error)

GetPlayerList returns a list of all connected players.

The list contains both players that are playing and players that are connected, but not playing (i.e. players that are in the class selection screen). However, the list only contains IDs and names.

func (*Client) GetServerDetails

func (client *Client) GetServerDetails() (*ServerDetails, error)

GetServerDetails returns some information about the server.

func (*Client) KickPlayer

func (client *Client) KickPlayer(playerID, reason string) error

KickPlayer kicks the player from the server.

func (*Client) RemoveWhitelistID

func (client *Client) RemoveWhitelistID(playerID ...string) error

RemoveWhitelistID removes one or more PlayerIDs from the whitelist.

func (*Client) Save

func (client *Client) Save() error

Save saves the current state of the map.

func (*Client) SendDirectMessage

func (client *Client) SendDirectMessage(playerID, message string) error

SendDirectMessage sends an announcement message to one specific user.

The message will be shown in the same way as a regular announcement.

func (*Client) SetAIDensity

func (client *Client) SetAIDensity(density float32) error

SetAIDensity sets the AI density that can also be defined in Game.ini.

func (*Client) ToggleAI

func (client *Client) ToggleAI() (bool, error)

ToggleAI turns the spawning of AI on or off.

func (*Client) ToggleGlobalChat

func (client *Client) ToggleGlobalChat() (bool, error)

ToggleGlobalState turns on or off the global chat feature on the server.

If you need to know whether global chat is already enabled, use Client.GetServerDetails.

func (*Client) ToggleHumans

func (client *Client) ToggleHumans() (bool, error)

ToggleHumans turns on or off the humans feature in the game.

func (*Client) ToggleWhitelist

func (client *Client) ToggleWhitelist() (bool, error)

ToggleWhitelist turns the whielist on or off and returns true, if the new state is on.

func (*Client) UpdatePlayables

func (client *Client) UpdatePlayables(classes []DinoClass) error

UpdatePlayables defines the list of playable classes.

func (*Client) WipeCorpses

func (client *Client) WipeCorpses() error

WipeCorpses removes all dead entities from the map.

type DinoClass added in v1.1.0

type DinoClass string

Classes are the different types of dinosaurs that players can choose to play.

const (
	Beipiaosaurus      DinoClass = "Beipiaosaurus"
	Carnotaurus        DinoClass = "Carnotaurus"
	Ceratosaurus       DinoClass = "Ceratosaurus"
	Deinosuchus        DinoClass = "Deinosuchus"
	Diabloceratops     DinoClass = "Diabloceratops"
	Dilophosaurus      DinoClass = "Dilophosaurus"
	Dryosaurus         DinoClass = "Dryosaurus"
	Gallimimus         DinoClass = "Gallimimus"
	Herrerasaurus      DinoClass = "Herrerasaurus"
	Hypsilophodon      DinoClass = "Hypsilophodon"
	Maiasaura          DinoClass = "Maiasaura"
	Omniraptor         DinoClass = "Omniraptor"
	Pachycephalosaurus DinoClass = "Pachycephalosaurus"
	Pteranodon         DinoClass = "Pteranodon"
	Stegosaurus        DinoClass = "Stegosaurus"
	Tenontosaurus      DinoClass = "Tenontosaurus"
	Troodon            DinoClass = "Troodon"
)

func (DinoClass) Name added in v1.1.0

func (c DinoClass) Name() string

Name returns a human-readable name for this class.

In case a class is not yet supported by this library, the name as reported by the server will be used.

type Location

type Location struct {
	X float64 // Latitude
	Y float64 // Longitude
	Z float64 // Altitude
}

type MessageType

type MessageType = byte
const (
	Auth              MessageType = 0x01
	ExecCommand       MessageType = 0x02
	ResponseValue     MessageType = 0x03
	Announce          MessageType = 0x10
	DirectMessage     MessageType = 0x11
	GetServerDetails  MessageType = 0x12
	WipeCorpses       MessageType = 0x13
	UpdatePlayables   MessageType = 0x15
	BanPlayer         MessageType = 0x20
	KickPlayer        MessageType = 0x30
	GetPlayerList     MessageType = 0x40
	Save              MessageType = 0x50
	GetPlayerData     MessageType = 0x77
	ToggleWhitelist   MessageType = 0x81
	AddWhitelistID    MessageType = 0x82
	RemoveWhitelistID MessageType = 0x83
	ToggleGlobalChat  MessageType = 0x84
	ToggleHumans      MessageType = 0x86
	ToggleAI          MessageType = 0x90
	DisableAIClasses  MessageType = 0x91
	SetAIDensity      MessageType = 0x92
)

type Player

type Player struct {
	ID        string // Steam or EOS ID
	Name      string
	Location  Location
	DinoClass DinoClass
	Growth    int8 // Growth as percentage. 75% means fully grown in the current game version.
	Health    int8 // Health as percentage
	Stamina   int8 // Stamina as percentage
	Hunger    int8 // Hunger as percentage
	Thirst    int8 // Thirst as percentage
}

type Response

type Response struct {
	Timestamp string
	Type      string
	Content   string
}

type ServerDetails

type ServerDetails struct {
	Name                           string
	Password                       string
	Map                            string
	MaxPlayers                     int
	CurrentPlayers                 int
	EnableMutations                bool
	EnableHumans                   bool
	HasPassword                    bool
	QueueEnabled                   bool
	Whitelist                      bool
	SpawnAI                        bool
	AllowRecordingGameplay         bool
	UseRegionSpawning              bool
	UseRegionSpawnCooldown         bool
	RegionSpawnCooldownTimeSeconds int
	DayLengthMinutes               int
	NightLengthMinutes             int
	EnableGlobalChat               bool
}

Directories

Path Synopsis
internal
parser
Package parser contains functions that help with parsing the RCON server responses.
Package parser contains functions that help with parsing the RCON server responses.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL