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
- func KnownParser(parser string) bool
- 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-vanilla", Name: "Vanilla", Game: "Minecraft", Repo: "pelican-eggs/minecraft", Commit: minecraftCommit, Path: "java/vanilla/egg-vanilla-minecraft.yaml", MemoryMB: 2 << 10, DiskMB: 5 << 10, }, { ID: "minecraft-paper", Name: "Paper", Game: "Minecraft", Repo: "pelican-eggs/minecraft", Commit: minecraftCommit, Path: "java/paper/egg-paper.yaml", }, { ID: "minecraft-purpur", Name: "Purpur", Game: "Minecraft", Repo: "pelican-eggs/minecraft", Commit: minecraftCommit, Path: "java/purpur/egg-purpur.yaml", MemoryMB: 2 << 10, DiskMB: 5 << 10, }, { ID: "minecraft-fabric", Name: "Fabric", Game: "Minecraft", Repo: "pelican-eggs/minecraft", Commit: minecraftCommit, Path: "java/fabric/egg-fabric.yaml", MemoryMB: 2 << 10, DiskMB: 5 << 10, }, { ID: "minecraft-forge", Name: "Forge", Game: "Minecraft", Repo: "pelican-eggs/minecraft", Commit: minecraftCommit, Path: "java/forge/egg-forge-minecraft.yaml", MemoryMB: 4 << 10, DiskMB: 10 << 10, }, { ID: "minecraft-neoforge", Name: "NeoForge", Game: "Minecraft", Repo: "pelican-eggs/minecraft", Commit: minecraftCommit, Path: "java/neoforge/egg-neo-forge.json", MemoryMB: 4 << 10, DiskMB: 10 << 10, }, { ID: "minecraft-velocity", Name: "Velocity", Game: "Minecraft", Repo: "pelican-eggs/minecraft", Commit: minecraftCommit, Path: "proxy/java/velocity/egg-velocity.json", MemoryMB: 512, DiskMB: 1 << 10, }, { ID: "minecraft-bedrock", Name: "Bedrock", Game: "Minecraft", Repo: "pelican-eggs/minecraft", Commit: minecraftCommit, Path: "bedrock/bedrock/egg-vanilla-bedrock.json", MemoryMB: 1 << 10, DiskMB: 2 << 10, }, { ID: "7-days-to-die", Name: "7 Days to Die", Game: "7 Days to Die", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "7_days_to_die/egg-7-days-to-die.json", MemoryMB: 8 << 10, DiskMB: 20 << 10, Ports: 4, Block: 4, }, { ID: "ark-survival-ascended", Name: "ARK: Survival Ascended", Game: "ARK: Survival Ascended", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "ark_survival_ascended/egg-a-r-k--survival-ascended.json", MemoryMB: 16 << 10, DiskMB: 40 << 10, }, { ID: "counter-strike-2", Name: "Counter-Strike 2", Game: "Counter-Strike 2", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "counter_strike/counter_strike_2/egg-counter--strike2.yaml", MemoryMB: 4 << 10, DiskMB: 50 << 10, Ports: 2, }, { ID: "enshrouded", Name: "Enshrouded", Game: "Enshrouded", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "enshrouded/egg-enshrouded.json", MemoryMB: 12 << 10, DiskMB: 10 << 10, Ports: 2, }, { ID: "garrys-mod", Name: "Garry's Mod", Game: "Garry's Mod", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "gmod/egg-garrys-mod.yaml", MemoryMB: 2 << 10, DiskMB: 10 << 10, }, { ID: "palworld", Name: "Palworld", Game: "Palworld", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "palworld/egg-palworld.yaml", }, { ID: "project-zomboid", Name: "Project Zomboid", Game: "Project Zomboid", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "project_zomboid/egg-project-zomboid.json", MemoryMB: 4 << 10, DiskMB: 10 << 10, Ports: 2, }, { ID: "rust", Name: "Rust", Game: "Rust", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "rust/vanilla/egg-rust.yaml", MemoryMB: 8 << 10, DiskMB: 30 << 10, Ports: 4, }, { ID: "satisfactory", Name: "Satisfactory", Game: "Satisfactory", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "satisfactory/egg-satisfactory.json", MemoryMB: 12 << 10, DiskMB: 25 << 10, Ports: 2, }, { ID: "sons-of-the-forest", Name: "Sons of the Forest", Game: "Sons of the Forest", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "sonsoftheforest/egg-sons-of-the-forest.json", MemoryMB: 8 << 10, DiskMB: 10 << 10, Ports: 3, }, { ID: "squad", Name: "Squad", Game: "Squad", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "squad/egg-squad.json", MemoryMB: 8 << 10, DiskMB: 25 << 10, Ports: 3, }, { ID: "v-rising", Name: "V Rising", Game: "V Rising", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "v_rising/v_rising_vanilla/egg-v-rising.json", MemoryMB: 8 << 10, DiskMB: 10 << 10, Ports: 2, }, { ID: "valheim", Name: "Valheim", Game: "Valheim", Repo: "pelican-eggs/games-steamcmd", Commit: steamCommit, Path: "valheim/valheim_vanilla/egg-valheim.json", MemoryMB: 4 << 10, DiskMB: 5 << 10, Ports: 3, Block: 3, }, { 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.
func Expand ¶
Expand fills in {{...}} placeholders. Eggs name the same value in several ways, from {{VAR}} to the long server.build.env.VAR and the server.allocations.* paths newer Pelican eggs use; all are understood. A placeholder that cannot be resolved is left as written.
func KnownParser ¶ added in v0.7.2
KnownParser reports whether ApplyFile can edit files with the parser.
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; some write the caret twice, and mean the same.
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
// Block is how many ports in a row, from the game port, the game itself
// opens without an egg variable to say where (Valheim's query port is
// always the game port plus one). They are part of Ports. Zero or one
// means the game port stands alone.
Block 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
}