Documentation
¶
Overview ¶
Package egg reads Pterodactyl and Pelican egg files, the game server definitions that most existing panels share, into one internal format.
Index ¶
- Constants
- Variables
- func ApplyFile(parser string, content []byte, replaces []Replace, expand func(string) string) (out []byte, skipped []string, err error)
- func Expand(s string, vars map[string]string, port int) string
- type Command
- type ConfigFile
- type Done
- type Egg
- type Entry
- type Image
- type Install
- type Kind
- type Replace
- type Variable
Constants ¶
const FeatureEULA = "eula"
FeatureEULA marks games, Minecraft's, that will not start until the player has accepted a license by writing eula=true to eula.txt.
const MaxConfigFile = 4 << 20
MaxConfigFile is the largest config file ApplyFile is meant for. The caller enforces it when it reads the file.
Variables ¶
var Catalog = []Entry{ { ID: "minecraft-paper", Name: "Paper", Game: "Minecraft", Repo: "pelican-eggs/minecraft", Commit: "75bf05db3c6c305e0fa6eef1d38c7e7176121de9", Path: "java/paper/egg-paper.yaml", }, { ID: "rust", Name: "Rust", Game: "Rust", Repo: "pelican-eggs/games-steamcmd", Commit: "e17e2c3db36aaf1ddecbc227803dd6cdbb0e6b1f", Path: "rust/vanilla/egg-rust.yaml", MemoryMB: 8 << 10, DiskMB: 30 << 10, Ports: 4, }, { ID: "palworld", Name: "Palworld", Game: "Palworld", Repo: "pelican-eggs/games-steamcmd", Commit: "e17e2c3db36aaf1ddecbc227803dd6cdbb0e6b1f", Path: "palworld/egg-palworld.yaml", }, { ID: "nodejs", Kind: KindRuntime, Name: "Node.js", Game: "Node.js", Repo: "pelican-eggs/generic", Commit: genericCommit, Path: "nodejs/egg-nodejs-generic.yaml", }, { ID: "python", Kind: KindRuntime, Name: "Python", Game: "Python", Repo: "pelican-eggs/generic", Commit: genericCommit, Path: "python/egg-python-generic.json", }, { ID: "bun", Kind: KindRuntime, Name: "Bun", Game: "Bun", Repo: "pelican-eggs/generic", Commit: genericCommit, Path: "bun/egg-bun.json", }, { ID: "deno", Kind: KindRuntime, Name: "Deno", Game: "Deno", Repo: "pelican-eggs/generic", Commit: genericCommit, Path: "deno/egg-deno-generic.json", }, { ID: "java", Kind: KindRuntime, Name: "Java", Game: "Java", Repo: "pelican-eggs/generic", Commit: genericCommit, Path: "java/egg-generic-java.json", MemoryMB: 1024, }, }
var RawBase = "https://raw.githubusercontent.com"
RawBase is where catalog files are downloaded from. Tests point it at a local server.
var RuntimeVars = []string{
"SERVER_MEMORY", "SERVER_IP", "SERVER_PORT", "TZ", "STARTUP",
"P_SERVER_LOCATION", "P_SERVER_UUID",
}
RuntimeVars are the environment variables the runtime has to set for every server, whatever the egg declares. Startup commands and install scripts use them freely, for example -Xmx{{SERVER_MEMORY}}M.
Functions ¶
func ApplyFile ¶
func ApplyFile(parser string, content []byte, replaces []Replace, expand func(string) string) (out []byte, skipped []string, err error)
ApplyFile makes the changes an egg asks for in one config file and returns the new content. The parser is one of properties, file, yaml, json, ini and xml. Values go through expand first, so they may hold placeholders; expand may be nil.
A file that cannot be read as its format is an error. A key that cannot be set, such as a path that runs through a plain value, is left alone and named in skipped, so the rest of the file still gets its changes.
Types ¶
type ConfigFile ¶
type ConfigFile struct {
Path string
Parser string // properties, file, yaml, json, ini or xml
Find []Replace
}
ConfigFile is a file the panel edits before each start.
type Done ¶
type Done struct {
// contains filtered or unexported fields
}
Done reports whether a console line means the server has started. A done string matches when the line contains it; one that starts with "regex:" is a regular expression the line is searched with. Lines that cannot be compiled never match.
type Egg ¶
type Egg struct {
Version string // meta.version of the file it came from
Name string
Author string
Description string
Features []string
Images []Image // the first one is the default
// Startup is the default command; StartupCommands has every named
// variant in file order, and Startup is the first of them.
Startup string
StartupCommands []Command
// Stop is the raw value: a console command, or "^" plus a signal.
Stop string
Done []string // console lines that mean the server has started
Files []ConfigFile
Install Install
Variables []Variable
}
Egg is one game server definition.
func Fetch ¶
Fetch downloads a catalog entry and returns it parsed, along with the file as downloaded so it can be stored unchanged.
func FetchURL ¶
FetchURL downloads an egg from any https address. Without a client of its own it only connects to public addresses.
func Parse ¶
Parse reads an egg in any supported format. The format is told apart by its first character and then by meta.version.
func (*Egg) DoneMatcher ¶
DoneMatcher prepares the egg's done lines.
func (*Egg) HasFeature ¶
HasFeature reports whether the egg lists the feature, such as "eula".
func (*Egg) StopSignal ¶
StopSignal reports whether Stop is a signal rather than a console command. Eggs write it as "^C" for SIGINT or "^" plus a signal name.
type Entry ¶
type Entry struct {
ID string
// Kind tells the eggs of games from the generic ones that run a
// program of the user's own. The two are offered in different places.
Kind Kind
Name string
Game string
Repo string // owner/name on GitHub
Commit string // full SHA
Path string
// What a game needs when the egg does not say, offered as the defaults
// of a new server: memory and disk in MB, and how many ports it takes.
// Zero means the general defaults.
MemoryMB int64
DiskMB int64
Ports int
}
Entry is one egg in the curated list. The list is not embedded in the binary: it names files in the pelican-eggs repositories (MIT) at a fixed commit, and the commits move with Zelie releases.
type Replace ¶
Replace sets Key to Value. Value may hold placeholders. When IfValue is set the key is only changed if it currently holds that value; eggs write that as a nested object under the key.
type Variable ¶
type Variable struct {
Name string
Description string
Env string
Default string
UserViewable bool
UserEditable bool
Rules []string
}