Documentation
¶
Index ¶
- func SetPortUnbinderRegistry(registry func(PortUnbinderFunc))
- type AlwaysMOTD
- func (a *AlwaysMOTD) Description() string
- func (a *AlwaysMOTD) Disable(ctx context.Context) error
- func (a *AlwaysMOTD) Enable(ctx context.Context) error
- func (a *AlwaysMOTD) Enabled() bool
- func (a *AlwaysMOTD) GetConfig() interface{}
- func (a *AlwaysMOTD) Name() string
- func (a *AlwaysMOTD) SetConfig(config interface{}) error
- func (a *AlwaysMOTD) UnbindPort(port int)
- func (a *AlwaysMOTD) UnbindPortForServer(port int)
- func (a *AlwaysMOTD) ValidateConfig(config interface{}) error
- type BedrockConfig
- type BedrockMotdServer
- func (s *BedrockMotdServer) BindToPort(serverPort int, state string) error
- func (s *BedrockMotdServer) Close() error
- func (s *BedrockMotdServer) SetServerPortMapping(bedrockMotdPort int, serverPort int)
- func (s *BedrockMotdServer) Start() error
- func (s *BedrockMotdServer) UnbindFromPort(serverPort int)
- type Config
- type DescriptionInfo
- type JavaConfig
- type LoggingConfig
- type MonitoringConfig
- type MotdConfig
- type MotdServer
- type PlayersInfo
- type PortRangeConfig
- type PortUnbinderFunc
- type ServerStatus
- type StateConfig
- type StatusResponse
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetPortUnbinderRegistry ¶
func SetPortUnbinderRegistry(registry func(PortUnbinderFunc))
SetPortUnbinderRegistry allows the router package to register the docker package's unbinder registration function. This breaks the import cycle.
Types ¶
type AlwaysMOTD ¶
type AlwaysMOTD struct {
// contains filtered or unexported fields
}
AlwaysMOTD is the main module implementation
func (*AlwaysMOTD) Description ¶
func (a *AlwaysMOTD) Description() string
Description returns the module description
func (*AlwaysMOTD) Disable ¶
func (a *AlwaysMOTD) Disable(ctx context.Context) error
Disable stops the module
func (*AlwaysMOTD) Enable ¶
func (a *AlwaysMOTD) Enable(ctx context.Context) error
Enable starts the module
func (*AlwaysMOTD) Enabled ¶
func (a *AlwaysMOTD) Enabled() bool
Enabled returns whether the module is enabled
func (*AlwaysMOTD) GetConfig ¶
func (a *AlwaysMOTD) GetConfig() interface{}
GetConfig returns the current configuration
func (*AlwaysMOTD) SetConfig ¶
func (a *AlwaysMOTD) SetConfig(config interface{}) error
SetConfig updates the module configuration If the module is enabled, it will reload to apply the new configuration
func (*AlwaysMOTD) UnbindPort ¶
func (a *AlwaysMOTD) UnbindPort(port int)
UnbindPort unbinds all MOTD bindings (both TCP redirects and UDP direct binds) for a given server port This implements the docker.PortUnbinder interface
func (*AlwaysMOTD) UnbindPortForServer ¶
func (a *AlwaysMOTD) UnbindPortForServer(port int)
UnbindPortForServer is an alias for UnbindPort for backwards compatibility This should be called before starting a container to prevent port binding conflicts
func (*AlwaysMOTD) ValidateConfig ¶
func (a *AlwaysMOTD) ValidateConfig(config interface{}) error
ValidateConfig validates the configuration
type BedrockConfig ¶
type BedrockConfig struct {
// Disconnect message formatting
DisconnectMessageFormat string `json:"disconnectMessageFormat" yaml:"disconnectMessageFormat"` // Format: "bold", "large", "normal"
DisconnectMessagePrefix string `json:"disconnectMessagePrefix" yaml:"disconnectMessagePrefix"` // Prefix to add before message
DisconnectMessageSuffix string `json:"disconnectMessageSuffix" yaml:"disconnectMessageSuffix"` // Suffix to add after message
// Connection handling
ConnectionWaitTime int `json:"connectionWaitTime" yaml:"connectionWaitTime"` // Milliseconds to wait before sending disconnect
DisconnectWaitTime int `json:"disconnectWaitTime" yaml:"disconnectWaitTime"` // Milliseconds to wait after sending disconnect before closing
// Protocol version (0 = auto-detect from client)
ProtocolVersion int `json:"protocolVersion" yaml:"protocolVersion"`
// Minecraft version string for Bedrock
MinecraftVersion string `json:"minecraftVersion" yaml:"minecraftVersion"`
}
BedrockConfig contains Bedrock Edition specific settings
type BedrockMotdServer ¶
type BedrockMotdServer struct {
// contains filtered or unexported fields
}
BedrockMotdServer handles Bedrock Edition (Pocket Edition) server list queries Uses gophertunnel library for RakNet protocol handling
func NewBedrockMotdServer ¶
func NewBedrockMotdServer(port int, config *StateConfig, bedrockConfig *BedrockConfig) *BedrockMotdServer
NewBedrockMotdServer creates a new Bedrock MOTD server instance
func (*BedrockMotdServer) BindToPort ¶
func (s *BedrockMotdServer) BindToPort(serverPort int, state string) error
BindToPort binds the Bedrock server to a specific server port (for when server is offline) This allows the server to respond directly from the server port without redirects
func (*BedrockMotdServer) Close ¶
func (s *BedrockMotdServer) Close() error
Close stops the Bedrock MOTD server
func (*BedrockMotdServer) SetServerPortMapping ¶
func (s *BedrockMotdServer) SetServerPortMapping(bedrockMotdPort int, serverPort int)
SetServerPortMapping sets the mapping from Bedrock MOTD port to server port This is needed when using redirects to know which server port a packet is for
func (*BedrockMotdServer) Start ¶
func (s *BedrockMotdServer) Start() error
Start starts the Bedrock MOTD server using gophertunnel
func (*BedrockMotdServer) UnbindFromPort ¶
func (s *BedrockMotdServer) UnbindFromPort(serverPort int)
UnbindFromPort unbinds from a server port
type Config ¶
type Config struct {
PortRange PortRangeConfig `json:"portRange" yaml:"portRange"`
Motd MotdConfig `json:"motd" yaml:"motd"`
Monitoring MonitoringConfig `json:"monitoring" yaml:"monitoring"`
Logging LoggingConfig `json:"logging" yaml:"logging"`
}
Config represents the configuration for the AlwaysMOTD module
type DescriptionInfo ¶
type DescriptionInfo struct {
Text string `json:"text,omitempty"`
Extra []map[string]interface{} `json:"extra,omitempty"`
// Support for full JSON text component structure
Color string `json:"color,omitempty"`
Bold bool `json:"bold,omitempty"`
Italic bool `json:"italic,omitempty"`
Underlined bool `json:"underlined,omitempty"`
Strikethrough bool `json:"strikethrough,omitempty"`
Obfuscated bool `json:"obfuscated,omitempty"`
}
DescriptionInfo contains the server description/MOTD Can be a simple string or a JSON text component with formatting
type JavaConfig ¶
type JavaConfig struct {
// Disconnect message formatting
DisconnectMessageFormat string `json:"disconnectMessageFormat" yaml:"disconnectMessageFormat"` // Format: "bold", "large", "normal"
DisconnectMessagePrefix string `json:"disconnectMessagePrefix" yaml:"disconnectMessagePrefix"` // Prefix to add before message
DisconnectMessageSuffix string `json:"disconnectMessageSuffix" yaml:"disconnectMessageSuffix"` // Suffix to add after message
// Connection handling
StatusResponseDelay int `json:"statusResponseDelay" yaml:"statusResponseDelay"` // Milliseconds to delay status response (0 = immediate)
DisconnectDelay int `json:"disconnectDelay" yaml:"disconnectDelay"` // Milliseconds to delay disconnect after sending
// Protocol settings
ProtocolVersion int `json:"protocolVersion" yaml:"protocolVersion"` // Protocol version (0 = use from state config)
// Minecraft version string for Java Edition
MinecraftVersion string `json:"minecraftVersion" yaml:"minecraftVersion"`
// Favicon settings
FaviconEnabled bool `json:"faviconEnabled" yaml:"faviconEnabled"` // Enable favicon in server list
FaviconURL string `json:"faviconURL" yaml:"faviconURL"` // Favicon URL or file path (PNG, 64x64 recommended)
// Response behavior
ShowAsUnhealthy bool `json:"showAsUnhealthy" yaml:"showAsUnhealthy"` // Make server appear unhealthy in server list (don't respond to ping)
}
JavaConfig contains Java Edition specific settings
type LoggingConfig ¶
type LoggingConfig struct {
Level string `json:"level" yaml:"level"` // error, warn, info, debug
}
LoggingConfig contains logging settings
type MonitoringConfig ¶
type MonitoringConfig struct {
CheckInterval int `json:"checkInterval" yaml:"checkInterval"` // milliseconds
}
MonitoringConfig contains monitoring settings
type MotdConfig ¶
type MotdConfig struct {
// Base port for MOTD servers. Each state gets its own port:
// - Java Edition: basePort + stateOffset (e.g., 25560 + 0 = 25560 for offline)
// - Bedrock Edition: basePort + stateOffset + 100 (e.g., 25560 + 0 + 100 = 25660 for offline)
// This allows multiple states to run simultaneously without port conflicts
Port int `json:"port" yaml:"port"`
States map[string]*StateConfig `json:"states" yaml:"states"`
// Edition support
JavaEnabled bool `json:"javaEnabled" yaml:"javaEnabled" default:"true"` // Enable Java Edition MOTD
BedrockEnabled bool `json:"bedrockEnabled" yaml:"bedrockEnabled" default:"true"` // Enable Bedrock Edition MOTD
// Edition-specific settings
Java JavaConfig `json:"java" yaml:"java"`
Bedrock BedrockConfig `json:"bedrock" yaml:"bedrock"`
}
MotdConfig contains MOTD server configuration
type MotdServer ¶
type MotdServer struct {
// contains filtered or unexported fields
}
MotdServer handles Minecraft protocol connections and serves custom MOTD
func NewMotdServer ¶
func NewMotdServer(port int, config *StateConfig, javaConfig *JavaConfig, favicon string) *MotdServer
NewMotdServer creates a new MOTD server instance
type PlayersInfo ¶
type PlayersInfo struct {
Max int `json:"max"`
Online int `json:"online"`
Sample []struct{} `json:"sample"`
}
PlayersInfo contains player count information
type PortRangeConfig ¶
type PortRangeConfig struct {
Start int `json:"start" yaml:"start"`
End int `json:"end" yaml:"end"`
}
PortRangeConfig defines the port range to monitor
type PortUnbinderFunc ¶
type PortUnbinderFunc func(port int)
PortUnbinderFunc is a function type for unbinding ports This allows registration without import cycles
type ServerStatus ¶
ServerStatus tracks the status of a server port
type StateConfig ¶
type StateConfig struct {
Version string `json:"version" yaml:"version"`
Protocol int `json:"protocol" yaml:"protocol"`
MaxPlayers int `json:"maxPlayers" yaml:"maxPlayers"`
OnlinePlayers int `json:"onlinePlayers" yaml:"onlinePlayers"`
Description interface{} `json:"description" yaml:"description"` // Can be string or JSON text component
// Edition-specific overrides
JavaDescription interface{} `json:"javaDescription" yaml:"javaDescription"` // Optional Java-specific message
BedrockDescription interface{} `json:"bedrockDescription" yaml:"bedrockDescription"` // Optional Bedrock-specific message
}
StateConfig defines the MOTD configuration for a specific server state
type StatusResponse ¶
type StatusResponse struct {
Version VersionInfo `json:"version"`
Players PlayersInfo `json:"players"`
Description DescriptionInfo `json:"description"`
DescriptionRaw interface{} `json:"-"` // Raw JSON description for direct use
Favicon string `json:"favicon,omitempty"`
}
StatusResponse represents a Minecraft server status response
type VersionInfo ¶
VersionInfo contains version information