system

package
v0.7.0-rc.8 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: AGPL-3.0 Imports: 11 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 a directory tree with du. Root only: 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 Download

func Download(url, dest string) error

Download fetches a URL to a local path using torsocks if available. It does not require Tor.

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 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 RebootRequired

func RebootRequired() bool

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 interrupts the command, but descendant-held output pipes can delay return because no WaitDelay is set.

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 output-pipe wait limitation.

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 ServiceAction

func ServiceAction(name, action string) error

func WriteFileRoot

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

WriteFileRoot creates a private, exclusive input temporary file, then requires root to install its content and mode at a fixed .<base>.tmp destination and move that file onto path. Callers must ensure the destination is suitable. The destination staging name is not exclusive, close errors are ignored and files are not fsynced; this is not a general crash-safe replacement primitive. Install and move failures are logged centrally.

Types

type DiskInfo

type DiskInfo struct {
	Total   string
	Used    string
	Percent string
}

func ReadDisk

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

type MemInfo

type MemInfo struct {
	Total   string
	Used    string
	Percent string
}

func ReadMemory

func ReadMemory() (MemInfo, error)

Jump to

Keyboard shortcuts

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