host

package
v0.7.0-rc.9 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 56 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

Overview

Package host owns privileged operations on the local node.

Index

Constants

View Source
const LNDBitcoindRPCUser = "lnd"

LNDBitcoindRPCUser is LND's independent Bitcoin RPC identity.

Variables

This section is empty.

Functions

func AdminLoginObserved

func AdminLoginObserved() (bool, error)

AdminLoginObserved checks the existing first-login contract: any accepted SSH authentication for vpn, including password authentication. The in-session su handoff is not evidence, nor does this prove an independent administrator path. Root work has its own bound; a disconnect does not revoke an accepted check.

func AllowSyncthingFirewallRule

func AllowSyncthingFirewallRule() error

func ApplySSHHardening

func ApplySSHHardening(passwordAuth string) error

ApplySSHHardening validates syntax and effective policy before restarting. Both the installer and runtime use the same owner-scoped configuration.

func ApplyUpdateHostStep

func ApplyUpdateHostStep(step string, cfg *config.AppConfig) error

func BuildLNDConfig

func BuildLNDConfig(
	cfg *config.AppConfig, publicIPv4, restOnion,
	bitcoindRPCUser, bitcoindRPCPass string,
) (string, error)

BuildLNDConfig generates lnd.conf content. Pure logic with no side effects. LND binds by the literal loopback addresses defined once in paths, the same constants every client dials, so the two ends of each connection cannot disagree, and the name localhost appears nowhere in the file (on this node, which disables IPv6, that name can resolve to an unusable IPv6 address).

func BuildTorConfig

func BuildTorConfig(cfg *config.AppConfig) (string, error)

BuildTorConfig generates the complete torrc content from config state. Pure logic: no side effects. Note: HiddenServiceDir paths are hardcoded strings because they are torrc config content read by Tor, not Go logic paths.

func CheckUpdateProcess

func CheckUpdateProcess(c protocol.Component) error

CheckUpdateProcess verifies the running inode, not just systemd's active flag.

func ConfigureAptTor

func ConfigureAptTor() error

ConfigureAptTor routes subsequent apt downloads through Tor and bounds download retries. Package configuration remains unbounded so callers do not kill dpkg during a transaction. Installer must pass its Tor gate first.

func ConfigureFail2ban

func ConfigureFail2ban() error

ConfigureFail2ban writes the initial SSH jail and starts the service.

func ConfigureInitialFirewall

func ConfigureInitialFirewall(cfg *config.AppConfig) error

ConfigureInitialFirewall establishes the node's global UFW baseline during initial installation. Post-install features must not call it: they add and verify only the rules they own through the additive host operations.

The initial operation re-observes sshd immediately before any firewall mutation. Observation failure refuses the rewrite; there is no cached-port or port-22 fallback.

func ConfigureOperatorAutoLaunch

func ConfigureOperatorAutoLaunch() error

ConfigureOperatorAutoLaunch opens the node TUI for interactive SSH logins. Installer calls it after recording successful password application.

func ConfigureOperatorSudo

func ConfigureOperatorSudo() error

ConfigureOperatorSudo runs only during admitted installation, after password application. Conflicting policy is refused rather than overwritten on resume.

func ConfigureUnattendedUpgrades

func ConfigureUnattendedUpgrades() error

ConfigureUnattendedUpgrades sets the appliance's security-only apt policy, including the existing automatic reboot schedule.

func ControlService

func ControlService(request servicecontrol.Request) (servicecontrol.Completion, error)

ControlService completes independently of the requesting terminal. The bound covers LND's five-minute stop and twenty-minute notified start. Terminating systemctl observation cannot roll back a job already accepted by systemd.

func CreateBaseDaemonIdentities

func CreateBaseDaemonIdentities() error

CreateBaseDaemonIdentities provisions the two base daemon identities and directories. Installer must admit the fresh or interrupted lifecycle first; this operation does not adopt existing node state.

func CreateOperatorAccount

func CreateOperatorAccount() error

CreateOperatorAccount creates the owner during an admitted base installation. SSH keys are added explicitly by the owner after installation.

func CreateSystemUser

func CreateSystemUser(username, home string) error

CreateSystemUser creates a non-login service identity when it is absent. Existing identities are left unchanged; callers own lifecycle admission.

func DisableAutoUnlock

func DisableAutoUnlock() (autounlock.Result, error)

DisableAutoUnlock proves a locked invocation before durably removing the secret.

func DisableIPv6

func DisableIPv6() error

DisableIPv6 applies the base appliance IPv4 policy.

func DownloadBitcoinCore

func DownloadBitcoinCore(version, workDir string) error

DownloadBitcoinCore fetches the release archive and detached manifest over Tor.

func DownloadLND

func DownloadLND(version, workDir string) error

DownloadLND fetches the release archive and manifest over Tor.

func EffectiveSSHPasswordAuth

func EffectiveSSHPasswordAuth() (bool, error)

EffectiveSSHPasswordAuth samples sshd's resolved configuration for the operator at localhost. Address-specific Match rules can differ for an actual connection; this observation is not proof that a remote password login will succeed.

func EnableAndRestartBitcoind

func EnableAndRestartBitcoind(cfg *config.AppConfig) error

EnableAndRestartBitcoind enables Core, restarts it and verifies its chain identity. Restart applies the unit and configuration written by this lifecycle even when Core is already running during an interrupted-install resume.

func EnableAndRestartLND

func EnableAndRestartLND() error

EnableAndRestartLND enables LND and restarts it with the installed configuration. Restart also applies changes when LND is running during an interrupted-install resume. The caller separately verifies and stages the TLS certificate.

func EnableAndRestartTor

func EnableAndRestartTor() error

EnableAndRestartTor belongs to initial installation. That operation owns establishing Tor's boot persistence as part of the base node. systemd loads the restart rule before Tor is restarted, so the rule applies from the first crash.

func EnsureGPG

func EnsureGPG() error

EnsureGPG installs the verifier when the admitted installation needs it.

func ExtractUpdateArchive

func ExtractUpdateArchive(archive, dest string, members map[string]string) error

ExtractUpdateArchive only copies explicitly selected regular members. Tar paths, symlinks, ownership and permissions never select host destinations.

func FixBoardOwnership

func FixBoardOwnership() error

FixBoardOwnership re-applies root:vpn 0640 to every existing board file and 0750 to the directory. The first-boot staging step calls this so files written during an image bake (before the admin group existed) become readable once the group does.

func GuardUpdateServices

func GuardUpdateServices(components []protocol.Component) error

GuardUpdateServices requires a permit under /run, so a reboot closes the gate. Conditions are evaluated only at start; removing the permit leaves a healthy process up.

func InstallBasePackages

func InstallBasePackages() error

InstallBasePackages prepares the packages needed before Tor routing is configured. Installer keeps this initial clearnet phase before its Tor gate.

func InstallBitcoinCoreBinaries

func InstallBitcoinCoreBinaries(version, workDir string) error

InstallBitcoinCoreBinaries installs the archive after VerifyBitcoinCore succeeds. The caller owns the private workspace and lifecycle admission.

func InstallFail2ban

func InstallFail2ban() error

InstallFail2ban installs the SSH intrusion-prevention service.

func InstallHelperUnits

func InstallHelperUnits() error

InstallHelperUnits writes both units, reloads systemd, and enables the socket. It requires an active socket unit and a node at the configured path.

func InstallInitialBinary

func InstallInitialBinary() error

InstallInitialBinary places the running executable at the fixed VPN path. Only the admitted base installer calls this; it is not an update operation.

func InstallLNDBinaries

func InstallLNDBinaries(version, workDir string) error

InstallLNDBinaries installs the archive after VerifyLND succeeds. The caller owns the private workspace and lifecycle admission.

func InstallLNDCertWatch

func InstallLNDCertWatch() error

InstallLNDCertWatch writes both units, reloads systemd, and enables and starts the path unit, verifying it is active. Idempotent for a recognized interrupted base install.

func InstallSyncthing

func InstallSyncthing(stage func() error, progress func(int)) error

InstallSyncthing owns fresh add-on provisioning and final desired publication. The helper supplies its fixed freshness action. Accepted work continues if the terminal disconnects; neither a failed step nor disconnect implies rollback.

func InstallUnattendedUpgrades

func InstallUnattendedUpgrades() error

InstallUnattendedUpgrades installs Debian's security-update tooling.

func InstallVPNUpdate

func InstallVPNUpdate(version, workDir string) error

InstallVPNUpdate extracts the verified VPN archive and installs its binary at the fixed system path. The update coordinator owns the private workspace and must authenticate the manifest and archive before calling this operation. Replacement is not a transaction and provides no automatic rollback.

func KeyVerificationPending

func KeyVerificationPending() (bool, error)

KeyVerificationPending reads the root-private workflow marker.

func LNDServiceUnit

func LNDServiceUnit(username string, withUnlock bool) string

LNDServiceUnit renders the LND systemd unit. withUnlock adds LND's --wallet-unlock-password-file flag, pointing at the root-staged password file, so the wallet unlocks without an operator on every service start. Everything else about the two variants is identical by construction; they come from this one template. Pinned LND natively notifies systemd once locked-wallet RPC is available or an auto-unlocked wallet has reached RPC_ACTIVE, before chain synchronization. The extended normal-start timeout follows LND's upstream unit guidance for occasional database work; auto-unlock verification temporarily overrides it with the product's bounded one-attempt window.

func ObserveUpdateVersions

func ObserveUpdateVersions(vpn string, cfg *config.AppConfig) (protocol.Versions, error)

func PrepareBaseHost

func PrepareBaseHost() error

PrepareBaseHost repairs unresolved local hostname lookup when possible and requests NTP synchronization. Failure to enable NTP remains a logged warning.

func PublishLNDBackup

func PublishLNDBackup(network string) (bool, error)

PublishLNDBackup is the internal service operation used by lnd-backup-export.service. The caller selects only a supported Bitcoin network. All filesystem paths and identity names are fixed here. The process must already be the lnd service user with the unit-local vpn-lnd-backup supplementary group.

The unit is started on every change of LND's backup and once a minute. It reports false without touching the export when LND has written no backup yet, or when the export already equals it.

func ReadLNDWalletState

func ReadLNDWalletState() (lnrpc.WalletState, error)

ReadLNDWalletState uses the root-owned TLS certificate for a bounded State RPC.

func ReadLocalAccount

func ReadLocalAccount(ref accountaccess.Ref) (accountaccess.Detail, error)

ReadLocalAccount accepts a local identity, never a caller-selected path or command. Each request resolves that identity again from the local database.

func ReadLocalAccounts

func ReadLocalAccounts() (accountaccess.Inventory, error)

func RebuildSSHHardeningConfig

func RebuildSSHHardeningConfig(disabled bool) error

RebuildSSHHardeningConfig checks fresh, structurally valid keys while holding the same lock as application edits. This cannot prove successful key login.

func RefreshLNDBackupExport

func RefreshLNDBackupExport() error

RefreshLNDBackupExport runs one export after VPN reloaded systemd at a moment when LND writes its backup, because the watcher cannot see a change made during the reload. A node without the Syncthing add-on has no export.

func RefreshPackageLists

func RefreshPackageLists() error

RefreshPackageLists fetches the package lists by whatever route apt is configured to use. Unlike a runtime package update it tolerates a source that cannot be reached: apt then keeps the list it has.

func ReleaseUpdateGuards

func ReleaseUpdateGuards(components []protocol.Component) error

func RequestReboot

func RequestReboot() error

RequestReboot asks systemd to enqueue a reboot, independently of the terminal. Success confirms acceptance, not shutdown or a subsequent successful boot.

func RequireActiveFirewall

func RequireActiveFirewall() error

RequireActiveFirewall is the shared prerequisite for additive post-install firewall changes. A feature operation never installs, enables, or repairs UFW; an inactive firewall is an inconsistent base-node state that must be reported before the feature mutates anything.

func SetKeyVerificationPending

func SetKeyVerificationPending(pending bool) error

SetKeyVerificationPending publishes the installer's first-login requirement. Only the installer arms it; runtime verification can only clear it.

func SetLoginPassword

func SetLoginPassword(password loginpassword.Password) error

SetLoginPassword provisions the initial password during root installation. It has no helper endpoint. Runtime changes use passwd as the owner. An interrupted process may already have changed the password.

func SetOperatorLogOwnership

func SetOperatorLogOwnership() error

SetOperatorLogOwnership gives the operator its application log. System configuration and its parent remain root-owned and are never made writable.

func SetupAutoUnlock

func SetupAutoUnlock(password autounlock.Password) (autounlock.Result, error)

SetupAutoUnlock runs the verified transition independently of the observing TUI.

func SetupJournalAccess

func SetupJournalAccess() error

SetupJournalAccess is the journal.access step: make journal storage persistent (an audit trail that vanishes at reboot is not much of a record) and let the admin user read it.

func SetupNodeCLI

func SetupNodeCLI(cfg *config.AppConfig) error

SetupNodeCLI installs the operator's unprivileged recovery commands. bitcoin-cli reads its staged RPC password on stdin; lncli uses the staged certificate and macaroon. Neither wrapper needs the daemon's private files.

func StageBitcoindRPCPassword

func StageBitcoindRPCPassword(password string) error

StageBitcoindRPCPassword publishes the initial provisioning operation's operator credential. LND's separate Bitcoin RPC password is never staged here.

func StageLNDMacaroon

func StageLNDMacaroon() error

StageLNDMacaroon copies the admin macaroon to the board. It requires the macaroon to exist: the callers are the moments that create it (wallet creation) or that follow its known existence. For the install-time case where no wallet exists yet, the installer skips this operation.

func StageLNDTLSCert

func StageLNDTLSCert() error

StageLNDTLSCert copies LND's TLS certificate (the public half only; tls.key never moves) to the board. LND rewrites the cert during startup when its parameters change, so this polls until the file parses as a stable certificate: two consecutive reads, half a second apart, must agree and parse.

func StageSyncthingAPIKey

func StageSyncthingAPIKey() error

StageSyncthingAPIKey extracts the GUI API key from Syncthing's config and stages it. With the key on the board, every runtime device operation (pair, unpair, folder sharing) is plain localhost REST with no privilege at all.

func StageSyncthingWebPassword

func StageSyncthingWebPassword(password string) error

StageSyncthingWebPassword publishes the generated password. Syncthing keeps only its hash, so this credential cannot be recovered from daemon config.

func StageUpdateComponent

func StageUpdateComponent(c protocol.Component, a protocol.Artifact, dir string) (map[string]string, error)

func StartUpdateService

func StartUpdateService(c protocol.Component) error

func StopUpdateService

func StopUpdateService(c protocol.Component) error

func SyncthingAPIKey

func SyncthingAPIKey() (string, error)

SyncthingAPIKey reads the private configuration for root-side provisioning. Runtime workflows read their staged credentials in the application layer.

func SyncthingDeviceID

func SyncthingDeviceID() string

SyncthingDeviceID reads the certificate identity with the pinned daemon's read-only command. Configuration device order does not identify the local node. runuser supplies the service HOME required by Syncthing package initialization.

func UpdateArchive

func UpdateArchive(c protocol.Component, version string) (string, map[string]string, error)

func UpdateBinaryNames

func UpdateBinaryNames(c protocol.Component) []string

UpdateBinaryNames is a closed destination allowlist, including companion tools retained by older Core installations.

func UpdatePackages

func UpdatePackages(progress func(int)) error

UpdatePackages completes accepted package work independently of the observer. Do not attach the terminal's cancellation to apt/dpkg: a lost connection must not interrupt package configuration. Apt retains its installed Tor routing, download timeouts and retries; only the read-only final audit has a deadline.

func UpdateUnit

func UpdateUnit(c protocol.Component) string

func UpgradeP2PToHybrid

func UpgradeP2PToHybrid(request p2p.UpgradeRequest, stage func() error, progress func(int)) error

UpgradeP2PToHybrid completes accepted root work independently of the terminal. The helper supplies its fixed freshness-matrix action, keeping TLS staging inside the transition's completion boundary and before desired-state publication.

func UpgradePackages

func UpgradePackages() error

UpgradePackages preserves existing configuration on conflict. Installation chooses when to run it; runtime package updates first refresh package lists. Both root entry points set noninteractive apt and needrestart environments.

func ValidV3OnionHostname

func ValidV3OnionHostname(hostname string) bool

ValidV3OnionHostname checks the syntax of a native Tor v3 hostname.

func VerifyAdminLogin

func VerifyAdminLogin() (pending, verified bool, err error)

VerifyAdminLogin clears the marker only after real sshd journal evidence. Unavailable evidence leaves the marker intact and returns an error.

func VerifyBitcoinCore

func VerifyBitcoinCore(workDir string) error

VerifyBitcoinCore requires two distinct pinned signers before checking the archive.

func VerifyInitialOwnerSSH

func VerifyInitialOwnerSSH() error

VerifyInitialOwnerSSH rechecks the installation postcondition on completion, including resumes whose SSH step was already recorded. It never rewrites policy.

func VerifyLND

func VerifyLND(version, workDir string) error

VerifyLND requires the pinned release signer before checking the archive.

func VerifyLNDTLSOnionSAN

func VerifyLNDTLSOnionSAN() error

VerifyLNDTLSOnionSAN waits for LND's startup-time TLS generation/refresh and proves that the certificate it wrote contains the exact REST onion DNS SAN configured above.

func VerifyOperatorSudo

func VerifyOperatorSudo() error

VerifyOperatorSudo inspects sudo's matched rules, including command defaults. It conservatively refuses conflicting authentication rules rather than trying to reproduce sudo's precedence logic or changing independent host policy. It does not authenticate a password or replace an actual owner login test.

func WalletExists

func WalletExists(network string) (bool, error)

WalletExists asks LND's always-running State service whether its wallet has been initialized. SQLite creates chain.sqlite before a wallet exists, so no database-file path can answer this question reliably.

func WriteBitcoindService

func WriteBitcoindService() error

WriteBitcoindService installs the unit for the dedicated Bitcoin identity.

func WriteInitialNodeRPCConfig

func WriteInitialNodeRPCConfig(cfg *config.AppConfig) error

WriteInitialNodeRPCConfig rotates both RPC credentials and writes both daemon configurations. Only the operator's password is staged; LND's password stays in root:lnd lnd.conf. Writes are sequential, not a transaction. The installer reruns the whole incomplete btc group after failure, before starting Core. This operation is for initial provisioning, not a completed-node rewrite.

func WriteLNDConfig

func WriteLNDConfig(cfg *config.AppConfig, publicIPv4 string) error

func WriteLNDConfigWithRPCPassword

func WriteLNDConfigWithRPCPassword(
	cfg *config.AppConfig, publicIPv4, password string,
) error

func WriteLNDServiceFromConfig

func WriteLNDServiceFromConfig(cfg *config.AppConfig) error

WriteLNDServiceFromConfig writes the LND unit that matches the node's desired state: the unlock variant when the config says auto-unlock is enabled AND the wallet password file is actually present, the plain variant otherwise. Requiring the file too is deliberate: a unit pointing at a missing password file would keep LND from starting at all.

func WriteTorConfig

func WriteTorConfig(cfg *config.AppConfig) error

WriteTorConfig writes the torrc to disk.

Types

type OnionAddresses

type OnionAddresses struct {
	BitcoinP2P string
	LNDGRPC    string
	LNDREST    string
	Syncthing  string
}

OnionAddresses contains the fixed Tor hostname observations used for display. Empty fields mean unavailable, including missing or unreadable files.

func ReadOnionAddresses

func ReadOnionAddresses() OnionAddresses

ReadOnionAddresses reads current display facts without staging or mutation. Provisioning separately validates required hostnames before using them.

type SSHObservation

type SSHObservation struct {
	// Ports are the listening ports, deduplicated, sorted.
	Ports []int
	// PasswordAuth reports whether password authentication is
	// effectively enabled.
	PasswordAuth bool
}

SSHObservation is an effective configuration snapshot for initial SSH setup.

func ObserveInitialSSHState

func ObserveInitialSSHState() (SSHObservation, error)

ObserveInitialSSHState queries effective SSH configuration for initial setup. Preflight and firewall callers refuse on error. Owner password access is established separately by the installer's SSH hardening step.

type UpdateHealth

type UpdateHealth struct{ Ready, Unlock bool }

UpdateHealth separates startup progress and a locked wallet from failure. Synchronization is normal runtime progress; it does not trigger a downgrade.

func CheckUpdateHealth

func CheckUpdateHealth(c protocol.Component, version string, cfg *config.AppConfig, walletPresent bool, syncthingID string) (UpdateHealth, error)

Jump to

Keyboard shortcuts

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