Documentation
¶
Overview ¶
Package core is the privileged half of Zelie. It runs as root, owns containerd, and accepts a small set of typed requests over a Unix socket. Nothing here listens on the network.
Index ¶
- Constants
- Variables
- func LoadExternal(path string) (*External, []ExternalListener, error)
- func UsedPorts() ([]int, error)
- type Backup
- type BackupMeta
- type Builder
- type Client
- func (c *Client) AddOldKey(ctx context.Context, recovery string) ([]string, error)
- func (c *Client) AppendUpload(ctx context.Context, id string, offset int64, piece io.Reader) (Upload, error)
- func (c *Client) BackUpVolumes(ctx context.Context, app string, vols []VolumeRef, live bool) (Backup, error)
- func (c *Client) Backups(ctx context.Context, app string) ([]Backup, error)
- func (c *Client) Build(ctx context.Context, app, version string, env, sealedEnv []string, ...) (build.Result, error)
- func (c *Client) ClearForwards(ctx context.Context, app string) error
- func (c *Client) CompressFiles(ctx context.Context, ref FileRef, dir string, paths []string, name string) (string, error)
- func (c *Client) CopyVolume(ctx context.Context, from, to string) error
- func (c *Client) CreateBackup(ctx context.Context, app, container, kind string) (Backup, error)
- func (c *Client) CreateVolume(ctx context.Context, name string) error
- func (c *Client) DataExport(ctx context.Context, app, container, engine string, q dataview.Query, ...) error
- func (c *Client) DataKey(ctx context.Context, app, container, key string) (dataview.Value, error)
- func (c *Client) DataKeys(ctx context.Context, app, container, pattern, cursor string) (dataview.KeyPage, error)
- func (c *Client) DataRows(ctx context.Context, app, container, engine string, q dataview.Query) (dataview.Page, error)
- func (c *Client) DataTables(ctx context.Context, app, container, engine string) ([]dataview.Table, error)
- func (c *Client) DeleteFiles(ctx context.Context, ref FileRef, paths []string) error
- func (c *Client) DownloadBackup(ctx context.Context, app, name string, w io.Writer) error
- func (c *Client) DownloadFile(ctx context.Context, ref FileRef, p string) (io.ReadCloser, int64, error)
- func (c *Client) DownloadRange(ctx context.Context, ref FileRef, p string, offset, length int64) (io.ReadCloser, int64, error)
- func (c *Client) ExtractFile(ctx context.Context, ref FileRef, p, dir string) (ExtractResult, error)
- func (c *Client) FetchBackup(ctx context.Context, app, name string) error
- func (c *Client) Host(ctx context.Context) (engine.Host, error)
- func (c *Client) ImportUpload(ctx context.Context, id, kind string) (Backup, error)
- func (c *Client) LayerSizes(ctx context.Context) ([]engine.LayerSize, error)
- func (c *Client) Links(ctx context.Context, app string) ([]engine.Link, error)
- func (c *Client) List(ctx context.Context) ([]engine.Status, error)
- func (c *Client) ListFiles(ctx context.Context, ref FileRef, dir string) (FileList, error)
- func (c *Client) Logs(ctx context.Context, id string, follow bool, tail int64, w io.Writer) error
- func (c *Client) MakeFolder(ctx context.Context, ref FileRef, p string) error
- func (c *Client) Offsite(ctx context.Context) (OffsiteInfo, error)
- func (c *Client) OffsiteBackups(ctx context.Context) (OffsiteList, error)
- func (c *Client) OpenFolder(ctx context.Context, ref FileRef, dir string) (Folder, error)
- func (c *Client) PeekVolumeFile(ctx context.Context, volume, path string) ([]byte, error)
- func (c *Client) Pin(ctx context.Context, image string) (string, error)
- func (c *Client) PrepareVolume(ctx context.Context, name string, req PrepareRequest) (PrepareResponse, error)
- func (c *Client) PublicAddress(ctx context.Context) (PublicAddress, error)
- func (c *Client) ReadFile(ctx context.Context, ref FileRef, p string) ([]byte, error)
- func (c *Client) RecoveryKey(ctx context.Context, host string, w io.Writer) error
- func (c *Client) Remove(ctx context.Context, id string) error
- func (c *Client) RemoveBackup(ctx context.Context, app, name string) error
- func (c *Client) RemoveBuildCache(ctx context.Context, app string) error
- func (c *Client) RemoveExternal(ctx context.Context, app, engine, container string) error
- func (c *Client) RemoveFile(ctx context.Context, ref FileRef, p string) error
- func (c *Client) RemoveImage(ctx context.Context, name string) error
- func (c *Client) RemoveOffsite(ctx context.Context) error
- func (c *Client) RemoveOffsiteBackup(ctx context.Context, app, name string) error
- func (c *Client) RemoveUpload(ctx context.Context, id string) error
- func (c *Client) RemoveVolume(ctx context.Context, name string) error
- func (c *Client) RenameFile(ctx context.Context, ref FileRef, from, to string) error
- func (c *Client) RestoreBackup(ctx context.Context, app, name, kind, container, volume string) error
- func (c *Client) RestoreVolumes(ctx context.Context, app, name string, vols []VolumeRef, size int64) error
- func (c *Client) Reveal(ctx context.Context, app, sealed string) (string, error)
- func (c *Client) Run(ctx context.Context, s engine.Spec) error
- func (c *Client) RunApp(ctx context.Context, s engine.Spec, sealedEnv []string, linked ...LinkedVar) (string, error)
- func (c *Client) RunInstall(ctx context.Context, req InstallRequest) (string, error)
- func (c *Client) SFTP(ctx context.Context) (SFTPStatus, error)
- func (c *Client) SecretKey(ctx context.Context) (secret.PublicKey, error)
- func (c *Client) SetExternal(ctx context.Context, app, engine, container string, port, target int, ...) error
- func (c *Client) SetFileMode(ctx context.Context, ref FileRef, p string, mode fs.FileMode) error
- func (c *Client) SetFileTimes(ctx context.Context, ref FileRef, p string, atime, mtime time.Time) error
- func (c *Client) SetForwards(ctx context.Context, app string, forwards []engine.Forward) error
- func (c *Client) SetLinks(ctx context.Context, app string, links []engine.Link) error
- func (c *Client) SetOffsite(ctx context.Context, cfg OffsiteConfig) (OffsiteInfo, error)
- func (c *Client) SetSFTPPort(ctx context.Context, port int) error
- func (c *Client) SetSFTPVolumes(ctx context.Context, names []string) error
- func (c *Client) Signal(ctx context.Context, id, signal string) error
- func (c *Client) StartUpload(ctx context.Context, app string, size int64) (Upload, error)
- func (c *Client) StatFile(ctx context.Context, ref FileRef, p string) (FileEntry, error)
- func (c *Client) Stop(ctx context.Context, id string, graceSeconds int) error
- func (c *Client) SweepImages(ctx context.Context, keep []string) ([]string, error)
- func (c *Client) SyncExternal(ctx context.Context, list []ExternalListener) error
- func (c *Client) TruncateFile(ctx context.Context, ref FileRef, p string, size int64) error
- func (c *Client) Update(ctx context.Context, version string) error
- func (c *Client) UpdateStatus(ctx context.Context) (UpdateStatus, error)
- func (c *Client) Upload(ctx context.Context, id string) (Upload, error)
- func (c *Client) UploadBackup(ctx context.Context, app, name string, meta BackupMeta) error
- func (c *Client) UploadFile(ctx context.Context, ref FileRef, p string, size int64, body io.Reader) error
- func (c *Client) Usage(ctx context.Context, id string) (engine.Usage, error)
- func (c *Client) UsedPorts(ctx context.Context) ([]int, error)
- func (c *Client) Version(ctx context.Context) (string, error)
- func (c *Client) VolumeSizes(ctx context.Context) (sizes map[string]int64, unmeasured []string, err error)
- func (c *Client) Wait(ctx context.Context, id string) (int, error)
- func (c *Client) WriteFile(ctx context.Context, ref FileRef, p string, content []byte, create bool) error
- func (c *Client) WriteStdin(ctx context.Context, id string, data []byte) error
- type ConfigChange
- type ConfigFile
- type Engine
- type Error
- type External
- type ExternalListener
- type ExtractResult
- type FileEntry
- type FileList
- type FileOwner
- type FileRef
- type Folder
- type InstallRequest
- type LinkedVar
- type Offsite
- type OffsiteBackup
- type OffsiteConfig
- type OffsiteInfo
- type OffsiteList
- type PeekRequest
- type PeekResponse
- type PrepareRequest
- type PrepareResponse
- type PublicAddress
- type SFTPSocket
- type SFTPStatus
- type SFTPVolumes
- type Server
- type UpdateStatus
- type Updater
- type Upload
- type VolumeRef
Constants ¶
const ( InstallScriptPath = "/mnt/install/install.sh" InstallVolumePath = "/mnt/server" )
Where an install container finds its script and the server's files, as Pterodactyl's installers expect them.
const DefaultSocket = "/run/zelie/core.sock"
DefaultSocket is where the core listens.
const ExternalUser = "zelie_external"
ExternalUser is the database user desktop tools sign in as. It is not the apps' user, so its password can change or go without touching them.
const (
// MaxEditBytes is the largest file the editor opens or saves.
MaxEditBytes = 4 << 20
)
const MaxPeek = 1 << 20
MaxPeek is the most a peek returns. It is for small text files the panel reads to learn something about a server, such as a game's manifest.
const MaxUploadChunk = 32 << 20
MaxUploadChunk is the most one piece of an upload may carry.
Variables ¶
var MeasureTimeout = 5 * time.Minute
MeasureTimeout is how long the panel waits for the core to measure disk use. The core walks files a container controls, and a walk that does not end would otherwise hold up every check that comes after it. A variable so tests can shorten it.
var RevealableNames = []string{"POSTGRES_PASSWORD", "MARIADB_PASSWORD", "REDIS_PASSWORD"}
RevealableNames are the sealed variables the core will open for the panel to show: the passwords of databases' app users. Everything else sealed here, such as an app's tokens or a database's root password, stays closed. The panel checks that every engine's password variable is listed.
var SFTPRoutes = []string{
"POST /v1/volumes/{name}/files/list",
"POST /v1/volumes/{name}/files/entries",
"POST /v1/volumes/{name}/files/stat",
"POST /v1/volumes/{name}/files/chmod",
"POST /v1/volumes/{name}/files/truncate",
"POST /v1/volumes/{name}/files/chtimes",
"POST /v1/volumes/{name}/files/mkdir",
"POST /v1/volumes/{name}/files/rename",
"POST /v1/volumes/{name}/files/remove",
"PUT /v1/volumes/{name}/files/upload",
"GET /v1/volumes/{name}/files/download",
}
SFTPRoutes are the only routes the SFTP process may use: the file operations of a volume, and nothing that starts, stops or configures anything. Which volume a login gets is the panel's decision.
Functions ¶
func LoadExternal ¶
func LoadExternal(path string) (*External, []ExternalListener, error)
LoadExternal reads the saved listeners. Start opens them.
Types ¶
type BackupMeta ¶
type BackupMeta struct {
// Engine is the database's; empty for a backup of an app's volumes.
Engine string `json:"engine"`
Volumes []string `json:"volumes,omitempty"`
Size int64 `json:"size,omitempty"`
}
BackupMeta is what a backup holds, sent along with it, encrypted, so another server can tell what to restore it into.
type Builder ¶
type Builder interface {
Build(ctx context.Context, req build.Request, out io.Writer) (build.Result, error)
RemoveCache(app string) error
}
Builder is what the core needs to build images.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to the core over its socket. The panel and the CLI use it.
func (*Client) AddOldKey ¶
AddOldKey adds the keys of another recovery file, and returns the public halves of the new ones.
func (*Client) AppendUpload ¶
func (c *Client) AppendUpload(ctx context.Context, id string, offset int64, piece io.Reader) (Upload, error)
AppendUpload sends one piece of an upload, which starts at offset.
func (*Client) BackUpVolumes ¶
func (c *Client) BackUpVolumes(ctx context.Context, app string, vols []VolumeRef, live bool) (Backup, error)
BackUpVolumes backs up an app's volumes into one archive. Live copies them while the app runs; otherwise the app must be stopped.
func (*Client) Build ¶
func (c *Client) Build(ctx context.Context, app, version string, env, sealedEnv []string, source io.Reader, out io.Writer) (build.Result, error)
Build sends source, a gzipped tar with one top-level directory, to be built for app, with the app's variables: env as NAME=value, sealedEnv sealed for the core. The build's output is written to out as it happens.
func (*Client) ClearForwards ¶ added in v0.6.0
ClearForwards closes every port open to an app.
func (*Client) CompressFiles ¶ added in v0.6.0
func (c *Client) CompressFiles(ctx context.Context, ref FileRef, dir string, paths []string, name string) (string, error)
CompressFiles packs items of one folder into a .tar.gz there and returns its name.
func (*Client) CopyVolume ¶ added in v0.7.3
CopyVolume fills the empty volume to with the files of from, owners included. Both are volumes of game servers or files apps.
func (*Client) CreateBackup ¶
CreateBackup backs up a database from its running container.
func (*Client) CreateVolume ¶
CreateVolume makes an empty volume.
func (*Client) DataExport ¶
func (c *Client) DataExport(ctx context.Context, app, container, engine string, q dataview.Query, w io.Writer) error
DataExport writes every row the query finds to w as CSV.
func (*Client) DataKeys ¶
func (c *Client) DataKeys(ctx context.Context, app, container, pattern, cursor string) (dataview.KeyPage, error)
DataKeys goes one step through a Redis database's keys.
func (*Client) DataRows ¶
func (c *Client) DataRows(ctx context.Context, app, container, engine string, q dataview.Query) (dataview.Page, error)
DataRows reads a page of a table.
func (*Client) DataTables ¶
func (c *Client) DataTables(ctx context.Context, app, container, engine string) ([]dataview.Table, error)
DataTables lists a database's tables and views, with their columns.
func (*Client) DeleteFiles ¶ added in v0.6.0
func (*Client) DownloadBackup ¶
DownloadBackup copies the encrypted file to w.
func (*Client) DownloadFile ¶ added in v0.6.0
func (c *Client) DownloadFile(ctx context.Context, ref FileRef, p string) (io.ReadCloser, int64, error)
DownloadFile opens a file of a volume, which the caller closes, and says how long it is.
func (*Client) DownloadRange ¶ added in v0.7.0
func (c *Client) DownloadRange(ctx context.Context, ref FileRef, p string, offset, length int64) (io.ReadCloser, int64, error)
DownloadRange is DownloadFile for length bytes from offset, or to the end when length is negative. What lies past the end of the file is not sent.
func (*Client) ExtractFile ¶ added in v0.6.0
func (c *Client) ExtractFile(ctx context.Context, ref FileRef, p, dir string) (ExtractResult, error)
ExtractFile unpacks an archive of a volume into dir, or into the folder it is in when dir is empty.
func (*Client) FetchBackup ¶
FetchBackup brings a backup back from the destination onto this server.
func (*Client) ImportUpload ¶
ImportUpload makes a backup of a whole upload, as a dump of kind.
func (*Client) LayerSizes ¶ added in v0.8.0
LayerSizes returns the disk the own files of each running container take.
func (*Client) Logs ¶
Logs writes a container's output to w. With tail above zero it starts at the first whole line within that many bytes of the end. With follow set it keeps streaming new output until ctx is cancelled.
func (*Client) MakeFolder ¶ added in v0.6.0
func (*Client) Offsite ¶
func (c *Client) Offsite(ctx context.Context) (OffsiteInfo, error)
Offsite returns the destination backups are copied to.
func (*Client) OffsiteBackups ¶
func (c *Client) OffsiteBackups(ctx context.Context) (OffsiteList, error)
OffsiteBackups lists the backups in the destination, and what each holds.
func (*Client) OpenFolder ¶ added in v0.8.0
OpenFolder starts reading a folder of a volume, every item of it. The caller closes it.
func (*Client) PeekVolumeFile ¶ added in v0.6.0
PeekVolumeFile returns the file at path inside a volume, which may be in use. A file that is not there is a *Error with status 404.
func (*Client) PrepareVolume ¶ added in v0.6.0
func (c *Client) PrepareVolume(ctx context.Context, name string, req PrepareRequest) (PrepareResponse, error)
PrepareVolume edits a game server's config files and gives its files to the user the server runs as. The volume must not be in use.
func (*Client) PublicAddress ¶ added in v0.6.0
func (c *Client) PublicAddress(ctx context.Context) (PublicAddress, error)
PublicAddress returns the address found on the machine's network cards.
func (*Client) ReadFile ¶ added in v0.6.0
ReadFile returns a text file of a volume, up to MaxEditBytes.
func (*Client) RecoveryKey ¶
RecoveryKey returns the recovery file for the backups.
func (*Client) RemoveBackup ¶
func (*Client) RemoveBuildCache ¶
RemoveBuildCache deletes what builds of an app keep between them.
func (*Client) RemoveExternal ¶
RemoveExternal closes a database's loopback port and, if container is running, drops the external user.
func (*Client) RemoveFile ¶ added in v0.7.0
RemoveFile removes a file or an empty folder of a volume.
func (*Client) RemoveImage ¶
RemoveImage deletes an image Zelie built.
func (*Client) RemoveOffsite ¶
RemoveOffsite forgets the destination; the bucket is left as it is.
func (*Client) RemoveOffsiteBackup ¶
RemoveOffsiteBackup deletes a backup's copy in the destination.
func (*Client) RemoveVolume ¶
RemoveVolume deletes a volume and its files. No container may use it.
func (*Client) RenameFile ¶ added in v0.6.0
func (*Client) RestoreBackup ¶
func (c *Client) RestoreBackup(ctx context.Context, app, name, kind, container, volume string) error
RestoreBackup puts a backup back: into the running container for kinds that load in place, into the stopped database's volume for the others.
func (*Client) RestoreVolumes ¶
func (c *Client) RestoreVolumes(ctx context.Context, app, name string, vols []VolumeRef, size int64) error
RestoreVolumes replaces the files of a stopped app's volumes with a backup's. size is how much the backup's files take, from when it was made.
func (*Client) RunApp ¶
func (c *Client) RunApp(ctx context.Context, s engine.Spec, sealedEnv []string, linked ...LinkedVar) (string, error)
RunApp runs a container of s.App with secret variables sealed for it, and variables made from the secrets of apps it is linked to. It returns the image that runs, pinned by digest (see engine.Pin).
func (*Client) RunInstall ¶ added in v0.6.0
RunInstall starts a game server's install container and returns the image that runs, pinned by digest. Wait, Logs and Remove work on it like on any container.
func (*Client) SFTP ¶ added in v0.7.0
func (c *Client) SFTP(ctx context.Context) (SFTPStatus, error)
SFTP asks whether the SFTP socket is up, and for the host key.
func (*Client) SetExternal ¶
func (c *Client) SetExternal(ctx context.Context, app, engine, container string, port, target int, sealedPassword string) error
SetExternal opens a database's loopback port. With a sealed password it also makes the external user, or gives it the new password.
func (*Client) SetFileMode ¶ added in v0.8.0
SetFileMode sets the permission bits of a file or folder of a volume. Only the nine bits of read, write and execute are set.
func (*Client) SetFileTimes ¶ added in v0.8.0
func (c *Client) SetFileTimes(ctx context.Context, ref FileRef, p string, atime, mtime time.Time) error
SetFileTimes sets the access and modification time of a file or folder of a volume, to the second.
func (*Client) SetForwards ¶ added in v0.6.0
SetForwards replaces the host ports open to an app's container: host port, protocol and the container's port. Traffic from outside the server goes straight to the container, not through the web proxy.
func (*Client) SetLinks ¶
SetLinks replaces the links of an app: which other apps it may reach, on which port, and by what name.
func (*Client) SetOffsite ¶
func (c *Client) SetOffsite(ctx context.Context, cfg OffsiteConfig) (OffsiteInfo, error)
SetOffsite checks a destination and saves it.
func (*Client) SetSFTPPort ¶ added in v0.7.0
SetSFTPPort tells the core which port the SFTP socket listens on.
func (*Client) SetSFTPVolumes ¶ added in v0.7.0
SetSFTPVolumes tells the core which volumes the SFTP user may use.
func (*Client) Signal ¶ added in v0.6.0
Signal sends a signal such as SIGINT to a container's main process.
func (*Client) StartUpload ¶
StartUpload makes room for a file of size bytes for app.
func (*Client) SweepImages ¶
SweepImages tells the core which images are still needed. It deletes those that have not been for a week and returns their names.
func (*Client) SyncExternal ¶
func (c *Client) SyncExternal(ctx context.Context, list []ExternalListener) error
SyncExternal makes the core's loopback ports exactly these.
func (*Client) TruncateFile ¶ added in v0.8.0
TruncateFile makes a file of a volume the given length.
func (*Client) Update ¶ added in v0.2.0
Update starts an update to version. It returns once the release is downloaded and checked; the services restart after.
func (*Client) UpdateStatus ¶ added in v0.2.0
func (c *Client) UpdateStatus(ctx context.Context) (UpdateStatus, error)
func (*Client) UploadBackup ¶
UploadBackup copies a backup to the destination, with what it holds.
func (*Client) UploadFile ¶ added in v0.6.0
func (c *Client) UploadFile(ctx context.Context, ref FileRef, p string, size int64, body io.Reader) error
UploadFile stores what body carries as a file of a volume. size is its length when known, or -1.
func (*Client) UsedPorts ¶ added in v0.6.0
UsedPorts returns the ports in use on the server, sorted.
func (*Client) VolumeSizes ¶
func (c *Client) VolumeSizes(ctx context.Context) (sizes map[string]int64, unmeasured []string, err error)
VolumeSizes returns the disk each volume takes, by name, and the names of the volumes that could not be measured.
func (*Client) Wait ¶
Wait waits until the container's process has exited and returns its exit code.
type ConfigChange ¶ added in v0.6.0
type ConfigFile ¶ added in v0.6.0
type ConfigFile struct {
Path string `json:"path"`
Parser string `json:"parser"`
Changes []ConfigChange `json:"changes"`
}
ConfigFile is a file to edit, with its values already filled in.
type Engine ¶
type Engine interface {
Run(ctx context.Context, s engine.Spec) error
Stop(ctx context.Context, id string, grace time.Duration) error
Remove(ctx context.Context, id string) error
List(ctx context.Context) ([]engine.Status, error)
RemoveImage(ctx context.Context, name string) error
Images(ctx context.Context) ([]engine.Image, error)
SetUnused(ctx context.Context, name string, since time.Time) error
Pin(ctx context.Context, ref string) (string, error)
Wait(ctx context.Context, id string) (uint32, error)
WriteStdin(ctx context.Context, id string, data []byte) error
Signal(ctx context.Context, id string, sig syscall.Signal) error
Usage(id string) (engine.Usage, error)
CreateVolume(name string) error
RemoveVolume(ctx context.Context, name string) error
VolumeSizes() (sizes map[string]int64, unmeasured map[string]error, err error)
LayerSizes(ctx context.Context) ([]engine.LayerSize, error)
Links(app string) ([]engine.Link, error)
SetLinks(ctx context.Context, app string, links []engine.Link) error
SetForwards(ctx context.Context, app string, forwards []engine.Forward) error
Exec(ctx context.Context, id string, args []string, stdin io.Reader, stdout, stderr io.Writer) (uint32, error)
OpenVolume(ctx context.Context, name string) (*os.Root, error)
ReadVolume(name string) (*os.Root, error)
VolumeSize(name string) (int64, error)
}
Engine is what the core needs from the container engine.
type Error ¶
type Error struct {
Status int
Message string
// Code and Params are set for a message meant for the user.
Code string
Params map[string]any
}
Error is a failure reported by the core.
type External ¶
type External struct {
// contains filtered or unexported fields
}
External keeps the loopback listeners, and saves them so they come back when the core restarts.
func (*External) Set ¶
func (x *External) Set(l ExternalListener) (changed bool, err error)
Set opens or moves an app's listener. It reports whether that changed anything: the panel asks again for a port that is open, to learn whether something else would hold it.
func (*External) Start ¶
func (x *External) Start(list []ExternalListener)
Start opens the saved listeners. One that cannot open is logged and left for the panel to set again.
func (*External) Sync ¶
func (x *External) Sync(list []ExternalListener) error
Sync makes the listeners exactly list, which the panel sends when it starts.
type ExternalListener ¶
type ExternalListener struct {
App string `json:"app"`
Port int `json:"port"` // on 127.0.0.1
Target int `json:"target"` // the database's port in its container
}
ExternalListener is one loopback port and where it leads.
type ExtractResult ¶ added in v0.6.0
ExtractResult says what an unpacked archive made.
type FileEntry ¶ added in v0.6.0
type FileEntry struct {
Name string `json:"name"`
Size int64 `json:"size"`
Mode string `json:"mode"`
Modified time.Time `json:"modified"`
Dir bool `json:"dir"`
Symlink bool `json:"symlink"`
// Target is where a link points, as it is written. It is not followed.
Target string `json:"target,omitempty"`
}
FileEntry is one item of a folder.
type FileList ¶ added in v0.6.0
type FileList struct {
Path string `json:"path"`
Entries []FileEntry `json:"entries"`
Truncated bool `json:"truncated,omitempty"`
}
FileList is a folder's content, folders first.
type FileOwner ¶ added in v0.6.0
FileOwner is who the files belong to as the container sees it. The volume keeps container IDs on disk, so it is also what the files carry.
type FileRef ¶ added in v0.6.0
type FileRef struct {
Volume string
FileOwner
// Room is how many more bytes the volume may take under its limit; nil
// when that is not known.
Room *int64
}
FileRef says which volume a file request is for and how to treat it.
type Folder ¶ added in v0.8.0
type Folder interface {
// Next returns the next item, or io.EOF after the last. A listing that
// breaks off is an error, never an end.
Next() (FileEntry, error)
Close() error
}
Folder reads the items of a folder as the core sends them, so a folder of any size is read with the same little memory.
type InstallRequest ¶ added in v0.6.0
type InstallRequest struct {
ID string `json:"id"`
App string `json:"app"`
Image string `json:"image"`
// Entrypoint is the shell that runs the script, such as bash or ash.
Entrypoint string `json:"entrypoint"`
Script string `json:"script"`
Env []string `json:"env,omitempty"`
// Volume is the server's volume, mounted at InstallVolumePath.
Volume string `json:"volume"`
Network string `json:"network,omitempty"`
MemoryBytes int64 `json:"memory_bytes"`
CPUs float64 `json:"cpus"`
Pids int64 `json:"pids"`
}
InstallRequest is a game server's install container: an image that runs a script with the server's volume mounted. The panel waits for it and reads its output like any other container's.
type LinkedVar ¶
type LinkedVar struct {
Name string
// Template is the value, with {secret} where the secret goes.
Template string
// From is the app the secret belongs to, and Sealed the secret, sealed
// for it.
From, Sealed string
}
LinkedVar is a variable made from a secret of another app, such as a database URL with the database's password in it.
type Offsite ¶
type Offsite struct {
// contains filtered or unexported fields
}
Offsite holds the destination. Its keys stay in a file only root reads: the panel can set them but never read them back, so a panel taken over cannot hand them out. Pointing the backups at another bucket gains it nothing either, since they are encrypted.
func LoadOffsite ¶
LoadOffsite reads the destination saved at path, if there is one.
type OffsiteBackup ¶
type OffsiteBackup struct {
App string `json:"app"`
Name string `json:"name"`
Bytes int64 `json:"bytes"`
Created time.Time `json:"created"`
// Meta is what the backup holds, when it was asked for and could be
// read. Locked is set when it is there but no key here opens it.
Meta *BackupMeta `json:"meta,omitempty"`
Locked bool `json:"locked,omitempty"`
}
OffsiteBackup is a backup file found in the bucket.
type OffsiteConfig ¶
type OffsiteConfig struct {
Endpoint string `json:"endpoint"`
Region string `json:"region"`
Bucket string `json:"bucket"`
Prefix string `json:"prefix"`
AccessKey string `json:"access_key"`
// SecretKey may be left out when changing the folder or the region;
// the one already saved is kept.
SecretKey string `json:"secret_key,omitempty"`
}
OffsiteConfig is where backups are copied off this server: a folder in an S3 bucket, and the keys to it.
type OffsiteInfo ¶
type OffsiteInfo struct {
Set bool `json:"set"`
Endpoint string `json:"endpoint,omitempty"`
Region string `json:"region,omitempty"`
Bucket string `json:"bucket,omitempty"`
Prefix string `json:"prefix,omitempty"`
AccessKey string `json:"access_key,omitempty"`
}
OffsiteInfo is the destination as the panel may see it: everything but the secret key.
type OffsiteList ¶
type OffsiteList struct {
// Key is the public key the folder's backups were encrypted for, from
// the note beside them, and Opens whether a key here opens them.
Key string `json:"key,omitempty"`
Opens bool `json:"opens"`
Backups []OffsiteBackup `json:"backups"`
}
OffsiteList is what the destination's folder holds.
type PeekRequest ¶ added in v0.6.0
type PeekRequest struct {
Path string `json:"path"`
}
PeekRequest names one file inside a volume.
type PeekResponse ¶ added in v0.6.0
type PeekResponse struct {
Content []byte `json:"content"`
}
PeekResponse holds the file as it is.
type PrepareRequest ¶ added in v0.6.0
type PrepareRequest struct {
// UID and GID are the owner as the container sees it. The volume keeps
// container IDs on disk, so this is also what the files carry.
UID uint32 `json:"uid"`
GID uint32 `json:"gid"`
Files []ConfigFile `json:"files,omitempty"`
}
PrepareRequest makes a game server's volume ready to start: the config files its egg asks for are edited, and every file is given to the user the server runs as. It is refused while a container of the volume runs.
type PrepareResponse ¶ added in v0.6.0
type PrepareResponse struct {
Notes []string `json:"notes"`
}
PrepareResponse lists what could not be done. Nothing in it stops the server from starting; the panel shows it in the start's log.
type PublicAddress ¶ added in v0.6.0
PublicAddress is the address players are most likely to reach this machine on. Private means no network card has a public one, so players outside the machine's network may not get through.
func DetectAddress ¶ added in v0.6.0
func DetectAddress() (PublicAddress, error)
DetectAddress reads the machine's network cards. Nothing is asked of any outside service, so it works the same behind a tunnel or offline.
type SFTPSocket ¶ added in v0.7.0
type SFTPSocket struct {
// DropIn is the file that holds the port.
DropIn string
// HostKeyDir is the root-owned folder with the SFTP server's host key,
// and User the account whose group may read it. OldKeyDir is where
// earlier versions kept the key, in the SFTP user's own folder.
HostKeyDir string
OldKeyDir string
User string
// Run runs a command and returns what it printed.
Run func(ctx context.Context, name string, args ...string) (string, error)
// contains filtered or unexported fields
}
SFTPSocket controls the SFTP socket. The paths and the command runner are fields so tests can point them elsewhere.
func (*SFTPSocket) EnsureHostKey ¶ added in v0.7.4
func (c *SFTPSocket) EnsureHostKey() (ssh.Signer, error)
EnsureHostKey makes the host key if there is none and returns it. The core calls it at start, so a fresh install has the key before the first connection, and Status calls it again in case the key went missing.
func (*SFTPSocket) Port ¶ added in v0.7.4
func (c *SFTPSocket) Port() (int, error)
Port is the port the socket listens on: the one in the drop-in, or the unit's own when the panel never changed it.
func (*SFTPSocket) SetPort ¶ added in v0.7.0
func (c *SFTPSocket) SetPort(ctx context.Context, port int) error
SetPort makes the socket listen on port. The drop-in first clears the port the unit names, or systemd would listen on both. Nothing happens if the file already says so, so a panel that repeats itself at every start does not drop a connection. If the socket will not start on the new port, most likely because another program has it, the old port is put back so SFTP keeps working where it was.
func (*SFTPSocket) Status ¶ added in v0.7.0
func (c *SFTPSocket) Status(ctx context.Context) (SFTPStatus, error)
Status reports whether the socket is up and the host key's fingerprint. It makes the host key if there is none, so the fingerprint can be shown before anyone has connected.
type SFTPStatus ¶ added in v0.7.0
type SFTPStatus struct {
// Listening is whether the socket is up. The server itself runs only
// while someone is connected.
Listening bool `json:"listening"`
HostKey string `json:"host_key"`
}
SFTPStatus is what the panel learns about the SFTP server.
type SFTPVolumes ¶ added in v0.7.0
type SFTPVolumes struct {
// contains filtered or unexported fields
}
SFTPVolumes is the list of volumes the SFTP user may use, kept in a file so it is there again when the core restarts.
func LoadSFTPVolumes ¶ added in v0.7.0
func LoadSFTPVolumes(path string) (*SFTPVolumes, error)
LoadSFTPVolumes reads the list at path. A missing file is an empty list. A file that cannot be parsed gives an empty list as well, along with the error: the panel tells the core the list again, so a damaged file should not keep the core from starting. SFTP logins find no volume until then.
func (*SFTPVolumes) Has ¶ added in v0.7.0
func (v *SFTPVolumes) Has(name string) bool
Has reports whether the SFTP user may use the volume.
func (*SFTPVolumes) Set ¶ added in v0.7.0
func (v *SFTPVolumes) Set(names []string) error
Set replaces the list and saves it.
type Server ¶
type Server struct {
Engine Engine
Builder Builder
Secrets *secret.Keys
Backups *backup.Dir
Offsite *Offsite
// External holds the loopback ports of databases open to desktop tools.
External *External
// Updater updates Zelie itself; nil where it cannot.
Updater *Updater
Paths engine.Paths
Log *slog.Logger
Allowed peer.Policy
// SFTPUID is the user of the SFTP server, and SFTPVolumes the volumes
// it may use. Without a user there is no such rule to apply.
SFTPUID uint32
SFTPVolumes *SFTPVolumes
// SFTPSocket holds the port and the host key of the SFTP server.
SFTPSocket *SFTPSocket
// Host describes the server; tests replace it.
Host func() (engine.Host, error)
// contains filtered or unexported fields
}
func (*Server) StartExternal ¶
func (s *Server) StartExternal(list []ExternalListener)
StartExternal opens the saved listeners once the server can find containers.
type UpdateStatus ¶ added in v0.2.0
type UpdateStatus struct {
Version string `json:"version"`
Last *update.Result `json:"last,omitempty"`
}
UpdateStatus is the running version and how the last update went.
type Updater ¶ added in v0.2.0
type Updater struct {
// Fetch downloads a release's binary and checks its signature.
Fetch func(ctx context.Context, version string) ([]byte, error)
// Place puts it where the services run from, keeping the old one.
Place func(bin []byte) error
// Start runs the unit that restarts the services and checks them.
Start func(ctx context.Context, from, to string) error
// Revert puts the old binary back after a Start that failed, so the
// next restart does not run a release nothing has checked.
Revert func() error
// Running reports whether that unit runs now.
Running func(ctx context.Context) bool
// Last is the outcome of the last update.
Last func() (update.Result, error)
// Installed reports whether the services run from the installed binary.
Installed func() bool
}
Updater does the parts of an update that touch the machine. Tests replace it.
Source Files
¶
- address.go
- backups.go
- build.go
- client.go
- data.go
- external.go
- files.go
- files_attrs.go
- files_entries.go
- follow.go
- forwards.go
- gamefiles.go
- images.go
- installs.go
- layers.go
- links.go
- offsite.go
- peek.go
- ports.go
- reveal.go
- server.go
- sftpport_guard.go
- sftpsocket.go
- sftpvolumes.go
- update.go
- uploads.go
- volume_backups.go
- volume_copy.go
- volumes.go