store

package
v0.7.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package store keeps the panel's state in a single SQLite file.

Index

Constants

View Source
const (
	SourceImage  = "image"
	SourceGitHub = "github"
	// SourceFiles is an app that runs the files in its volume with the
	// startup command of an egg.
	SourceFiles = "files"
)

App sources.

View Source
const (
	KindApp  = "app"
	KindGame = "game"
)

What an app is.

View Source
const (
	DeployQueued     = "queued"
	DeployBuilding   = "building"
	DeployTesting    = "testing"
	DeployStarting   = "starting"
	DeployInstalling = "installing" // a game server's install container runs
	DeployInstalled  = "installed"  // the install finished; nothing goes live
	DeployLive       = "live"
	DeployFailed     = "failed"
	DeployReplaced   = "replaced" // was live until a newer one took over
	DeploySkipped    = "skipped"  // a newer one came before it started
)

Deployment states. A deployment moves forward through them and ends in one of the last four.

View Source
const (
	CauseManual    = "manual"
	CausePush      = "push"
	CauseRestart   = "restart"   // the live image again, without a build
	CauseRollback  = "rollback"  // an earlier deployment's image
	CauseRecover   = "recover"   // the live image again, after it stopped by itself
	CauseRestore   = "restore"   // the live image again, after a backup was put back
	CauseBackup    = "backup"    // the live image again, after the app was stopped for its backup
	CauseUpdate    = "update"    // what the image's tag points at now; a database is backed up first
	CauseUpgrade   = "upgrade"   // a database's new major version, with its data dumped and loaded
	CauseInstall   = "install"   // a new game server's install container
	CauseReinstall = "reinstall" // the install again, after a backup of the server's files
	CauseClone     = "clone"     // a new server filled with the files of another; Message names it
)

What started a deployment.

View Source
const (
	BackupScheduled = "scheduled"
	BackupManual    = "manual"
	// BackupRestore is the safety backup taken just before a restore.
	BackupRestore = "restore"
	// BackupFound was made elsewhere and found in off-site storage.
	BackupFound = "found"
	// BackupUploaded is a dump from another server that someone uploaded.
	BackupUploaded = "uploaded"
	// BackupUpdate is taken just before a database moves to a new image.
	BackupUpdate = "update"
	// BackupUpgrade is the dump a database's new major version loads.
	BackupUpgrade = "upgrade"
	// BackupReinstall is taken just before a game server's install runs
	// again.
	BackupReinstall = "reinstall"
	// BackupSchedule is made by a task of a game server's schedule.
	BackupSchedule = "schedule"
)

Why a backup was made.

View Source
const (
	BackupRunning = "running"
	BackupDone    = "done"
	BackupFailed  = "failed"
)

Backup states.

View Source
const (
	OffsitePending = "pending"
	OffsiteDone    = "done"
	OffsiteFailed  = "failed"
)

Where a backup's off-site copy is. A backup that is not sent has none.

View Source
const (
	InstallRunning = "installing"
	InstallDone    = "installed"
	InstallFailed  = "failed"
)

Install states of a game server.

View Source
const (
	// ReasonRejoined closes a session when the same player joins again
	// without a leave in between.
	ReasonRejoined = "rejoined"
	// ReasonPanelRestarted closes sessions a stopped server left open.
	ReasonPanelRestarted = "panel restarted"
)
View Source
const (
	TaskCommand = "command"
	TaskPower   = "power"
	TaskBackup  = "backup"
)

Kinds of schedule task.

View Source
const (
	RunRunning = "running"
	RunDone    = "done"
	RunFailed  = "failed"
	RunSkipped = "skipped"
)

How the last run of a schedule went.

View Source
const AnyAddress = "0.0.0.0"

AnyAddress is the ip of an allocation that covers every address of the machine.

View Source
const DefaultSFTPPort = 2222

DefaultSFTPPort is where the SFTP service listens until it is changed. It is Pterodactyl's port too, so a machine that runs Wings may need another.

View Source
const MaxFileFavorites = 50

MaxFileFavorites is how many paths an account may star in one server.

View Source
const ThisNode = 1

ThisNode is the machine Zelie runs on, the only node until there are more.

Variables

View Source
var (
	// ErrWhichAccount means there is more than one administrator, so the
	// reset needs an email.
	ErrWhichAccount = errors.New("there is more than one administrator; name one by email")
	// ErrBadResetToken means the reset link is wrong, used or expired.
	ErrBadResetToken = errors.New("this reset link is not valid")
)
View Source
var (
	// ErrSetupDone means an administrator exists and setup is closed for good.
	ErrSetupDone = errors.New("setup is already complete")
	// ErrBadSetupToken means the setup link is wrong, used or expired.
	ErrBadSetupToken = errors.New("this setup link is not valid; run 'zelie setup-link' on the server for a new one")
)
View Source
var (
	// ErrNotFound means the thing asked for does not exist.
	ErrNotFound = errors.New("not found")
	// ErrLastFactor stops an account from removing its only second factor.
	ErrLastFactor = errors.New("this is the only second step left on the account; add another before removing it")
)
View Source
var ErrExists = errors.New("already exists")

ErrExists is returned when a name or domain is already taken.

View Source
var ErrInUse = errors.New("in use")

ErrInUse means an allocation belongs to a server.

View Source
var ErrTooManyFavorites = errors.New("too many favourites")

ErrTooManyFavorites is returned when an account is at MaxFileFavorites.

Functions

This section is empty.

Types

type Account

type Account struct {
	User
	Password   string
	TOTPSecret []byte // encrypted; nil until an authenticator app is set up
	Passkeys   int
}

Account is a user with what is needed to log them in.

func (Account) HasSecondFactor

func (a Account) HasSecondFactor() bool

HasSecondFactor reports whether the account has an authenticator app or a passkey. Until it does, the panel only lets it set one up.

type Allocation added in v0.6.0

type Allocation struct {
	ID        int64
	NodeID    int64
	IP        string
	Port      int
	AppID     string // empty when no server has it
	CreatedAt time.Time
}

Allocation is a port a node may give to a server. It covers TCP and UDP.

type App

type App struct {
	ID       string
	Source   string
	Image    string // for SourceImage
	Repo     string // owner/name, for SourceGitHub
	Branch   string
	Port     int
	Domain   string
	MemoryMB int64
	CPUs     float64
	// AutoDeploy deploys each push to the branch, for SourceGitHub.
	AutoDeploy bool
	// HealthPath is what the health check asks for, when the app has a
	// domain.
	HealthPath string
	// TestCommand runs the app's tests; empty means none. TestSet is false
	// until it has been decided, by a build's suggestion or by the user.
	TestCommand string
	TestSet     bool
	// Stopped is set when the user stopped the app.
	Stopped bool
	// The user's own commands; empty means what the build chose.
	BuildCommand string
	StartCommand string
	// Detected is what the last build chose.
	Detected Detected
	// RestartPulls makes a restart build the branch's newest commit.
	RestartPulls bool
	// Engine is set for a database: postgres, mariadb or redis, in the
	// major version EngineVersion.
	Engine        string
	EngineVersion string
	// Kind is KindApp or KindGame. A database is a KindApp with an Engine.
	Kind      string
	CreatedAt time.Time
}

App is something Zelie keeps running.

func (App) IsDatabase

func (a App) IsDatabase() bool

IsDatabase reports whether the app is one of Zelie's databases.

func (App) IsFiles added in v0.6.0

func (a App) IsFiles() bool

IsFiles reports whether the app runs the files in its volume.

func (App) IsGame added in v0.6.0

func (a App) IsGame() bool

IsGame reports whether the app is a game server.

func (App) RunSettings added in v0.7.12

func (a App) RunSettings() RunSettings

RunSettings returns the app's current ones.

func (App) RunsEgg added in v0.6.0

func (a App) RunsEgg() bool

RunsEgg reports whether the app is started from an egg: a game server or a files app.

type AuditEntry added in v0.7.10

type AuditEntry struct {
	ID     int64
	At     time.Time
	By     string
	Action string
	Target string
	Detail string
}

AuditEntry is one thing an account did.

type Backup

type Backup struct {
	ID     int64
	AppID  string
	Engine string // what the app was when it was made; empty for volumes
	Reason string
	State  string
	File   string // the core's name for it, once made
	Bytes  int64
	Error  *msg.Msg // why it failed
	// For a backup of volumes: the folders in it, how much its files take
	// and how many changed while they were copied.
	Volumes []string
	Size    int64
	Changed int
	// For an uploaded dump: what was changed so it loads here, by kind.
	Adapted map[string]int

	CreatedAt  time.Time
	FinishedAt time.Time // zero while running
	KeepUntil  time.Time
	RestoredAt time.Time // zero if it was never put back

	// The off-site copy: its state (empty when there is none), why it
	// failed, how often it was tried, when it was sent or is tried
	// again, and until when it is kept.
	Offsite      string
	OffsiteError *msg.Msg
	OffsiteTries int
	OffsiteAt    time.Time
	OffsiteUntil time.Time
	// Local is false once only the off-site copy is left.
	Local bool
}

Backup is one backup, made or tried.

type BackupPlan

type BackupPlan struct {
	AppID    string
	Enabled  bool
	Minute   int // of the day, in the server's time zone
	KeepDays int
	// Stop stops an app for its volume backup instead of copying the
	// files while it runs.
	Stop bool
	// Offsite sends each backup to the off-site storage, when there is
	// one, where it is kept for OffsiteDays.
	Offsite     bool
	OffsiteDays int
}

BackupPlan says when an app is backed up and for how long its backups are kept.

func AppBackupPlan

func AppBackupPlan(app string) BackupPlan

AppBackupPlan is what an app has until its plan is changed: the same hours, but off, since volumes such as game worlds can be large.

func DefaultBackupPlan

func DefaultBackupPlan(app string) BackupPlan

DefaultBackupPlan is what a new database gets: every night at three, kept for a week.

type ChatFilter added in v0.7.10

type ChatFilter struct {
	Player  string
	Channel string
	Search  string
	Before  int64
	Limit   int
}

ChatFilter narrows PlayerChatSearch. Empty fields match everything.

type Deployment

type Deployment struct {
	ID         int64
	AppID      string
	Version    string // a branch until the commit is known
	Image      string
	Cause      string
	Message    string // first line of the pushed commit's message
	Pruned     bool   // its image was deleted
	State      string
	Error      *msg.Msg // why it failed
	CreatedAt  time.Time
	FinishedAt time.Time // zero while in progress
	// Settings are what the app ran with once this deployment went live.
	// Nil for deployments from before they were kept.
	Settings *RunSettings
}

Deployment is one attempt to put a version of an app live.

func (Deployment) ReusesLive added in v0.7.12

func (d Deployment) ReusesLive() bool

ReusesLive reports whether the deployment starts the live version again, as the live version is when it runs, instead of building or pulling one.

type Detected

type Detected struct {
	Builder string `json:"builder,omitempty"` // dockerfile or railpack
	Build   string `json:"build,omitempty"`
	Start   string `json:"start,omitempty"`
}

Detected is how the last build built an app.

type Egg added in v0.6.0

type Egg struct {
	ID         int64
	Name       string
	Source     string // a catalog id or an address
	Raw        []byte
	ImportedAt time.Time
}

Egg is an egg file kept as it was fetched.

type EnvVar

type EnvVar struct {
	Name   string
	Value  string
	Secret bool
}

EnvVar is one environment variable of an app. For a secret one, Value is sealed for the core and the panel cannot read it.

type ExternalAccess

type ExternalAccess struct {
	AppID     string
	Port      int
	CreatedAt time.Time
}

ExternalAccess is a database open to desktop tools on a loopback port.

type GameServer added in v0.6.0

type GameServer struct {
	AppID   string
	EggID   int64
	Image   string // the image the server runs, one the egg offers
	Startup string
	// Variables maps environment variable names to their values.
	Variables    map[string]string
	InstallState string
	// InstallID is the deployment of the last install, whose log has its
	// output; zero before the first one is queued.
	InstallID   int64
	InstalledAt time.Time // zero until an install has finished
	// EULAAcceptedAt is when the game's EULA was accepted; zero until then.
	EULAAcceptedAt time.Time
	// SteamAppID is the app SteamCMD installs for this server, or 0.
	SteamAppID int64
	// SteamAutoUpdate lets the panel update the server once it is empty.
	SteamAutoUpdate bool
}

GameServer is what a game server has besides its app row.

type GitHubApp

type GitHubApp struct {
	AppID         int64
	Slug          string
	Owner         string
	HTMLURL       string
	BaseURL       string
	Key           []byte
	WebhookSecret []byte
	CreatedAt     time.Time
}

GitHubApp is the panel's own GitHub App. Key and WebhookSecret are encrypted with the panel key; the store never sees them in the clear.

type KeptVolume added in v0.3.0

type KeptVolume struct {
	ID      int64
	Name    string
	AppID   string
	Path    string
	LimitMB int64
	Version string // the engine version the files belong to
	KeptAt  time.Time
}

KeptVolume is a database's volume from before an upgrade.

type Link struct {
	AppID, DBID string
	// Prefix starts the names of the variables the app gets, so one app
	// can have several databases.
	Prefix    string
	CreatedAt time.Time
}

Link connects an app to a database.

type Metric added in v0.4.0

type Metric struct {
	AppID        string
	At           time.Time
	MemoryBytes  int64
	CPU          float64 // CPUs, on average
	RxBytes      int64
	TxBytes      int64
	Requests     int64
	ClientErrors int64 // 4xx answers
	ServerErrors int64 // 5xx answers
}

Metric is what an app used in one minute.

type Node added in v0.6.0

type Node struct {
	ID   int64
	Name string
	// PublicAddress is what the administrator says players connect to. It
	// is empty when they left it to Zelie to find one.
	PublicAddress string
	CreatedAt     time.Time
}

Node is a machine that runs servers.

type Passkey

type Passkey struct {
	ID         []byte
	UserID     int64
	Name       string
	Credential []byte // JSON, owned by the WebAuthn code
	CreatedAt  time.Time
	UsedAt     time.Time // zero if never used to log in
}

Passkey is a WebAuthn credential registered to an account.

type Player added in v0.7.10

type Player struct {
	ID          string
	Name        string
	FirstSeen   time.Time
	LastSeen    time.Time
	LastIP      string
	PlaySeconds int64
	Online      bool
}

Player is what is known of one player of a server.

type PlayerBan added in v0.7.10

type PlayerBan struct {
	ID        int64
	PlayerID  string
	Name      string
	Reason    string
	CreatedBy int64 // account id; zero when the account is gone
	By        string
	CreatedAt time.Time
	ExpiresAt time.Time
	LiftedAt  time.Time
	LiftedBy  string
}

PlayerBan is a ban made through the panel. ExpiresAt is zero for a ban that never ends. LiftedAt is zero while it stands; LiftedBy is empty when it ended by itself.

func (PlayerBan) Active added in v0.7.10

func (b PlayerBan) Active(at time.Time) bool

Active says whether the ban holds at the given time.

type PlayerChat added in v0.7.10

type PlayerChat struct {
	ID       int64
	PlayerID string
	Name     string
	Channel  string
	Text     string
	At       time.Time
}

PlayerChat is one chat message.

type PlayerFlags added in v0.7.10

type PlayerFlags struct {
	Banned bool
	Notes  int
}

PlayerFlags is what the lists show next to a player.

type PlayerLink struct {
	PlayerID string
	Name     string
	IP       string
	LastSeen time.Time
}

PlayerLink is a player who connected from an address another one used.

type PlayerNote added in v0.7.10

type PlayerNote struct {
	ID       int64
	PlayerID string
	Tag      string
	Note     string
	By       string
	At       time.Time
}

PlayerNote is what an administrator wrote about a player. By is the account's email, empty once the account is gone.

type PlayerReport added in v0.7.10

type PlayerReport struct {
	ID           int64
	ReporterID   string
	ReporterName string
	TargetID     string
	TargetName   string
	Subject      string
	Message      string
	At           time.Time
}

PlayerReport is one report a player made against another.

type PlayerSession added in v0.7.10

type PlayerSession struct {
	ID       int64
	PlayerID string
	Name     string
	IP       string
	JoinedAt time.Time
	LeftAt   time.Time // zero while the player is in
	Reason   string
}

PlayerSession is one visit.

type PruneResult added in v0.7.10

type PruneResult struct {
	Sessions, Players, Chat, Reports int64
}

PruneResult is how many rows PrunePlayerData removed.

type RestoreRun added in v0.7.14

type RestoreRun struct {
	AppID     string
	BackupID  int64
	StartedAt time.Time
}

RestoreRun is a restore that began and has not ended.

type RunSettings added in v0.7.12

type RunSettings struct {
	StartCommand string  `json:"start_command,omitempty"`
	Port         int     `json:"port"`
	MemoryMB     int64   `json:"memory_mb"`
	CPUs         float64 `json:"cpus"`
	HealthPath   string  `json:"health_path,omitempty"`
}

RunSettings are the settings of an app that shape how its container runs. An app's settings take effect with its next deployment. The live deployment keeps the ones it went live with, so it can start again when a newer one fails.

func (RunSettings) ApplyTo added in v0.7.12

func (r RunSettings) ApplyTo(a App) App

ApplyTo returns a with these settings in place of its own.

type SSHKey added in v0.7.0

type SSHKey struct {
	ID          int64
	UserID      int64
	Name        string
	Fingerprint string
	// PublicKey is the key in the SSH wire format.
	PublicKey []byte
	CreatedAt time.Time
}

SSHKey is a public key of an account, for logging in over SFTP.

type Schedule added in v0.6.0

type Schedule struct {
	ID          int64
	AppID       string
	Name        string
	Cron        string
	OnlyRunning bool
	Enabled     bool
	CreatedAt   time.Time
	// LastSlot is the minute the schedule last fired for; slots up to it
	// are done with.
	LastSlot time.Time
	// LastRun is when the last run started, zero if there was none.
	LastRun   time.Time
	LastState string
	LastError *msg.Msg
	Tasks     []ScheduleTask
}

Schedule runs its tasks in order whenever its cron expression fires.

type ScheduleTask added in v0.6.0

type ScheduleTask struct {
	ID int64
	// Action is TaskCommand, TaskPower or TaskBackup. Data is the console
	// command, or the power action; empty for a backup.
	Action string
	Data   string
	// Delay is how many seconds to wait before the task.
	Delay int
	// KeepGoing runs the tasks after this one even if it fails.
	KeepGoing bool
}

ScheduleTask is one step of a schedule.

type Session

type Session struct {
	Hash        []byte
	UserID      int64
	Verified    bool // the second factor has been checked
	CreatedAt   time.Time
	SeenAt      time.Time
	ExpiresAt   time.Time
	ConfirmedAt time.Time // last time the user proved it was them
	IP          string
	Agent       string
}

Session is a logged-in browser. Hash is the SHA-256 of the cookie value.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is the panel's database.

func Open

func Open(ctx context.Context, path string) (*Store, error)

Open opens or creates the database at path and brings its schema up to date.

func (*Store) AcceptEULA added in v0.6.0

func (s *Store) AcceptEULA(ctx context.Context, appID string, at time.Time) error

AcceptEULA records that the game's EULA was accepted for the server.

func (*Store) AccountByEmail

func (s *Store) AccountByEmail(ctx context.Context, email string) (Account, error)

func (*Store) AccountByID

func (s *Store) AccountByID(ctx context.Context, id int64) (Account, error)

func (*Store) AccountByName added in v0.7.16

func (s *Store) AccountByName(ctx context.Context, app, name string) (Player, error)

AccountByName is PlayerByName among the players the game gave an id of their own. A record keyed by the name alone is a guess at who it is, so it does not show that another account has the name.

func (*Store) AddAllocations added in v0.6.0

func (s *Store) AddAllocations(ctx context.Context, nodeID int64, ip string, ports []int, now time.Time) error

AddAllocations adds ports on one address of a node, all or none. A port that is already in the pool is refused with a *TakenError, and so is one that overlaps it: every address covers each specific one.

func (*Store) AddAudit added in v0.7.10

func (s *Store) AddAudit(ctx context.Context, at time.Time, account int64, app, action, target, detail string) error

AddAudit records what an account did. account is zero for what the panel did on its own, and app is empty for what belongs to no server.

func (*Store) AddEgg added in v0.6.0

func (s *Store) AddEgg(ctx context.Context, name, source string, raw []byte, now time.Time) (Egg, error)

AddEgg stores an egg file. The same file from the same source is stored once, so many servers of one game share a row.

func (*Store) AddFailure added in v0.5.0

func (s *Store) AddFailure(ctx context.Context, kind string, key []byte, at, keepSince time.Time) error

AddFailure records a failed attempt, and forgets those of kind made at keepSince or earlier.

func (*Store) AddFileFavorite added in v0.7.1

func (s *Store) AddFileFavorite(ctx context.Context, userID int64, appID, path string, at time.Time) error

AddFileFavorite stars a path. Starring it again changes nothing.

func (*Store) AddFoundBackup

func (s *Store) AddFoundBackup(ctx context.Context, b Backup) (int64, error)

AddFoundBackup records a backup found in off-site storage, kept there until offsite_until and not here.

func (*Store) AddMetrics added in v0.4.0

func (s *Store) AddMetrics(ctx context.Context, list []Metric) error

AddMetrics saves a minute's readings. A second reading for the same app and minute replaces the first.

func (*Store) AddPasskey

func (s *Store) AddPasskey(ctx context.Context, p Passkey) error

func (*Store) AddPlayerBan added in v0.7.10

func (s *Store) AddPlayerBan(ctx context.Context, app string, b PlayerBan) (int64, error)

AddPlayerBan records a ban and returns its id.

func (*Store) AddPlayerNote added in v0.7.10

func (s *Store) AddPlayerNote(ctx context.Context, app, player, tag, note string, by int64, at time.Time) (int64, error)

AddPlayerNote saves a note and returns its id. by is the account's id.

func (*Store) AddSSHKey added in v0.7.0

func (s *Store) AddSSHKey(ctx context.Context, k SSHKey) (int64, error)

AddSSHKey stores a key. The fingerprint is unique among all accounts, so a key already in use returns ErrExists.

func (*Store) Allocations added in v0.6.0

func (s *Store) Allocations(ctx context.Context, nodeID int64) ([]Allocation, error)

Allocations lists a node's ports by number.

func (*Store) App

func (s *Store) App(ctx context.Context, id string) (App, error)

func (*Store) AppAllocations added in v0.6.0

func (s *Store) AppAllocations(ctx context.Context, appID string) ([]Allocation, error)

AppAllocations lists the ports a server uses.

func (*Store) Apps

func (s *Store) Apps(ctx context.Context) ([]App, error)

func (*Store) AssignAllocations added in v0.6.0

func (s *Store) AssignAllocations(ctx context.Context, appID string, ids []int64) error

AssignAllocations gives the allocations to a server, all or none. One that another server took meanwhile fails with ErrInUse.

func (*Store) Audit added in v0.7.10

func (s *Store) Audit(ctx context.Context, app string, limit int) ([]AuditEntry, error)

Audit lists a server's entries, the newest first.

func (*Store) Backup

func (s *Store) Backup(ctx context.Context, id int64) (Backup, error)

func (*Store) BackupFiles

func (s *Store) BackupFiles(ctx context.Context) (map[string]bool, error)

BackupFiles returns every backup file on record, as app/file.

func (*Store) BackupPlan

func (s *Store) BackupPlan(ctx context.Context, app string) (BackupPlan, error)

BackupPlan returns an app's plan, or ErrNotFound when it has none.

func (*Store) BackupPlans

func (s *Store) BackupPlans(ctx context.Context) ([]BackupPlan, error)

BackupPlans returns every plan.

func (*Store) Backups

func (s *Store) Backups(ctx context.Context, app string) ([]Backup, error)

Backups returns an app's backups, newest first. With app empty, it returns every backup whose app no longer exists.

func (*Store) BanInForce added in v0.7.16

func (s *Store) BanInForce(ctx context.Context, app, player, name string, at time.Time) (bool, error)

BanInForce says whether a ban of the player is in force at the given time. With a name, a ban under another id of that name counts too, whatever the case: a game that bans by name does not tell the two apart.

func (*Store) BeginInstall added in v0.6.0

func (s *Store) BeginInstall(ctx context.Context, appID string) (bool, error)

BeginInstall marks the server as installing, unless it already is. It reports whether it did, so of two requests to install again only one goes ahead.

func (*Store) BeginRestore added in v0.7.14

func (s *Store) BeginRestore(ctx context.Context, app string, backup int64, at time.Time) error

BeginRestore records that a restore has started.

func (*Store) CapPlayerData added in v0.7.16

func (s *Store) CapPlayerData(ctx context.Context, app string) (PruneResult, error)

CapPlayerData deletes a server's finished sessions, chat and reports past the most it keeps, the oldest first, whatever their age. Players are not touched: those over maxPlayers were never recorded.

func (*Store) CheckResetToken added in v0.7.14

func (s *Store) CheckResetToken(ctx context.Context, tokenHash []byte, now time.Time) error

CheckResetToken says whether ResetLogin would take this token, without changing anything, so the caller can refuse before hashing a password.

func (*Store) CheckSetupToken added in v0.7.14

func (s *Store) CheckSetupToken(ctx context.Context, tokenHash []byte, now time.Time) error

CheckSetupToken says what CreateFirstAdmin would answer to this token, without changing anything, so the caller can refuse before the costly work of hashing a password.

func (*Store) ClaimSlot added in v0.6.0

func (s *Store) ClaimSlot(ctx context.Context, id int64, slot time.Time) (bool, error)

ClaimSlot records that the schedule fires for slot, and reports whether it did so first: false means the slot was already handled.

func (*Store) Close

func (s *Store) Close() error

func (*Store) CloseOpenSessions added in v0.7.10

func (s *Store) CloseOpenSessions(ctx context.Context, app string, at time.Time, reason string) error

CloseOpenSessions ends every open session of a server at the given time, for when the server stops: the game prints no leave for players that are still in.

func (*Store) CloseStaleSessions added in v0.7.10

func (s *Store) CloseStaleSessions(ctx context.Context, running []string, reason string) error

CloseStaleSessions ends the open sessions of every server not in running. Nobody saw those players leave, so each session ends at the last moment the player was seen rather than at a guess.

func (*Store) ConfirmSession

func (s *Store) ConfirmSession(ctx context.Context, hash []byte, now time.Time) error

ConfirmSession records that the user proved it was them again.

func (*Store) CountPlayers added in v0.7.10

func (s *Store) CountPlayers(ctx context.Context, app, search string) (int, error)

CountPlayers counts what Players would list without its page.

func (*Store) CreateApp

func (s *Store) CreateApp(ctx context.Context, a App) error

func (*Store) CreateDeployment

func (s *Store) CreateDeployment(ctx context.Context, d Deployment, now time.Time) (int64, error)

CreateDeployment adds d as a queued deployment and returns its id.

func (*Store) CreateFirstAdmin

func (s *Store) CreateFirstAdmin(ctx context.Context, tokenHash []byte, email, password string, now time.Time) (User, error)

CreateFirstAdmin spends the setup token and creates the first administrator. Once it succeeds, setup is closed.

func (*Store) CreateGameServer added in v0.6.0

func (s *Store) CreateGameServer(ctx context.Context, g GameServer) error

CreateGameServer adds the game server data of an app that exists. Its install starts out running: the caller queues it next.

func (s *Store) CreateLink(ctx context.Context, l Link) error

func (*Store) CreateSchedule added in v0.6.0

func (s *Store) CreateSchedule(ctx context.Context, x Schedule) (int64, error)

CreateSchedule adds a schedule and returns its id. Its slots start now: LastSlot is what the caller sets, normally the current minute.

func (*Store) CreateSession

func (s *Store) CreateSession(ctx context.Context, x Session) error

CreateSession adds a session, and forgets those that have expired: reads only skip them, so without this they would stay for good, each with an address and a browser name.

func (*Store) CreateVolume

func (s *Store) CreateVolume(ctx context.Context, v Volume) (Volume, error)

CreateVolume saves a new volume under a new name for the core.

func (*Store) DeleteAllocation added in v0.6.0

func (s *Store) DeleteAllocation(ctx context.Context, nodeID, id int64) error

DeleteAllocation removes a port from a node's pool. One a server uses stays, with ErrInUse.

func (*Store) DeleteApp

func (s *Store) DeleteApp(ctx context.Context, id string) error

DeleteApp removes an app with its variables and deployments.

func (*Store) DeleteBackup

func (s *Store) DeleteBackup(ctx context.Context, id int64) error

func (*Store) DeleteDeployments added in v0.7.12

func (s *Store) DeleteDeployments(ctx context.Context, appID string, ids []int64) error

DeleteDeployments removes deployments of an app that have finished, other than its live one. Their images are not touched.

func (*Store) DeleteGitHubApp

func (s *Store) DeleteGitHubApp(ctx context.Context) error

func (*Store) DeleteKeptVolume added in v0.3.0

func (s *Store) DeleteKeptVolume(ctx context.Context, appID string, id int64) error
func (s *Store) DeleteLink(ctx context.Context, appID, dbID string) error

func (*Store) DeleteOtherSessions

func (s *Store) DeleteOtherSessions(ctx context.Context, userID int64, keep []byte) error

DeleteOtherSessions ends every session of the account except keep.

func (*Store) DeletePasskey

func (s *Store) DeletePasskey(ctx context.Context, userID int64, id []byte) error

DeletePasskey removes a passkey, unless it is the account's last second factor.

func (*Store) DeletePlayerNote added in v0.7.10

func (s *Store) DeletePlayerNote(ctx context.Context, app, player string, id int64) error

DeletePlayerNote removes one of a player's notes, or returns ErrNotFound.

func (*Store) DeleteSSHKey added in v0.7.0

func (s *Store) DeleteSSHKey(ctx context.Context, userID, id int64) error

DeleteSSHKey removes one of an account's keys.

func (*Store) DeleteSchedule added in v0.6.0

func (s *Store) DeleteSchedule(ctx context.Context, id int64) error

func (*Store) DeleteSession

func (s *Store) DeleteSession(ctx context.Context, hash []byte) error

func (*Store) DeleteSteamKey added in v0.7.10

func (s *Store) DeleteSteamKey(ctx context.Context) error

func (*Store) DeleteUserSession

func (s *Store) DeleteUserSession(ctx context.Context, userID int64, hash []byte) error

DeleteUserSession ends one of an account's sessions. The account is part of the query so no one can end another account's session.

func (*Store) DeleteVolume

func (s *Store) DeleteVolume(ctx context.Context, appID string, id int64) error

func (*Store) Deployment

func (s *Store) Deployment(ctx context.Context, appID string, id int64) (Deployment, error)

func (*Store) Deployments

func (s *Store) Deployments(ctx context.Context, appID string, limit int) ([]Deployment, error)

Deployments lists an app's most recent deployments, newest first.

func (*Store) DropOffsiteQueue

func (s *Store) DropOffsiteQueue(ctx context.Context) error

DropOffsiteQueue forgets the backups still waiting to be sent, when there is no longer anywhere to send them.

func (*Store) Egg added in v0.6.0

func (s *Store) Egg(ctx context.Context, id int64) (Egg, error)

Egg returns a stored egg, or ErrNotFound.

func (*Store) EndRestore added in v0.7.14

func (s *Store) EndRestore(ctx context.Context, app string) error

EndRestore records that a restore has ended, however it went.

func (*Store) Env

func (s *Store) Env(ctx context.Context, appID string) ([]EnvVar, error)

func (*Store) ExpiredBackups

func (s *Store) ExpiredBackups(ctx context.Context, now time.Time) ([]Backup, error)

ExpiredBackups returns the backups whose file here is due to go. The newest backup made of an app that still exists is never among them: if backups stop working, the last good one stays.

func (*Store) ExpiredOffsite

func (s *Store) ExpiredOffsite(ctx context.Context, now time.Time) ([]Backup, error)

ExpiredOffsite returns the backups left only off-site whose time is up there too.

func (*Store) ExpiredPlayerBans added in v0.7.10

func (s *Store) ExpiredPlayerBans(ctx context.Context, app string, at time.Time) ([]PlayerBan, error)

ExpiredPlayerBans lists the timed bans that ended by themselves and have not been lifted in the game yet.

func (*Store) ExternalAccess

func (s *Store) ExternalAccess(ctx context.Context, appID string) (ExternalAccess, error)

ExternalAccess returns the database's, or ErrNotFound.

func (*Store) ExternalAccesses

func (s *Store) ExternalAccesses(ctx context.Context) ([]ExternalAccess, error)

ExternalAccesses lists every database open to desktop tools.

func (*Store) FailUnfinished

func (s *Store) FailUnfinished(ctx context.Context, now time.Time) error

FailUnfinished marks deployments that were in progress when the panel stopped as failed. The panel calls it on start.

func (*Store) FailUnfinishedBackups

func (s *Store) FailUnfinishedBackups(ctx context.Context, now time.Time) error

FailUnfinishedBackups marks backups that were running when the panel stopped as failed. The panel calls it on start.

func (*Store) FailUnfinishedInstalls added in v0.6.0

func (s *Store) FailUnfinishedInstalls(ctx context.Context) error

FailUnfinishedInstalls marks installs that were running when the panel stopped as failed. The panel calls it on start.

func (*Store) FailUnfinishedRuns added in v0.6.0

func (s *Store) FailUnfinishedRuns(ctx context.Context) error

FailUnfinishedRuns marks runs that were going when the panel stopped as failed. The panel calls it on start.

func (*Store) Failures added in v0.5.0

func (s *Store) Failures(ctx context.Context, kind string, key []byte, since time.Time) (int, time.Time, error)

Failures counts the failed attempts of kind and key after a time, and returns when the oldest of them was.

func (*Store) FileFavorites added in v0.7.1

func (s *Store) FileFavorites(ctx context.Context, userID int64, appID string) ([]string, error)

FileFavorites lists an account's starred paths in a server, oldest first.

func (*Store) FinishBackup

func (s *Store) FinishBackup(ctx context.Context, id int64, file string, bytes int64, failure *msg.Msg, at time.Time) error

FinishBackup records how a backup ended: with a file, or with why not.

func (*Store) FinishRun added in v0.6.0

func (s *Store) FinishRun(ctx context.Context, id int64, state string, failure *msg.Msg, at time.Time) error

FinishRun records how a run ended. A skipped run also sets when it was.

func (*Store) FirstDelivery

func (s *Store) FirstDelivery(ctx context.Context, id string, now time.Time) (bool, error)

FirstDelivery records a webhook delivery id and reports whether it is new.

func (*Store) GameServer added in v0.6.0

func (s *Store) GameServer(ctx context.Context, appID string) (GameServer, error)

GameServer returns the game server data of an app, or ErrNotFound.

func (*Store) GameServers added in v0.6.0

func (s *Store) GameServers(ctx context.Context) ([]GameServer, error)

GameServers lists every game server by app id.

func (*Store) GitHubApp

func (s *Store) GitHubApp(ctx context.Context) (GitHubApp, error)

func (*Store) GoLive

func (s *Store) GoLive(ctx context.Context, d Deployment, now time.Time) error

GoLive makes d the app's live deployment and marks the one before it replaced, in one step.

func (*Store) HasExpirable added in v0.7.14

func (s *Store) HasExpirable(ctx context.Context) (bool, error)

HasExpirable reports whether some backup is one that ExpiredBackups or ExpiredOffsite returns once its time is up. Without one there is nothing for the backup clock to do. A backup that is running counts, since the one it replaces as the newest may be due when it ends.

func (*Store) HasNewer

func (s *Store) HasNewer(ctx context.Context, d Deployment) (bool, error)

HasNewer reports whether the app has a deployment created after d that makes d pointless. A newer restart of the live version does not for a deployment that builds a new one: that deployment still has to run, and the restart then restarts what it made live.

func (*Store) HasTimedBans added in v0.7.10

func (s *Store) HasTimedBans(ctx context.Context, app string) (bool, error)

HasTimedBans says whether the server has a ban that ends on its own and has not been lifted, which is when someone has to watch the clock.

func (*Store) HoldBackup added in v0.7.14

func (s *Store) HoldBackup(ctx context.Context, id int64, until time.Time) error

HoldBackup keeps a backup at least until the time given. The newest backup of an app is kept only while it is the newest, so one that is about to be restored is held, or the safety backup taken first would end that.

func (*Store) Images

func (s *Store) Images(ctx context.Context) ([]string, error)

Images lists every image an app or a kept deployment refers to.

func (*Store) KeepVolume added in v0.3.0

func (s *Store) KeepVolume(ctx context.Context, v Volume, version string, now time.Time) (KeptVolume, error)

KeepVolume takes v off its app and keeps it as the data of version.

func (*Store) KeptVolumes added in v0.3.0

func (s *Store) KeptVolumes(ctx context.Context, appID string) ([]KeptVolume, error)

KeptVolumes lists an app's kept volumes, newest first; appID "" lists every app's.

func (*Store) LiftPlayerBan added in v0.7.10

func (s *Store) LiftPlayerBan(ctx context.Context, app string, id, by int64, at time.Time) (bool, error)

LiftPlayerBan ends a ban. by is the account's id, or zero when the ban ran out. It reports whether this call ended it: a ban that was lifted already stays as it was.

func (s *Store) Links(ctx context.Context, appID, dbID string) ([]Link, error)

Links returns the databases an app is linked to, or with appID empty, the apps linked to the database dbID.

func (*Store) LiveDeployment

func (s *Store) LiveDeployment(ctx context.Context, appID string) (Deployment, error)

LiveDeployment returns the deployment serving an app, if any.

func (*Store) LiveDeployments added in v0.3.0

func (s *Store) LiveDeployments(ctx context.Context) ([]Deployment, error)

LiveDeployments returns the live deployment of every app.

func (*Store) Metrics added in v0.4.0

func (s *Store) Metrics(ctx context.Context, appID string, since time.Time) ([]Metric, error)

Metrics returns an app's readings since a time, oldest first.

func (*Store) MoveFileFavorites added in v0.7.1

func (s *Store) MoveFileFavorites(ctx context.Context, appID, from, to string) error

MoveFileFavorites follows a rename for every account: the path and anything below it changes to sit under the new name. A star whose new path is already starred is left where it was.

func (*Store) Node added in v0.6.0

func (s *Store) Node(ctx context.Context, id int64) (Node, error)

Node returns the node, or ErrNotFound.

func (*Store) OffsiteDue

func (s *Store) OffsiteDue(ctx context.Context, now time.Time) ([]Backup, error)

OffsiteDue returns the backups to send now, oldest first.

func (*Store) OffsiteFailedAt

func (s *Store) OffsiteFailedAt(ctx context.Context, id int64, failure msg.Msg, tries int, next time.Time) error

OffsiteFailedAt records a failed send, to be tried again at next.

func (*Store) OffsiteSent

func (s *Store) OffsiteSent(ctx context.Context, id int64, at time.Time) error

OffsiteSent records that a backup's copy is off-site.

func (*Store) OffsiteWaiting added in v0.7.14

func (s *Store) OffsiteWaiting(ctx context.Context, never time.Time) (bool, error)

OffsiteWaiting reports whether a backup is waiting to be sent, or to be sent again, at a time before never.

func (*Store) Passkeys

func (s *Store) Passkeys(ctx context.Context, userID int64) ([]Passkey, error)

func (*Store) PinImage added in v0.7.14

func (s *Store) PinImage(ctx context.Context, appID, tag, pinned string) (bool, error)

PinImage swaps the tag an app started from for the build it ran, unless the app's image was changed meanwhile. It reports whether it did.

func (*Store) Player added in v0.7.10

func (s *Store) Player(ctx context.Context, app, id string) (Player, error)

Player returns one player, or ErrNotFound.

func (*Store) PlayerBan added in v0.7.10

func (s *Store) PlayerBan(ctx context.Context, app string, id int64) (PlayerBan, error)

PlayerBan returns one ban of the server, or ErrNotFound.

func (*Store) PlayerBans added in v0.7.10

func (s *Store) PlayerBans(ctx context.Context, app, player string, all bool, at time.Time) ([]PlayerBan, error)

PlayerBans lists a server's bans, the newest first. Only those in force at the given time are listed unless all is set. A player narrows it to one.

func (*Store) PlayerByName added in v0.7.10

func (s *Store) PlayerByName(ctx context.Context, app, name string) (Player, error)

PlayerByName finds the player of that name seen last, for a console that only says names. It returns ErrNotFound for a name nobody had.

func (*Store) PlayerChat added in v0.7.10

func (s *Store) PlayerChat(ctx context.Context, app, player string, beforeID int64, limit int) ([]PlayerChat, error)

PlayerChat lists chat, the newest first: a server's, or one player's when player is not empty. beforeID, when not zero, returns only messages older than that one, which is how the next page is asked for.

func (*Store) PlayerFlagsFor added in v0.7.10

func (s *Store) PlayerFlagsFor(ctx context.Context, app string, ids []string, at time.Time) (map[string]PlayerFlags, error)

PlayerFlagsFor says which of the players are banned at the given time and how many notes each has. Players with neither are left out of the result.

func (*Store) PlayerLogPos added in v0.7.16

func (s *Store) PlayerLogPos(ctx context.Context, app string) (container string, lines int, err error)

PlayerLogPos returns the container whose console the panel last recorded players from, and how many of its lines it was through, or ErrNotFound. A position older than the newest player on record is not returned: whoever recorded since did not move it, as a version rolled back to after an update would not, so the lines after it may be recorded already.

func (*Store) PlayerNotes added in v0.7.10

func (s *Store) PlayerNotes(ctx context.Context, app, player string) ([]PlayerNote, error)

PlayerNotes lists a player's notes, the newest first.

func (*Store) PlayerReports added in v0.7.10

func (s *Store) PlayerReports(ctx context.Context, app, target string, limit int) ([]PlayerReport, error)

PlayerReports lists reports, the newest first: those against one player, or every server's when target is empty.

func (*Store) PlayerSessions added in v0.7.10

func (s *Store) PlayerSessions(ctx context.Context, app, player string, limit int) ([]PlayerSession, error)

PlayerSessions lists a player's visits, the newest first.

func (*Store) Players added in v0.7.10

func (s *Store) Players(ctx context.Context, app, search string, limit, offset int) ([]Player, error)

Players lists a server's players, the ones seen last first. A search matches part of a name, the start of an address, or a whole id.

func (*Store) PlayersSharingIP added in v0.7.10

func (s *Store) PlayersSharingIP(ctx context.Context, app, player string, limit int) ([]PlayerLink, error)

PlayersSharingIP lists the other players who connected from an address this player used, each with the address they shared, the ones seen last first.

func (*Store) PruneMetrics added in v0.4.0

func (s *Store) PruneMetrics(ctx context.Context, before time.Time) error

PruneMetrics deletes the readings from before a time.

func (*Store) PrunePlayerData added in v0.7.10

func (s *Store) PrunePlayerData(ctx context.Context, app string, sessionsBefore, chatBefore, reportsBefore time.Time) (PruneResult, error)

PrunePlayerData deletes what is older than the cutoffs: finished sessions and players not seen since sessionsBefore, chat before chatBefore and reports before reportsBefore. An empty app means every server. A player with a note or a ban is kept, and so is one who is in.

func (*Store) PushTargets

func (s *Store) PushTargets(ctx context.Context, repo, branch string) ([]App, error)

PushTargets lists the apps that deploy pushes to a repository's branch. GitHub names are case-insensitive.

func (*Store) RecordPlayerEvents added in v0.7.10

func (s *Store) RecordPlayerEvents(ctx context.Context, app string, events []players.Event) error

RecordPlayerEvents stores what a parser read, in order, in one transaction. Events with no time are stamped now, and near misses are not stored. A leave of a player with no record is not stored either.

func (*Store) RecordPlayerEventsAt added in v0.7.16

func (s *Store) RecordPlayerEventsAt(ctx context.Context, app string, events []players.Event, container string, lines int) (dropped int, err error)

RecordPlayerEventsAt stores events like RecordPlayerEvents and, in the same transaction, notes that the console of container has been recorded up to line lines. With no container it notes nothing. It returns how many events it left out because they were of a player the server could not take up, with maxPlayers on record or maxOpenSessions in.

func (*Store) Recoveries added in v0.4.0

func (s *Store) Recoveries(ctx context.Context, appID string, since time.Time) (int, error)

Recoveries counts the times Zelie brought an app back up after it stopped by itself, since a time.

func (*Store) RecoveryCodesLeft

func (s *Store) RecoveryCodesLeft(ctx context.Context, userID int64) (int, error)

RecoveryCodesLeft counts the account's unused recovery codes.

func (*Store) RecoverySavedAt

func (s *Store) RecoverySavedAt(ctx context.Context) (time.Time, error)

RecoverySavedAt returns when the backup recovery file was last saved, or the zero time.

func (*Store) RemoveExternalAccess

func (s *Store) RemoveExternalAccess(ctx context.Context, appID string) error

func (*Store) RemoveFileFavorite added in v0.7.1

func (s *Store) RemoveFileFavorite(ctx context.Context, userID int64, appID, path string) error

RemoveFileFavorite unstars a path. A path that was not starred is fine.

func (*Store) RemoveTOTP

func (s *Store) RemoveTOTP(ctx context.Context, userID int64) error

RemoveTOTP turns off the authenticator app, unless the account has no passkey to fall back on.

func (*Store) ReplaceGamePorts added in v0.7.0

func (s *Store) ReplaceGamePorts(ctx context.Context, nodeID int64, appID string, ids []int64, port int, variables map[string]string) error

ReplaceGamePorts makes ids the ports a server holds, at once: the ones it no longer lists go back to the pool and the new ones are taken. port is the server's main port, and variables the game server's values with the port variables changed. A port another server holds fails with ErrInUse, one that is not on the node with ErrNotFound, and nothing changes then.

func (*Store) ResetAllFailures added in v0.5.0

func (s *Store) ResetAllFailures(ctx context.Context) error

ResetAllFailures forgets every failed attempt, for an owner who got back in from the server.

func (*Store) ResetFailures added in v0.5.0

func (s *Store) ResetFailures(ctx context.Context, kind string, key []byte) error

ResetFailures forgets the failed attempts of kind and key.

func (*Store) ResetLogin added in v0.5.0

func (s *Store) ResetLogin(ctx context.Context, tokenHash []byte, password string, now time.Time) (User, error)

ResetLogin spends the reset token: the account gets password, loses its second factors, SSH keys and sessions, and every login limit is lifted. The keys go too: one added by whoever had the account would otherwise keep opening SFTP after the owner is back.

func (*Store) SFTPPassword added in v0.7.0

func (s *Store) SFTPPassword(ctx context.Context, appID string) (string, error)

SFTPPassword returns the hash of a game server's SFTP password, or "" when it has none.

func (*Store) SFTPPort added in v0.7.0

func (s *Store) SFTPPort(ctx context.Context, nodeID int64) (int, error)

SFTPPort is the port the SFTP service listens on for a node.

func (*Store) SSHKeyOwner added in v0.7.0

func (s *Store) SSHKeyOwner(ctx context.Context, fingerprint string) (Account, SSHKey, error)

SSHKeyOwner finds the account a key belongs to, and the key.

func (*Store) SSHKeys added in v0.7.0

func (s *Store) SSHKeys(ctx context.Context, userID int64) ([]SSHKey, error)

SSHKeys lists an account's keys, oldest first.

func (*Store) Schedule added in v0.6.0

func (s *Store) Schedule(ctx context.Context, id int64) (Schedule, error)

Schedule returns one schedule.

func (*Store) Schedules added in v0.6.0

func (s *Store) Schedules(ctx context.Context, app string) ([]Schedule, error)

Schedules returns a server's schedules, oldest first. An empty app id returns every schedule.

func (*Store) SearchPlayerChat added in v0.7.10

func (s *Store) SearchPlayerChat(ctx context.Context, app string, f ChatFilter) ([]PlayerChat, error)

SearchPlayerChat lists chat the way PlayerChat does, narrowed by channel and by part of the text or of the sender's name.

func (*Store) SendOffsite

func (s *Store) SendOffsite(ctx context.Context, id int64, until time.Time) error

SendOffsite marks a backup to be sent now, and kept off-site until.

func (*Store) Session

func (s *Store) Session(ctx context.Context, hash []byte, now time.Time) (Session, error)

Session returns the session with this hash if it has not expired.

func (*Store) Sessions

func (s *Store) Sessions(ctx context.Context, userID int64, now time.Time) ([]Session, error)

Sessions lists an account's unexpired sessions, most recently used first.

func (*Store) SetAdapted

func (s *Store) SetAdapted(ctx context.Context, id int64, adapted map[string]int) error

SetAdapted records what an uploaded dump needed changed to load here.

func (*Store) SetBackupContents

func (s *Store) SetBackupContents(ctx context.Context, id int64, volumes []string, size int64, changed int) error

SetBackupContents records what a volume backup holds.

func (*Store) SetBackupPlan

func (s *Store) SetBackupPlan(ctx context.Context, p BackupPlan) error

SetBackupPlan saves a plan. Backups already made are kept for the new numbers of days, counted from when each was made.

func (*Store) SetDeployment

func (s *Store) SetDeployment(ctx context.Context, d Deployment, now time.Time) error

SetDeployment records progress. Ending states also set the finish time.

func (*Store) SetDeploymentImage added in v0.3.0

func (s *Store) SetDeploymentImage(ctx context.Context, id int64, image string) error

SetDeploymentImage records the image a deployment runs.

func (*Store) SetDetected

func (s *Store) SetDetected(ctx context.Context, appID string, d Detected) error

SetDetected records how the last build built the app.

func (*Store) SetEngineVersion added in v0.3.0

func (s *Store) SetEngineVersion(ctx context.Context, appID, image, version string) error

SetEngineVersion moves a database to another version of its engine.

func (*Store) SetEnv

func (s *Store) SetEnv(ctx context.Context, appID string, vars []EnvVar) error

SetEnv replaces all of an app's variables.

func (*Store) SetExternalAccess

func (s *Store) SetExternalAccess(ctx context.Context, x ExternalAccess) error

SetExternalAccess saves the database's port. ErrExists means another database has it.

func (*Store) SetGameSettings added in v0.6.0

func (s *Store) SetGameSettings(ctx context.Context, appID, image, startup string, variables map[string]string) error

SetGameSettings records the image, the startup command and the variable values a game server starts with from now on.

func (*Store) SetGitHubApp

func (s *Store) SetGitHubApp(ctx context.Context, g GitHubApp) error

SetGitHubApp saves the App, replacing the one before, if any.

func (*Store) SetImage added in v0.7.14

func (s *Store) SetImage(ctx context.Context, appID, image string) error

SetImage points an app at another image and leaves its other settings as they are. UpdateApp would write all of them back from whatever copy of the app the caller holds, which may be older than a change made meanwhile.

func (*Store) SetInstall added in v0.6.0

func (s *Store) SetInstall(ctx context.Context, appID, state string, deployment int64, installed time.Time) error

SetInstall records how an install is going. deployment is the one whose log has its output; installed is when it finished successfully.

func (*Store) SetLimits added in v0.7.14

func (s *Store) SetLimits(ctx context.Context, appID string, memoryMB int64, cpus float64) error

SetLimits changes how much memory and how many CPUs the app gets, and nothing else about it.

func (*Store) SetLocal

func (s *Store) SetLocal(ctx context.Context, id int64, local bool, keep time.Time) error

SetLocal records whether a backup's file is here. One brought back from off-site is kept here until keep.

func (*Store) SetPassword

func (s *Store) SetPassword(ctx context.Context, userID int64, hash string) error

SetPassword replaces the account's password hash.

func (*Store) SetPlayerLogPos added in v0.7.16

func (s *Store) SetPlayerLogPos(ctx context.Context, app, container string, lines int) error

SetPlayerLogPos notes that the console of container has been recorded up to line lines.

func (*Store) SetPruned

func (s *Store) SetPruned(ctx context.Context, appID, image string) error

SetPruned records that an image was deleted, for every deployment that used it.

func (*Store) SetPublicAddress added in v0.6.0

func (s *Store) SetPublicAddress(ctx context.Context, id int64, address string) error

SetPublicAddress sets the address players use for a node's servers. An empty one goes back to the detected address.

func (*Store) SetRecoveryCodes

func (s *Store) SetRecoveryCodes(ctx context.Context, userID int64, hashes [][]byte) error

SetRecoveryCodes replaces the account's recovery codes.

func (*Store) SetRecoverySaved

func (s *Store) SetRecoverySaved(ctx context.Context, at time.Time) error

func (*Store) SetResetToken added in v0.5.0

func (s *Store) SetResetToken(ctx context.Context, email string, hash []byte, expires time.Time) (User, error)

SetResetToken replaces the reset token with one for the account with email, or for the only administrator when email is empty.

func (*Store) SetRestored

func (s *Store) SetRestored(ctx context.Context, id int64, at time.Time) error

SetRestored records that a backup was put back.

func (*Store) SetSFTPPassword added in v0.7.0

func (s *Store) SetSFTPPassword(ctx context.Context, appID, hash string, at time.Time) error

SetSFTPPassword replaces a server's SFTP password hash. An empty hash removes the password.

func (*Store) SetSFTPPort added in v0.7.0

func (s *Store) SetSFTPPort(ctx context.Context, nodeID int64, port int) error

SetSFTPPort changes the port the SFTP service listens on.

func (*Store) SetSetupToken

func (s *Store) SetSetupToken(ctx context.Context, hash []byte, expires time.Time) error

SetSetupToken replaces the setup token. Only the hash of the token is kept.

func (*Store) SetSteamAppID added in v0.6.0

func (s *Store) SetSteamAppID(ctx context.Context, appID string, steamApp int64) error

SetSteamAppID records the Steam app of a game server found in its egg.

func (*Store) SetSteamAutoUpdate added in v0.6.0

func (s *Store) SetSteamAutoUpdate(ctx context.Context, appID string, on bool) error

SetSteamAutoUpdate turns updating a game server when it is empty on or off.

func (*Store) SetSteamKey added in v0.7.10

func (s *Store) SetSteamKey(ctx context.Context, sealed []byte) error

SetSteamKey saves the sealed key, replacing the one before.

func (*Store) SetStopped

func (s *Store) SetStopped(ctx context.Context, appID string, stopped bool) error

SetStopped records whether the user stopped the app.

func (*Store) SetTOTP

func (s *Store) SetTOTP(ctx context.Context, userID int64, secret []byte, step int64) error

SetTOTP stores an encrypted authenticator secret. step is the time step of the code that confirmed it, which may not be used again.

func (*Store) SettledOn added in v0.7.14

func (s *Store) SettledOn(ctx context.Context, appID string, live int64) (bool, error)

SettledOn reports whether the user wants the app up, with deployment live serving it and no newer one on its way to replace it. It looks in one statement, so a deployment cannot go live between the parts.

func (*Store) SetupOpen

func (s *Store) SetupOpen(ctx context.Context) (bool, error)

SetupOpen reports whether the panel still has no users.

func (*Store) StartBackup

func (s *Store) StartBackup(ctx context.Context, b Backup) (int64, error)

StartBackup records a backup that is about to be made and returns its id.

func (*Store) StartRun added in v0.6.0

func (s *Store) StartRun(ctx context.Context, id int64, at time.Time) error

StartRun records that a run has begun.

func (*Store) SteamKey added in v0.7.10

func (s *Store) SteamKey(ctx context.Context) ([]byte, error)

SteamKey returns the sealed Steam Web API key, or ErrNotFound.

func (*Store) SuggestTest

func (s *Store) SuggestTest(ctx context.Context, appID, command string) (bool, error)

SuggestTest stores a build's suggested test command, unless one was decided already. It reports whether it was stored.

func (*Store) TakeInterruptedRestores added in v0.7.14

func (s *Store) TakeInterruptedRestores(ctx context.Context) ([]RestoreRun, error)

TakeInterruptedRestores returns the restores that never ended, and forgets them. The panel calls it on start, when none can be running.

func (*Store) TouchSession

func (s *Store) TouchSession(ctx context.Context, hash []byte, seen, expires time.Time) error

TouchSession records activity and moves the expiry.

func (*Store) UnassignAllocations added in v0.6.0

func (s *Store) UnassignAllocations(ctx context.Context, appID string) error

UnassignAllocations takes every port back from a server. Deleting the server does the same.

func (*Store) UnkeepVolume added in v0.3.0

func (s *Store) UnkeepVolume(ctx context.Context, k KeptVolume, now time.Time) (Volume, error)

UnkeepVolume gives a kept volume back to its app, which must have no other volume at its path.

func (*Store) Unpruned

func (s *Store) Unpruned(ctx context.Context, appID string) ([]Deployment, error)

Unpruned lists the app's deployments that still have an image, newest first.

func (*Store) UpdateApp

func (s *Store) UpdateApp(ctx context.Context, a App) error

UpdateApp saves everything about an app except its id, source and creation time.

func (s *Store) UpdateLink(ctx context.Context, l Link) error

func (*Store) UpdatePasskey

func (s *Store) UpdatePasskey(ctx context.Context, id, credential []byte, used time.Time) error

UpdatePasskey saves the credential after a login, which carries the authenticator's new signature counter.

func (*Store) UpdateSchedule added in v0.6.0

func (s *Store) UpdateSchedule(ctx context.Context, x Schedule) error

UpdateSchedule replaces a schedule's settings and tasks. LastSlot moves too, so a change never fires for a minute that has passed.

func (*Store) UpdateVolume

func (s *Store) UpdateVolume(ctx context.Context, v Volume) error

UpdateVolume changes where the app sees a volume and how large it may grow.

func (*Store) UseRecoveryCode

func (s *Store) UseRecoveryCode(ctx context.Context, userID int64, hash []byte) (bool, error)

UseRecoveryCode spends a recovery code. It reports false if the code is wrong or already used.

func (*Store) UseTOTPStep

func (s *Store) UseTOTPStep(ctx context.Context, userID, step int64) (bool, error)

UseTOTPStep records that a code from this time step was used. It fails if a code from the same or a later step was used before, which stops a code that was seen over someone's shoulder from being replayed.

func (*Store) VerifySession

func (s *Store) VerifySession(ctx context.Context, hash []byte, now, expires time.Time) error

VerifySession marks the second factor as checked. Finishing a login also counts as confirming.

func (*Store) Volumes

func (s *Store) Volumes(ctx context.Context, appID string) ([]Volume, error)

Volumes returns an app's volumes, oldest first. An empty appID returns every app's.

type TakenError added in v0.6.0

type TakenError struct{ Port int }

TakenError says which port of a new range clashes with an allocation already there. It matches ErrExists.

func (*TakenError) Error added in v0.6.0

func (e *TakenError) Error() string

func (*TakenError) Is added in v0.6.0

func (e *TakenError) Is(target error) bool

type User

type User struct {
	ID    int64
	Email string
	Admin bool
}

User is a panel account.

type Volume

type Volume struct {
	ID        int64
	Name      string // the core's name for it, set when it is created
	AppID     string
	Path      string // where the app sees it
	LimitMB   int64
	CreatedAt time.Time
}

Volume is a directory an app keeps between deployments.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL