system

package
v0.7.0-rc.12 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirSize

func DirSize(path string) string

DirSize measures the disk space a directory tree uses, with du, and formats it for the screen, because the helper sends it as text. Root only, because the data directories it is used on belong to service users. The unprivileged status screen gets the LND size through the helper's dir-size operation (which calls this as root) and the Bitcoin size from bitcoind's own RPC. It never calls this directly.

func DownloadRequireTor

func DownloadRequireTor(url, dest string) error

DownloadRequireTor fetches a URL and fails if torsocks is unavailable. It makes up to three attempts, with two-second gaps. Tool-specific limits apply within each attempt. The wget path has no overall deadline.

func IsServiceActive

func IsServiceActive(name string) bool

func ParseSourceIP

func ParseSourceIP(routeOutput string) string

ParseSourceIP extracts the source IP from "ip route get" output. Exported for testing.

func ParseUnitProperties

func ParseUnitProperties(out string) map[string]map[string]string

ParseUnitProperties reads the output of systemctl show for several units, one block of Key=value lines per unit, blocks separated by an empty line. A block without an Id is left out.

func PublicIPv4

func PublicIPv4() string

PublicIPv4 returns the server's public IPv4 address. Uses the kernel routing table (no network call) and caches the result. Only relevant in hybrid (clearnet+tor) P2P mode.

func ReadFileRoot

func ReadFileRoot(path string) ([]byte, error)

ReadFileRoot requires the process to be root and returns os.ReadFile's result, preserving errors for os.IsNotExist checks. Ordinary unprivileged TUI reads use staged files. Separate helper operations can refresh privileged evidence.

func ReadPublicIPv4

func ReadPublicIPv4(ctx context.Context) (string, error)

func ReadRebootRequired

func ReadRebootRequired() (bool, error)

func ReadServiceActive

func ReadServiceActive(ctx context.Context, name string) (bool, error)

ReadServiceActive separates an inactive unit from a failed systemd query.

func ReadServiceState

func ReadServiceState(ctx context.Context, name string) (string, error)

ReadServiceState retains transitional states for mutation postconditions.

func ReadUnitProperties

func ReadUnitProperties(ctx context.Context, units []string, properties ...string) (map[string]map[string]string, error)

ReadUnitProperties reads systemd's record of the given units, which every account can read. The result is keyed by unit name.

func Run

func Run(name string, args ...string) error

Run executes a command and returns an error with output on failure.

func RunCombinedOutput

func RunCombinedOutput(name string, args ...string) (string, error)

RunCombinedOutput executes a command and returns combined stdout+stderr. Used for GPG commands which write status to stderr.

func RunOutput

func RunOutput(name string, args ...string) (string, error)

RunOutput returns trimmed stdout on success and discards output on error.

func RunOutputWithTimeout

func RunOutputWithTimeout(timeout time.Duration, name string, args ...string) (string, error)

RunOutputWithTimeout returns trimmed stdout on success using its own timeout. It does not accept a caller context. Output is discarded on error. Expiry kills the command. A child process that still holds the output then delays the return by at most commandWaitDelay. A command that exits but leaves a child holding its output or error stream for longer than that fails, and its output is discarded.

func RunRoot

func RunRoot(name string, args ...string) error

RunRoot requires the process to be root, then executes the command directly.

func RunRootCombinedOutput

func RunRootCombinedOutput(name string, args ...string) (string, error)

RunRootCombinedOutput requires root and returns combined stdout and stderr, trimmed on success and untrimmed on command failure.

func RunRootOutput

func RunRootOutput(name string, args ...string) (string, error)

RunRootOutput requires root and returns trimmed stdout on success. Output is discarded on error.

func RunRootOutputWithTimeout

func RunRootOutputWithTimeout(timeout time.Duration, name string, args ...string) (string, error)

RunRootOutputWithTimeout requires root and uses RunOutputWithTimeout's output and timeout behavior, including its bounded wait for output.

func RunRootSilent

func RunRootSilent(name string, args ...string) error

RunRootSilent requires root and executes a command, discarding all output.

func RunSilent

func RunSilent(name string, args ...string) error

RunSilent executes a command and discards all output.

func WriteFileRoot

func WriteFileRoot(path string, content []byte, perm os.FileMode) error

WriteFileRoot requires root and replaces path with content and mode perm, so that a power cut leaves either the old file or the complete new one. The new file is root owned. Callers must ensure the destination is suitable. Failures are logged centrally.

func WriteFileRootOwned

func WriteFileRootOwned(path string, content []byte, perm os.FileMode, owner, group string) error

WriteFileRootOwned is WriteFileRoot for a file a service account reads. The file reaches its name already owned by owner and group, so the service never finds a new file it cannot read. If the owner or the group cannot be found, or the owner cannot be set, the old file is left as it was.

Types

type DiskInfo

type DiskInfo struct {
	TotalBytes, UsedBytes uint64
	Percent               string
}

DiskInfo is the size and use of a filesystem in bytes. The screen formats them.

func ReadDisk

func ReadDisk(ctx context.Context, path string) (DiskInfo, error)

type MemInfo

type MemInfo struct {
	TotalBytes, UsedBytes uint64
	Percent               string
}

MemInfo is the size and use of memory in bytes. The screen formats them.

func ReadMemory

func ReadMemory() (MemInfo, error)

type SecurityUpdates

type SecurityUpdates struct {
	LastRun    time.Time
	Configured time.Time
}

SecurityUpdates is what Debian's daily apt job has recorded. LastRun is zero until both the package list refresh and the upgrade have succeeded. Configured is when the install wrote vpn's update settings.

func ReadSecurityUpdates

func ReadSecurityUpdates(config string) (SecurityUpdates, error)

ReadSecurityUpdates reads apt's success stamps and the time of the update settings file the install wrote. Every account can read both.

Jump to

Keyboard shortcuts

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