Documentation
¶
Index ¶
- Constants
- func DetectModpackLoader(candidates ...string) (models.ModLoader, bool)
- func DownloadAllowsPrivate(indexerURL string) bool
- func DownloadDatapackArchiveFrom(ctx context.Context, indexerURL, rawURL, destPath string) error
- func DownloadDatapackArchiveWithClient(client *http.Client, ctx context.Context, rawURL, destPath string) error
- func FindMostRecentMinecraftVersion(versions []string) string
- func GamePackFormat(mcVersion string) (float64, bool)
- func GenerateVelocitySecret() (string, error)
- func GetAllConfigs(serverDataPath string, loader models.ModLoader) (map[string]any, error)
- func GetAllVersions() []string
- func GetDatapacksPath(serverDataPath, levelName string) string
- func GetJavaVersion(mcVersion string) (string, error)
- func GetLatestSnapshot() string
- func GetLatestVersion() string
- func GetModsPath(serverDataPath string, loader models.ModLoader) string
- func GetProtocolVersion(mcVersion string) int
- func GetTPSCommand(modLoader models.ModLoader) string
- func GetVersionDate(version string) (time.Time, error)
- func GetVersions() []string
- func IsClientOnly(jarPath string) (bool, error)
- func IsSnapshot(version string) bool
- func IsValidDatapackFile(filename string) bool
- func IsValidModFile(filename string, loader models.ModLoader) bool
- func IsValidVersion(version string) bool
- func LoadYAMLConfig(serverDataPath string, configFile ConfigFile) (map[string]any, error)
- func MatchModLoader(input string) (models.ModLoader, bool)
- func NormalizeDatapackArchive(path string) (bool, error)
- func PackFormatWarning(pack PackFormat, mcVersion string) string
- func ParsePlayerListFromOutput(output string) (int, []string)
- func ParseTPSFromOutput(output string) float64
- func SaveServerProperties(serverDataPath string, properties ServerProperties) error
- func SaveYAMLConfig(serverDataPath string, configFile ConfigFile, config map[string]any) error
- func SyncVelocitySecretToDataPath(dataPath string, secret string) (string, error)
- func ValidateDatapackArchive(path string) error
- func ValidateDatapackFilename(name string) error
- type ConfigFile
- type LatestVersions
- type ModLoaderInfo
- type ModSide
- type PackFormat
- type ProtocolVersionEntry
- type SLPClient
- type SLPResult
- type ServerProperties
- func (p ServerProperties) GetBool(key string, defaultValue bool) bool
- func (p ServerProperties) GetInt(key string, defaultValue int) int
- func (p ServerProperties) GetString(key string, defaultValue string) string
- func (p ServerProperties) SetBool(key string, value bool)
- func (p ServerProperties) SetInt(key string, value int)
- func (p ServerProperties) SetString(key, value string)
- type Version
- type VersionManifestV2
- type VersionMetadata
Constants ¶
const DefaultLevelName = "world"
DefaultLevelName is the world directory Minecraft uses when server.properties does not override level-name.
const MaxDatapackBytes = 256 << 20 // 256 MiB
MaxDatapackBytes caps a downloaded datapack archive. Datapacks are small world-data bundles; anything enormous is a mistake or an attack.
const (
SettingVelocitySecret = "velocity_forwarding_secret"
)
Variables ¶
This section is empty.
Functions ¶
func DetectModpackLoader ¶
Inspects candidate strings for modloader identification
func DownloadAllowsPrivate ¶ added in v1.0.39
DownloadAllowsPrivate reports whether downloads driven by an indexer at indexerURL may target private network addresses. A public indexer's responses must never point the panel at internal hosts (SSRF via tampered index data), while a self-hosted indexer on a private network is an operator's deliberate trust decision and keeps serving private downloads. Unresolvable indexer hosts fail closed to strict (public-only).
func DownloadDatapackArchiveFrom ¶ added in v1.0.39
DownloadDatapackArchiveFrom streams a datapack to destPath with an SSRF-guarded client whose private-network allowance is scoped to the indexer that supplied the URL. It does not trust Content-Length.
func DownloadDatapackArchiveWithClient ¶ added in v1.0.39
func DownloadDatapackArchiveWithClient(client *http.Client, ctx context.Context, rawURL, destPath string) error
DownloadDatapackArchiveWithClient is DownloadDatapackArchive with an explicit client so tests can exercise the streaming and size logic without defeating the SSRF guard.
func GamePackFormat ¶ added in v1.0.39
GamePackFormat reports the data pack format supported by a Minecraft release (e.g. "1.21.1" -> 48). Unknown versions (snapshots, future releases) report false.
func GenerateVelocitySecret ¶
GenerateVelocitySecret generates a cryptographically secure 32-byte (256-bit) secret
func GetAllConfigs ¶
GetAllConfigs returns all configuration files for a server
func GetDatapacksPath ¶ added in v1.0.39
GetDatapacksPath returns the datapack directory for a server's world. Datapacks are world data, not mods, so they live under the world folder rather than a loader-specific mods directory.
func GetJavaVersion ¶
Fetches required Java version for a specific Minecraft version
func GetModsPath ¶
GetModsPath returns the path where mods should be stored for a given server
func GetProtocolVersion ¶
Get protocol version for a Minecraft version string
func GetTPSCommand ¶
func GetVersionDate ¶
Returns the release date of a Minecraft version
func IsClientOnly ¶ added in v1.0.39
IsClientOnly reports whether the jar targets the client exclusively. It returns false for unknown metadata; callers that must be strict should check InspectModSide directly.
func IsValidDatapackFile ¶ added in v1.0.39
IsValidDatapackFile reports whether a filename has a datapack archive extension. Datapacks are distributed as ZIP archives.
func IsValidModFile ¶
IsValidModFile checks if a file is a valid mod file for the given loader
func IsValidVersion ¶
Checks if a given version string is a valid Minecraft version
func LoadYAMLConfig ¶
func LoadYAMLConfig(serverDataPath string, configFile ConfigFile) (map[string]any, error)
LoadYAMLConfig loads a YAML configuration file
func NormalizeDatapackArchive ¶ added in v1.0.39
NormalizeDatapackArchive repairs a common real-world packaging mistake: the whole datapack is nested inside a single wrapper directory (pack.mcmeta sits at wrapper/pack.mcmeta instead of the archive root). Minecraft ignores such archives, so the installer re-packs them with the wrapper stripped. It reports whether the archive was rewritten. An archive that is already valid, or that cannot be repaired, is left untouched (an error is returned only for a structurally broken archive).
func PackFormatWarning ¶ added in v1.0.39
func PackFormatWarning(pack PackFormat, mcVersion string) string
PackFormatWarning judges a datapack's declared formats against a server's Minecraft version. Minecraft loads packs whose format is at or below the game's supported format (older packs get fixers) and marks packs built for NEWER formats as incompatible. The message is empty when the pack is fine or when either side is unknown — the panel never warns on guesses.
func ParsePlayerListFromOutput ¶
ParsePlayerListFromOutput parses player count and names from list command output.
func ParseTPSFromOutput ¶
ParseTPSFromOutput parses TPS value from various server command outputs.
func SaveServerProperties ¶
func SaveServerProperties(serverDataPath string, properties ServerProperties) error
SaveServerProperties saves the server.properties file
func SaveYAMLConfig ¶
func SaveYAMLConfig(serverDataPath string, configFile ConfigFile, config map[string]any) error
SaveYAMLConfig saves a YAML configuration file
func SyncVelocitySecretToDataPath ¶
SyncVelocitySecretToDataPath writes or updates the Velocity modern forwarding secret in paper-global.yml or paper.yml
func ValidateDatapackArchive ¶ added in v1.0.39
ValidateDatapackArchive checks that a file is a well-formed datapack: a ZIP archive containing a pack.mcmeta descriptor at its root. This is what separates a real datapack from an arbitrary zip a user might upload.
func ValidateDatapackFilename ¶ added in v1.0.39
ValidateDatapackFilename rejects path traversal and non-zip names.
Types ¶
type ConfigFile ¶
type ConfigFile string
ConfigFile represents a generic configuration file type
const ( ConfigServerProperties ConfigFile = "server.properties" ConfigBukkit ConfigFile = "bukkit.yml" ConfigSpigot ConfigFile = "spigot.yml" ConfigPaper ConfigFile = "paper.yml" ConfigPaperGlobal ConfigFile = "config/paper-global.yml" ConfigPaperWorld ConfigFile = "config/paper-world-defaults.yml" )
func GetConfigFiles ¶
func GetConfigFiles(loader models.ModLoader) []ConfigFile
GetConfigFiles returns the configuration files for a specific mod loader
type LatestVersions ¶
type ModLoaderInfo ¶
type ModLoaderInfo struct {
Name string
DisplayName string
Description string
Category string
ModsDirectory string
ConfigDirectory string
SupportedVersions []string
FileExtensions []string
}
ModLoaderInfo contains information about a specific mod loader
func GetAllModLoaders ¶
func GetAllModLoaders() []ModLoaderInfo
GetAllModLoaders returns information about all available mod loaders
func GetModLoaderInfo ¶
func GetModLoaderInfo(loader models.ModLoader) ModLoaderInfo
GetModLoaderInfo returns information about a specific mod loader
type ModSide ¶ added in v1.0.39
type ModSide string
ModSide describes which Minecraft side a mod artifact targets.
const ( // SideClient means the mod is client-only and will crash a dedicated server. SideClient ModSide = "client" // SideServer means the mod targets the server side only. SideServer ModSide = "server" // SideBoth means the mod runs on both sides (the Fabric default). SideBoth ModSide = "both" // SideUnknown means the metadata declares nothing reliable (e.g. Forge). SideUnknown ModSide = "unknown" )
func InspectModSide ¶ added in v1.0.39
InspectModSide reads a mod jar's metadata to determine whether it targets the client, the server, or both. Client-only mods crash dedicated servers at class load, so a panel must catch them before installing (ME-04).
Fabric and Quilt declare an explicit environment; Forge and NeoForge have no reliable equivalent, so those return SideUnknown rather than guessing.
type PackFormat ¶ added in v1.0.39
PackFormat is the pack-format range a datapack declares in pack.mcmeta. Formats since 1.21.9 carry minor parts (88.0, 94.1), so the range is floating point. A zero Min means the archive declared nothing usable.
func ReadPackFormat ¶ added in v1.0.39
func ReadPackFormat(archivePath string) (PackFormat, error)
ReadPackFormat parses the pack.mcmeta of a datapack archive. It understands all three historical shapes: legacy pack_format, pack_format as a range object with supported_formats, and the 1.21.9+ min_format/max_format pair. A zero value means the archive declared nothing the panel can judge.
func (PackFormat) Known ¶ added in v1.0.39
func (p PackFormat) Known() bool
Known reports whether the archive declared any format at all.
func (PackFormat) String ¶ added in v1.0.39
func (p PackFormat) String() string
String renders the declared range for display ("48", "88.0 - 94.1").
type ProtocolVersionEntry ¶
type SLPClient ¶
type SLPClient struct {
// contains filtered or unexported fields
}
Implements the Minecraft Server List Ping protocol
type SLPResult ¶
type SLPResult struct {
Version struct {
Name string `json:"name"`
Protocol int `json:"protocol"`
} `json:"version"`
Players struct {
Max int `json:"max"`
Online int `json:"online"`
Sample []struct {
Name string `json:"name"`
ID string `json:"id"`
} `json:"sample"`
} `json:"players"`
Description json.RawMessage `json:"description"`
Favicon string `json:"favicon,omitempty"`
EnforcesSecure bool `json:"enforcesSecureChat,omitempty"`
LatencyMs int64
MOTD string // Parsed from Description
PlayerNames []string // Extracted player names
}
Parsed response from a server list ping
type ServerProperties ¶
ServerProperties represents the Minecraft server.properties file
func LoadServerProperties ¶
func LoadServerProperties(serverDataPath string) (ServerProperties, error)
LoadServerProperties loads the server.properties file from a server's data directory
func (ServerProperties) GetBool ¶
func (p ServerProperties) GetBool(key string, defaultValue bool) bool
func (ServerProperties) GetString ¶
func (p ServerProperties) GetString(key string, defaultValue string) string
func (ServerProperties) SetBool ¶
func (p ServerProperties) SetBool(key string, value bool)
func (ServerProperties) SetInt ¶
func (p ServerProperties) SetInt(key string, value int)
func (ServerProperties) SetString ¶
func (p ServerProperties) SetString(key, value string)
type Version ¶
type Version struct {
ID string `json:"id"`
Type string `json:"type"`
URL string `json:"url"`
Time time.Time `json:"time"`
ReleaseTime time.Time `json:"releaseTime"`
SHA1 string `json:"sha1"`
ComplianceLevel int `json:"complianceLevel"`
}
A single Minecraft version entry
func GetVersionInfo ¶
Returns detailed information about a specific version
type VersionManifestV2 ¶
type VersionManifestV2 struct {
Latest LatestVersions `json:"latest"`
Versions []Version `json:"versions"`
}
type VersionMetadata ¶
type VersionMetadata struct {
JavaVersion struct {
Component string `json:"component"`
MajorVersion int `json:"majorVersion"`
} `json:"javaVersion"`
}
Metadata for a specific version