Documentation
¶
Index ¶
- func DirSize(path string) string
- func Download(url, dest string) error
- func DownloadRequireTor(url, dest string) error
- func IsServiceActive(name string) bool
- func ParseSourceIP(routeOutput string) string
- func ParseUnitProperties(out string) map[string]map[string]string
- func PublicIPv4() string
- func ReadFileRoot(path string) ([]byte, error)
- func ReadPublicIPv4(ctx context.Context) (string, error)
- func ReadRebootRequired() (bool, error)
- func ReadServiceActive(ctx context.Context, name string) (bool, error)
- func ReadServiceState(ctx context.Context, name string) (string, error)
- func ReadUnitProperties(ctx context.Context, units []string, properties ...string) (map[string]map[string]string, error)
- func RebootRequired() bool
- func Run(name string, args ...string) error
- func RunCombinedOutput(name string, args ...string) (string, error)
- func RunOutput(name string, args ...string) (string, error)
- func RunOutputWithTimeout(timeout time.Duration, name string, args ...string) (string, error)
- func RunRoot(name string, args ...string) error
- func RunRootCombinedOutput(name string, args ...string) (string, error)
- func RunRootOutput(name string, args ...string) (string, error)
- func RunRootOutputWithTimeout(timeout time.Duration, name string, args ...string) (string, error)
- func RunRootSilent(name string, args ...string) error
- func RunSilent(name string, args ...string) error
- func ServiceAction(name, action string) error
- func WriteFileRoot(path string, content []byte, perm os.FileMode) error
- type DiskInfo
- type MemInfo
- type SecurityUpdates
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DirSize ¶
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 ¶
Download fetches a URL to a local path using torsocks if available. It does not require Tor.
func DownloadRequireTor ¶
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 ParseSourceIP ¶
ParseSourceIP extracts the source IP from "ip route get" output. Exported for testing.
func ParseUnitProperties ¶
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 ¶
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 ReadRebootRequired ¶
func ReadServiceActive ¶
ReadServiceActive separates an inactive unit from a failed systemd query.
func ReadServiceState ¶
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 RebootRequired ¶
func RebootRequired() bool
func RunCombinedOutput ¶
RunCombinedOutput executes a command and returns combined stdout+stderr. Used for GPG commands which write status to stderr.
func RunOutputWithTimeout ¶
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 RunRootCombinedOutput ¶
RunRootCombinedOutput requires root and returns combined stdout and stderr, trimmed on success and untrimmed on command failure.
func RunRootOutput ¶
RunRootOutput requires root and returns trimmed stdout on success. Output is discarded on error.
func RunRootOutputWithTimeout ¶
RunRootOutputWithTimeout requires root and uses RunOutputWithTimeout's output and timeout behavior, including its bounded wait for output.
func RunRootSilent ¶
RunRootSilent requires root and executes a command, discarding all output.
func ServiceAction ¶
func WriteFileRoot ¶
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.
Types ¶
type MemInfo ¶
func ReadMemory ¶
type SecurityUpdates ¶
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.