Documentation ¶
Overview ¶
rcon package implements the minecraft rcon protocol (based on the source rcon protocol). This package is strictly compliant with the following documentation : https://wiki.vg/RCON.
Index ¶
Constants ¶
Variables ¶
var ( ErrNotAuthenticated error = errors.New("authentication hasn't been realised or has failed. Call Authenticate method to authenticate") ErrCommandTooLong error = errors.New("command length must be 1446 or less") )
var (
ErrWrongPassword error = errors.New("wrong password")
)
Functions ¶
Types ¶
type RCONClient ¶
type RCONClient struct { // options SkipSRVLookup bool DialTimeout time.Duration ReadTimeout time.Duration // contains filtered or unexported fields }
RCONClient is the RCON client.
func NewClient ¶
func NewClient(hostname string, port int) *RCONClient
NewClient returns a well-formed *RCONClient.
func (*RCONClient) Authenticate ¶
func (client *RCONClient) Authenticate(password string) (bool, error)
Authenticate sends an authentication packet to the server. If connection is successful it returns true, if not it returns false. If the communication didn't go wrong, err will be nil. This means that (false, nil) is a perfectly fine return if the password was wrong but he communication went well.
func (*RCONClient) Command ¶
func (client *RCONClient) Command(command string) (string, error)
Command sends a command packet to the server. Command length cannot be over MaximumRequestPayloadLength. This is a limitation of the source RCON protocol.
func (*RCONClient) Connect ¶
func (client *RCONClient) Connect() error
Connect establishes a connection via TCP.
func (*RCONClient) Disconnect ¶
func (client *RCONClient) Disconnect() error
Disconnect closes the connection. This also means the authentication isn't valid anymore, even if a call to the Connect method is made. Connection is made not usable anymore no matter if the it closed properly or not.