Documentation
¶
Overview ¶
Package serverinfo backs the read-only "Server" tab: it sizes Mooring's own on-disk footprint, lists release artifacts for cleanup, and serves an allow-listed, read-only file view. Everything here is deliberately bounded and fail-closed — it is a LOOK-but-don't-break tool. The only mutation any of it performs is deleting an OLD downloaded mooring *.deb (DebManager), which the web layer gates behind password+TOTP re-auth.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned for an unknown root name or a missing path. ErrNotFound = errors.New("serverinfo: not found") // ErrDenied is returned for anything outside an allow-listed root, anything // under a denied prefix, or a traversal/symlink-escape attempt. ErrDenied = errors.New("serverinfo: denied") // ErrTooBig is returned when a file exceeds the read cap. ErrTooBig = errors.New("serverinfo: file too large to view") )
var ErrNotADeb = errors.New("serverinfo: not a mooring .deb")
ErrNotADeb is returned when a delete target isn't a recognized Mooring .deb.
var ErrRunningDeb = errors.New("serverinfo: refusing to delete the running version")
ErrRunningDeb is returned when a delete target is the currently-running version.
Functions ¶
func DeleteDeb ¶
DeleteDeb removes one Mooring .deb from dir. It is intentionally narrow: name must be a bare filename (no path separators) matching debRe exactly, must not be the running version, and the resolved file must be a regular file located directly in dir (re-checked after symlink resolution so a symlinked name can't escape). The web layer additionally gates this behind password+TOTP re-auth.
Types ¶
type Deb ¶
type Deb struct {
Name string
Version string
Arch string
Size uint64
Mod time.Time
Running bool // version matches the running binary → never deletable
}
Deb is one Mooring release package found in the configured cache dir.
type FileBrowser ¶
type FileBrowser struct {
// contains filtered or unexported fields
}
FileBrowser serves an allow-listed, read-only view of the filesystem. Two independent gates apply to EVERY path, after resolving symlinks on the final target: (1) it must stay within one declared root; (2) it must not fall under any denied prefix (secrets, keys, the DB, the config). The deny list wins.
func NewFileBrowser ¶
func NewFileBrowser(roots []Root, deny []string, maxList int, maxRead int64) *FileBrowser
NewFileBrowser canonicalizes the given roots and denied prefixes (resolving symlinks so the containment checks compare real paths). Roots that don't exist or resolve under a denied prefix are dropped (fail-closed). With no usable roots the browser lists/reads nothing.
func (*FileBrowser) Enabled ¶
func (b *FileBrowser) Enabled() bool
Enabled reports whether any root is browsable.
func (*FileBrowser) List ¶
func (b *FileBrowser) List(rootName, rel string) ([]Entry, error)
List returns the children of rel within the named root (rel "" = the root).
func (*FileBrowser) Read ¶
func (b *FileBrowser) Read(rootName, rel string) (content []byte, binary bool, err error)
Read returns a regular file's contents, capped at maxRead. binary=true (with no content) when the file looks binary, so the UI can refuse to render it inline.
func (*FileBrowser) Roots ¶
func (b *FileBrowser) Roots() []Root
Roots returns the usable allow-listed roots (for the UI's root picker).
type Footprint ¶
type Footprint struct {
At time.Time
Groups []Usage
Total uint64
Files int
Partial bool // a group's walk hit the budget/timeout and may undercount
}
Footprint is Mooring's measured on-disk usage, grouped by purpose, plus the wall-clock time the measurement took (so the UI can warn if it's getting slow).
func MeasureFootprint ¶
MeasureFootprint sizes each target subtree. It is intended to run on the slow monitor cadence (NOT per request) because a WalkDir over large git stores can be slow; a per-target deadline (derived from ctx) keeps one huge tree from stalling the whole measurement. Missing directories contribute zero (not an error) — Mooring creates them lazily. A walk that trips the context budget marks the result Partial rather than failing.
type Root ¶
type Root struct {
Name string // stable key used in the UI + URL (e.g. "logs")
Path string // absolute, symlink-resolved root directory
}
Root is one allow-listed directory the operator may browse, read-only.