{"modulePath":"github.com/virtpriv/node","version":"v0.7.0-rc.13","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package system\n\n## Functions\n\n```go\nfunc DirSize(path string) string\n```\nDirSize 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.\n\n```go\nfunc DownloadRequireTor(url, dest string) error\n```\nDownloadRequireTor 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.\n\n```go\nfunc IsServiceActive(name string) bool\n```\n\n```go\nfunc ParseSourceIP(routeOutput string) string\n```\nParseSourceIP extracts the source IP from \"ip route get\" output. Exported for testing.\n\n```go\nfunc ParseUnitProperties(out string) map[string]map[string]string\n```\nParseUnitProperties 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.\n\n```go\nfunc PublicIPv4() string\n```\nPublicIPv4 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.\n\n```go\nfunc ReadFileRoot(path string) ([]byte, error)\n```\nReadFileRoot 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.\n\n```go\nfunc ReadPublicIPv4(ctx context.Context) (string, error)\n```\n\n```go\nfunc ReadRebootRequired() (bool, error)\n```\n\n```go\nfunc ReadServiceActive(ctx context.Context, name string) (bool, error)\n```\nReadServiceActive separates an inactive unit from a failed systemd query.\n\n```go\nfunc ReadServiceState(ctx context.Context, name string) (string, error)\n```\nReadServiceState retains transitional states for mutation postconditions.\n\n```go\nfunc ReadUnitProperties(ctx context.Context, units []string, properties ...string) (map[string]map[string]string, error)\n```\nReadUnitProperties reads systemd's record of the given units, which every account can read. The result is keyed by unit name.\n\n```go\nfunc Run(name string, args ...string) error\n```\nRun executes a command and returns an error with output on failure.\n\n```go\nfunc RunCombinedOutput(name string, args ...string) (string, error)\n```\nRunCombinedOutput executes a command and returns combined stdout+stderr. Used for GPG commands which write status to stderr.\n\n```go\nfunc RunOutput(name string, args ...string) (string, error)\n```\nRunOutput returns trimmed stdout on success and discards output on error.\n\n```go\nfunc RunOutputWithTimeout(timeout time.Duration, name string, args ...string) (string, error)\n```\nRunOutputWithTimeout 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.\n\n```go\nfunc RunRoot(name string, args ...string) error\n```\nRunRoot requires the process to be root, then executes the command directly.\n\n```go\nfunc RunRootCombinedOutput(name string, args ...string) (string, error)\n```\nRunRootCombinedOutput requires root and returns combined stdout and stderr, trimmed on success and untrimmed on command failure.\n\n```go\nfunc RunRootOutput(name string, args ...string) (string, error)\n```\nRunRootOutput requires root and returns trimmed stdout on success. Output is discarded on error.\n\n```go\nfunc RunRootOutputWithTimeout(timeout time.Duration, name string, args ...string) (string, error)\n```\nRunRootOutputWithTimeout requires root and uses RunOutputWithTimeout's output and timeout behavior, including its bounded wait for output.\n\n```go\nfunc RunRootSilent(name string, args ...string) error\n```\nRunRootSilent requires root and executes a command, discarding all output.\n\n```go\nfunc RunSilent(name string, args ...string) error\n```\nRunSilent executes a command and discards all output.\n\n```go\nfunc WriteFileRoot(path string, content []byte, perm os.FileMode) error\n```\nWriteFileRoot 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.\n\n```go\nfunc WriteFileRootOwned(path string, content []byte, perm os.FileMode, owner, group string) error\n```\nWriteFileRootOwned 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.\n\n## Types\n\n```go\ntype DiskInfo struct {\n\tTotalBytes, UsedBytes uint64\n\tPercent               string\n}\n```\nDiskInfo is the size and use of a filesystem in bytes. The screen formats them.\n\n```go\nfunc ReadDisk(ctx context.Context, path string) (DiskInfo, error)\n```\n\n```go\ntype MemInfo struct {\n\tTotalBytes, UsedBytes uint64\n\tPercent               string\n}\n```\nMemInfo is the size and use of memory in bytes. The screen formats them.\n\n```go\nfunc ReadMemory() (MemInfo, error)\n```\n\n```go\ntype SecurityUpdates struct {\n\tLastRun    time.Time\n\tConfigured time.Time\n}\n```\nSecurityUpdates 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.\n\n```go\nfunc ReadSecurityUpdates(config string) (SecurityUpdates, error)\n```\nReadSecurityUpdates reads apt's success stamps and the time of the update settings file the install wrote. Every account can read both.\n\n","path":"github.com/virtpriv/node/internal/system","name":"system","synopsis":"","isRedistributable":true}
