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

rcon

package
v0.0.0-...-8241180 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidBattlEyePacket marks a datagram that is not a well-formed BattlEye packet.
	// It is never returned to the caller: the read loops skip such datagrams, because a UDP
	// socket can receive unrelated traffic.
	ErrInvalidBattlEyePacket = errors.New("invalid battleye packet")

	// ErrBattlEyeIncompleteResponse is returned when the parts of a multi-packet reply do not
	// all arrive within the timeout.
	ErrBattlEyeIncompleteResponse = errors.New("battleye response is incomplete")
)
View Source
var (
	// ErrRconDisabled is returned when the server answers that no RCON password is configured,
	// so remote console is switched off rather than merely rejecting our credentials.
	ErrRconDisabled = errors.New("rcon is not enabled on the server")

	// ErrPasswordContainsWhitespace rejects a password the id Tech protocols cannot express.
	// The server locates the command by walking to the first space after the password, so a
	// password containing whitespace would push part of itself into the command position and
	// execute something the caller never asked for.
	ErrPasswordContainsWhitespace = errors.New("rcon password must not contain whitespace")
)
View Source
var (
	// ErrSAMPRequiresIPv4 is returned when the server address does not resolve to IPv4. The
	// protocol embeds the four address octets in every packet, so IPv6 cannot be expressed.
	ErrSAMPRequiresIPv4 = errors.New("samp rcon requires an IPv4 server address")

	// ErrSAMPPingMismatch is returned when the server's ping reply does not echo our payload.
	ErrSAMPPingMismatch = errors.New("samp server did not echo the ping payload")

	// ErrSAMPFieldTooLong is returned when a password or command exceeds the 16-bit length
	// prefix the protocol uses.
	ErrSAMPFieldTooLong = errors.New("samp rcon field exceeds the maximum length")
)
View Source
var (
	ErrAuthenticationFailed = errors.New("authentication failed")
	ErrInvalidPacket        = errors.New("invalid packet")
)
View Source
var (
	ErrInvalidChallengeResponse = errors.New("invalid challenge response")
)
View Source
var (
	ErrUnsupportedProtocol = errors.New("unsupported protocol")
)

Functions

func IsPlayerManagementSupported

func IsPlayerManagementSupported(gameCode string) bool

func IsProtocolSupported

func IsProtocolSupported(protocol Protocol) bool

Types

type BattlEye

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

BattlEye implements the BattlEye RCon protocol used by Arma 2, Arma 3, DayZ, SCUM and Arma Reforger. Unlike the id Tech protocols it is a real session: the client logs in, then numbers its commands, and the server can push unsolicited messages at any time.

The protocol also requires an empty command packet at least every 45 seconds to keep a login alive. No keepalive is implemented here on purpose — the panel opens a connection, runs one command and closes it within a couple of seconds per request. Anyone reusing a client across requests (for example by wiring pool.go) must add one, and must also stop relying on drainStaleDatagrams, which discards unacknowledged server messages.

func NewBattlEye

func NewBattlEye(config Config) (*BattlEye, error)

func (*BattlEye) Close

func (b *BattlEye) Close() error

func (*BattlEye) Execute

func (b *BattlEye) Execute(_ context.Context, command string) (string, error)

func (*BattlEye) Open

func (b *BattlEye) Open(ctx context.Context) error

type Client

type Client interface {
	Open(ctx context.Context) error
	Close() error
	Execute(ctx context.Context, command string) (string, error)
}

func NewClient

func NewClient(config Config) (Client, error)

type Config

type Config struct {
	Address  string
	Password string
	Protocol Protocol
	Timeout  time.Duration
}

type GoldSource

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

func NewGoldSource

func NewGoldSource(config Config) (*GoldSource, error)

func (*GoldSource) Close

func (g *GoldSource) Close() error

func (*GoldSource) Execute

func (g *GoldSource) Execute(_ context.Context, command string) (string, error)

func (*GoldSource) Open

func (g *GoldSource) Open(ctx context.Context) error

type Player

type Player struct {
	ID    string
	Name  string
	Ping  string
	Score string
	Addr  string

	// Additional fields
	UniqID string
}

type Pool

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

func NewPool

func NewPool(config Config) (*Pool, error)

func (*Pool) Acquire

func (p *Pool) Acquire(ctx context.Context) (Client, error)

func (*Pool) Close

func (p *Pool) Close()

func (*Pool) Stat

func (p *Pool) Stat() *puddle.Stat

func (*Pool) TryAcquire

func (p *Pool) TryAcquire(ctx context.Context) (Client, error)

type PooledClient

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

func (*PooledClient) Close

func (c *PooledClient) Close() (err error)

func (*PooledClient) Execute

func (c *PooledClient) Execute(ctx context.Context, command string) (string, error)

func (*PooledClient) Open

func (c *PooledClient) Open(_ context.Context) error

type Protocol

type Protocol string
const (
	ProtocolSource   Protocol = "source"
	ProtocolGoldSrc  Protocol = "goldsource"
	ProtocolQuake2   Protocol = "quake2"
	ProtocolQuake3   Protocol = "quake3"
	ProtocolSAMP     Protocol = "samp"
	ProtocolBattlEye Protocol = "battleye"
)

type Quake

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

Quake implements RCON for the id Tech 2 and id Tech 3 engine families: Quake 2, Quake 3 Arena, Quake Live, Return to Castle Wolfenstein, Wolfenstein: Enemy Territory, the Call of Duty series and the ioquake3 derivatives.

The wire format is a single connectionless UDP datagram in each direction; there is no handshake and no session, so Open only dials. Large replies arrive as several datagrams because the server flushes its redirect buffer in ~1 KiB chunks.

func NewQuake2

func NewQuake2(config Config) (*Quake, error)

NewQuake2 creates a client for id Tech 2 servers.

func NewQuake3

func NewQuake3(config Config) (*Quake, error)

NewQuake3 creates a client for id Tech 3 servers.

func (*Quake) Close

func (q *Quake) Close() error

func (*Quake) Execute

func (q *Quake) Execute(_ context.Context, command string) (string, error)

func (*Quake) Open

func (q *Quake) Open(ctx context.Context) error

Open dials the server. The protocol is stateless and carries the password on every command, so there is nothing to authenticate here — a wrong password surfaces from Execute. Probing with a throw-away command is deliberately avoided: vanilla Quake 3 throttles RCON to one packet per 500 ms server-wide and would silently drop the real command that follows.

type SAMP

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

SAMP implements RCON for SA-MP and open.mp servers. The remote console shares the UDP query port and reuses the query framing: every packet starts with the eleven-byte header, and the server answers with one datagram per console output line.

Most SA-MP console commands print nothing at all, and `players` prints nothing on an empty server, so silence after a command is a normal empty response rather than an error. Open therefore performs a ping handshake, which is what establishes that the server is reachable.

func NewSAMP

func NewSAMP(config Config) (*SAMP, error)

func (*SAMP) Close

func (s *SAMP) Close() error

func (*SAMP) Execute

func (s *SAMP) Execute(_ context.Context, command string) (string, error)

func (*SAMP) Open

func (s *SAMP) Open(ctx context.Context) error

type Source

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

func NewSource

func NewSource(config Config) (*Source, error)

func (*Source) Close

func (s *Source) Close() error

func (*Source) Execute

func (s *Source) Execute(_ context.Context, command string) (string, error)

func (*Source) Open

func (s *Source) Open(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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