gamestatus

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package gamestatus probes a game server's own published port: the Minecraft Java server list ping, with a plain TCP connect for other games.

Index

Constants

View Source
const (
	KindMinecraft = "minecraft"
	KindTCP       = "tcp"
)

Kinds of answer a probe can give.

View Source
const (

	// MaxPacketBytes bounds one status packet; a favicon response is ~10 KB.
	MaxPacketBytes = 256 << 10
)

Protocol limits of the Java list ping, not tunables.

Variables

View Source
var (
	// ErrNotLoopback is returned for any target but this host's loopback.
	ErrNotLoopback = errors.New("gamestatus: target must be a loopback address")
	// ErrBadPacket is returned when the server reply is not a valid status packet.
	ErrBadPacket = errors.New("gamestatus: malformed status response")
)

Functions

This section is empty.

Types

type Dialer

type Dialer func(ctx context.Context, network, addr string) (net.Conn, error)

Dialer opens the connection; tests replace it.

type Status

type Status struct {
	Kind        string
	Online      bool
	Version     string
	Players     int
	MaxPlayers  int
	LatencyMS   int64
	Description string
}

Status is one probe result.

func Probe

func Probe(ctx context.Context, dial Dialer, addr string, timeout time.Duration) (Status, error)

Probe checks one loopback host:port. A Minecraft answer wins; a port that accepts a connection but does not speak the protocol is reported as TCP-open. Only loopback targets are allowed so a probe can never reach another host.

func ReadMinecraftStatus

func ReadMinecraftStatus(rw io.ReadWriter, host string, port uint16) (Status, error)

ReadMinecraftStatus runs the handshake, status request and ping over rw.

Jump to

Keyboard shortcuts

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