Help us shape the future of Go! Take the 2026 Go Developer Survey

rcon

package module
v0.0.0-...-61bdfe7 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2017 License: MIT Imports: 6 Imported by: 5

README

factorio-rcon

GoDoc License

This package is a fork of madcitygg/rcon with a few tweaks to work with Factorio. Namely, Factorio's rejection of sending SERVERDATA_RESPONSE_VALUE packets to check for multi-packet responses (details here).

Usage

A simple example:

package main

import (
    "fmt"
    "github.com/gtaylor/factorio-rcon"
)

func main() {
    r, err := rcon.Dial("10.10.10.10:27015")
    if err != nil {
        panic(err)
    }
    defer r.Close()

    err = r.Authenticate("password")
    if err != nil {
        panic(err)
    }

    response, err := r.Execute("status")
    if err != nil {
        panic(err)
    }

    fmt.Printf("Response: %+v\n", response)
}

License

Like the upstream madcitygg/rcon, this package is licensed under the MIT License.

Documentation

Index

Constants

View Source
const (
	Auth          int32 = 3
	AuthResponse  int32 = 2
	ExecCommand   int32 = 2
	ResponseValue int32 = 0
)

Variables

View Source
var (
	ErrInvalidWrite       = errors.New("rcon: failed to write to remote connection")
	ErrInvalidID          = errors.New("rcon: invalid response ID from remote connection")
	ErrInvalidPacketOrder = errors.New("rcon: packets from server received out of order")
	ErrAuthFailed         = errors.New("rcon: authentication failed")
)

Functions

This section is empty.

Types

type Packet

type Packet struct {
	Size int32
	ID   int32
	Type int32
	Body string
}

func NewPacket

func NewPacket(typ int32, body string) *Packet

func (*Packet) Payload

func (p *Packet) Payload() (payload []byte, err error)

type Player

type Player struct {
	Name   string
	Online bool
}

Player represents a registered player on the server.

type RCON

type RCON struct {
	// TODO: add some more useful stuff here?
	Address string
	// contains filtered or unexported fields
}

func Dial

func Dial(address string) (*RCON, error)

func (*RCON) Authenticate

func (r *RCON) Authenticate(password string) (err error)

func (*RCON) Close

func (r *RCON) Close() error

func (*RCON) CmdAdmins

func (r *RCON) CmdAdmins() (players []Player, err error)

CmdAdmins returns all registered admin players on the server.

func (*RCON) CmdPlayers

func (r *RCON) CmdPlayers() (players []Player, err error)

CmdPlayers returns all registered players on the server.

func (*RCON) Execute

func (r *RCON) Execute(command string) (response *Packet, err error)

func (*RCON) ReadPacket

func (r *RCON) ReadPacket() (response *Packet, err error)

func (*RCON) WritePacket

func (r *RCON) WritePacket(packet *Packet) (err error)

Jump to

Keyboard shortcuts

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