gameserver

package
v0.0.0-...-6b267e2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gameserver provides monitoring functionality for game servers

Index

Constants

This section is empty.

Variables

View Source
var ErrMonitorRunning = errors.New("monitor is already running")
View Source
var ErrNotFound = errors.New("game server not found")

Functions

This section is empty.

Types

type Create

type Create struct {
	Code             string
	Host             string
	Port             int
	QueryHost        string
	QueryPort        int
	Kind             Kind
	Password         string
	DisplaysIP       bool
	DisplaysPort     bool
	Ignore           bool
	OverrideDefaults bool
	Application      string
	Version          string
	MaxPlayers       int
	Title            string
	Description      string
}

func (*Create) Normalize

func (r *Create) Normalize()

func (Create) Validate

func (r Create) Validate() error

type Defaults

type Defaults struct {
	Application string
	Version     string
	MaxPlayers  int
	Title       string
	Description string
}

type GameServer

type GameServer struct {
	Code             string
	Host             string
	Port             int
	QueryHost        string
	QueryPort        int
	Kind             Kind
	Password         string
	DisplaysIP       bool
	DisplaysPort     bool
	Ignore           bool
	OverrideDefaults bool
	Defaults         Defaults
	State            State
	Metadata         Metadata
}

func (GameServer) GetDisplayAddress

func (gs GameServer) GetDisplayAddress() string

func (GameServer) GetQueryAddress

func (gs GameServer) GetQueryAddress() string

func (GameServer) GetQueryHost

func (gs GameServer) GetQueryHost() string

func (GameServer) GetQueryPort

func (gs GameServer) GetQueryPort() int

func (*GameServer) UpdateState

func (gs *GameServer) UpdateState(next State) bool

type Kind

type Kind string
const (
	KindSteamA2S      Kind = "steam_a2s"
	KindMinecraftJava Kind = "minecraft_java"
)

type Metadata

type Metadata struct {
	LastChange  time.Time
	LastAttempt time.Time
}

type MinecraftJavaServer

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

func (*MinecraftJavaServer) Latest

func (s *MinecraftJavaServer) Latest() GameServer

func (*MinecraftJavaServer) Refresh

func (s *MinecraftJavaServer) Refresh(ctx context.Context) (GameServer, bool)

type Monitor

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

func NewMonitor

func NewMonitor(targets []Target, poller poll.Poller) *Monitor

func (*Monitor) Run

func (m *Monitor) Run(ctx context.Context) error

func (*Monitor) Subscribe

func (m *Monitor) Subscribe(ctx context.Context) <-chan GameServer

type State

type State struct {
	IP          string
	Application string
	Version     string
	MaxPlayers  int
	PlayerCount int
	Title       string
	Description string
	Status      Status
	Since       time.Time
}

type Status

type Status string
const (
	StatusUnknown Status = "unknown"
	StatusOnline  Status = "online"
	StatusOffline Status = "offline"
)

type SteamA2SServer

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

func (*SteamA2SServer) Latest

func (s *SteamA2SServer) Latest() GameServer

func (*SteamA2SServer) Refresh

func (s *SteamA2SServer) Refresh(ctx context.Context) (GameServer, bool)

type Store

type Store interface {
	List(ctx context.Context) ([]GameServer, error)
	Get(ctx context.Context, code string) (GameServer, error)
	Create(ctx context.Context, server Create) error
	Update(ctx context.Context, code string, patch Update) error
	Delete(ctx context.Context, code string) error
}

type Target

type Target interface {
	Latest() GameServer
	Refresh(ctx context.Context) (server GameServer, changed bool)
}

func TargetsFromServers

func TargetsFromServers(servers []GameServer) []Target

type Update

type Update struct {
	Host             *string
	Port             *int
	QueryHost        *string
	QueryPort        *int
	Kind             *Kind
	Password         *string
	DisplaysIP       *bool
	DisplaysPort     *bool
	Ignore           *bool
	OverrideDefaults *bool
	Application      *string
	Version          *string
	MaxPlayers       *int
	Title            *string
	Description      *string
}

func (*Update) Normalize

func (r *Update) Normalize()

func (Update) Validate

func (r Update) Validate() error

Jump to

Keyboard shortcuts

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