Documentation ¶
Overview ¶
Package rcon implements the communication protocol for communicating with RCON servers. Tested and working with Valve game servers.
Index ¶
Constants ¶
const ( PacketPaddingSize uint8 = 2 // Size of Packet's padding. PacketHeaderSize uint8 = 8 // Size of Packet's header. )
const ( Exec int32 = 2 Auth int32 = 3 AuthResponse int32 = 2 ResponseValue int32 = 0 )
Packet type constants. https://developer.valvesoftware.com/wiki/Source_RCON_Protocol#Packet_Type
const (
TerminationSequence = "\x00" // Null empty ASCII string suffix.
)
Variables ¶
var ( ErrInvalidWrite = errors.New("failed to write the payload correctly to remote connection") ErrInvalidRead = errors.New("failed to read the response correctly from remote connection") ErrInvalidChallenge = errors.New("server failed to mirror request challenge") ErrFailedAuthorization = errors.New("failed to authorize to the remote server") )
Rcon package errors.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Host string // The IP address of the remote server. Port int // The Port the remote server's listening on. Authorized bool // Has the client been authorized by the server? Connection net.Conn // The TCP connection to the server. }
func NewClient ¶
NewClient creates a new Client type, creating the connection to the server specified by the host and port arguments. If the connection fails, an error is returned.
func (*Client) Authorize ¶
Authorize calls Send with the appropriate command type and the provided password. The response packet is returned if authorization is successful or a potential error.
func (*Client) Execute ¶
Execute calls Send with the appropriate command type and the provided command. The response packet is returned if the command executed successfully or a potential error.
func (*Client) Send ¶
Sends accepts the commands type and its string to execute to the clients server, creating a packet with a random challenge id for the server to mirror, and compiling its payload bytes in the appropriate order. The response is decompiled from its bytes into a Packet type for return. An error is returned if send fails.