Documentation
¶
Overview ¶
Package host owns privileged operations on the local node.
Index ¶
- Constants
- func AdminLoginObserved() (bool, error)
- func AllowSyncthingFirewallRule() error
- func ApplySSHHardening(passwordAuth string) error
- func ApplyUpdateHostStep(step string, cfg *config.AppConfig) error
- func BuildLNDConfig(cfg *config.AppConfig, ...) (string, error)
- func BuildTorConfig(cfg *config.AppConfig) (string, error)
- func CheckUpdateProcess(c protocol.Component) error
- func ConfigureAptTor() error
- func ConfigureFail2ban() error
- func ConfigureInitialFirewall(cfg *config.AppConfig) error
- func ConfigureOperatorAutoLaunch() error
- func ConfigureOperatorSudo() error
- func ConfigureUnattendedUpgrades() error
- func ControlService(request servicecontrol.Request) (servicecontrol.Completion, error)
- func CreateBaseDaemonIdentities() error
- func CreateOperatorAccount() error
- func CreateSystemUser(username, home string) error
- func DisableAutoUnlock() (autounlock.Result, error)
- func DisableIPv6() error
- func DownloadBitcoinCore(version, workDir string) error
- func DownloadLND(version, workDir string) error
- func EffectiveSSHPasswordAuth() (bool, error)
- func EnableAndRestartBitcoind(cfg *config.AppConfig) error
- func EnableAndRestartLND() error
- func EnableAndRestartTor() error
- func EnsureGPG() error
- func ExtractUpdateArchive(archive, dest string, members map[string]string) error
- func FixBoardOwnership() error
- func GuardUpdateServices(components []protocol.Component) error
- func InstallBasePackages() error
- func InstallBitcoinCoreBinaries(version, workDir string) error
- func InstallFail2ban() error
- func InstallHelperUnits() error
- func InstallInitialBinary() error
- func InstallLNDBinaries(version, workDir string) error
- func InstallLNDCertWatch() error
- func InstallSyncthing(stage func() error, progress func(int)) error
- func InstallUnattendedUpgrades() error
- func InstallVPNUpdate(version, workDir string) error
- func KeyVerificationPending() (bool, error)
- func LNDServiceUnit(username string, withUnlock bool) string
- func ObserveUpdateVersions(vpn string, cfg *config.AppConfig) (protocol.Versions, error)
- func PrepareBaseHost() error
- func PublishLNDBackup(network string) error
- func ReadLNDWalletState() (lnrpc.WalletState, error)
- func ReadLocalAccount(ref accountaccess.Ref) (accountaccess.Detail, error)
- func ReadLocalAccounts() (accountaccess.Inventory, error)
- func RebuildSSHHardeningConfig(disabled bool) error
- func RefreshPackageLists() error
- func ReleaseUpdateGuards(components []protocol.Component) error
- func RequestReboot() error
- func RequireActiveFirewall() error
- func SetKeyVerificationPending(pending bool) error
- func SetLoginPassword(password loginpassword.Password) error
- func SetOperatorLogOwnership() error
- func SetupAutoUnlock(password autounlock.Password) (autounlock.Result, error)
- func SetupJournalAccess() error
- func SetupNodeCLI(cfg *config.AppConfig) error
- func StageBitcoindRPCPassword(password string) error
- func StageLNDMacaroon() error
- func StageLNDTLSCert() error
- func StageSyncthingAPIKey() error
- func StageSyncthingWebPassword(password string) error
- func StageUpdateComponent(c protocol.Component, a protocol.Artifact, dir string) (map[string]string, error)
- func StartUpdateService(c protocol.Component) error
- func StopUpdateService(c protocol.Component) error
- func SyncthingAPIKey() (string, error)
- func SyncthingDeviceID() string
- func UpdateArchive(c protocol.Component, version string) (string, map[string]string, error)
- func UpdateBinaryNames(c protocol.Component) []string
- func UpdatePackages(progress func(int)) error
- func UpdateUnit(c protocol.Component) string
- func UpgradeP2PToHybrid(request p2p.UpgradeRequest, stage func() error, progress func(int)) error
- func UpgradePackages() error
- func ValidV3OnionHostname(hostname string) bool
- func VerifyAdminLogin() (pending, verified bool, err error)
- func VerifyBitcoinCore(workDir string) error
- func VerifyInitialOwnerSSH() error
- func VerifyLND(version, workDir string) error
- func VerifyLNDTLSOnionSAN() error
- func VerifyOperatorSudo() error
- func WalletExists(network string) (bool, error)
- func WriteBitcoindService() error
- func WriteInitialNodeRPCConfig(cfg *config.AppConfig) error
- func WriteLNDConfig(cfg *config.AppConfig, publicIPv4 string) error
- func WriteLNDConfigWithRPCPassword(cfg *config.AppConfig, publicIPv4, password string) error
- func WriteLNDServiceFromConfig(cfg *config.AppConfig) error
- func WriteTorConfig(cfg *config.AppConfig) error
- type OnionAddresses
- type SSHObservation
- type UpdateHealth
Constants ¶
const LNDBitcoindRPCUser = "lnd"
LNDBitcoindRPCUser is LND's independent Bitcoin RPC identity.
Variables ¶
This section is empty.
Functions ¶
func AdminLoginObserved ¶
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 ¶
ApplySSHHardening validates syntax and effective policy before restarting. Both the installer and runtime use the same owner-scoped configuration.
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 ¶
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 ¶
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 ¶
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 ¶
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 DownloadBitcoinCore ¶
DownloadBitcoinCore fetches the release archive and detached manifest over Tor.
func DownloadLND ¶
DownloadLND fetches the release archive and manifest over Tor.
func EffectiveSSHPasswordAuth ¶
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 ¶
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.
func EnsureGPG ¶
func EnsureGPG() error
EnsureGPG installs the verifier when the admitted installation needs it.
func ExtractUpdateArchive ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
KeyVerificationPending reads the root-private workflow marker.
func LNDServiceUnit ¶
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 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 ¶
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.
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 ¶
RebuildSSHHardeningConfig checks fresh, structurally valid keys while holding the same lock as application edits. This cannot prove successful key login.
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 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 ¶
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 ¶
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 ¶
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 ¶
StageSyncthingWebPassword publishes the generated password. Syncthing keeps only its hash, so this credential cannot be recovered from daemon config.
func StageUpdateComponent ¶
func StartUpdateService ¶
func StopUpdateService ¶
func SyncthingAPIKey ¶
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 UpdateBinaryNames ¶
UpdateBinaryNames is a closed destination allowlist, including companion tools retained by older Core installations.
func UpdatePackages ¶
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 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 ¶
ValidV3OnionHostname checks the syntax of a native Tor v3 hostname.
func VerifyAdminLogin ¶
VerifyAdminLogin clears the marker only after real sshd journal evidence. Unavailable evidence leaves the marker intact and returns an error.
func VerifyBitcoinCore ¶
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 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 ¶
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 ¶
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 WriteLNDServiceFromConfig ¶
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 ¶
WriteTorConfig writes the torrc to disk.
Types ¶
type OnionAddresses ¶
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.
Source Files
¶
- account_access.go
- account_sudo.go
- admin_login.go
- bitcoin_artifact.go
- bitcoin_config.go
- bitcoin_provision.go
- board.go
- bootstrap.go
- cli.go
- firewall.go
- firewall_initial.go
- helper_provision.go
- identities.go
- keyverification.go
- lnd_artifact.go
- lnd_auto_unlock.go
- lnd_backup_export_linux.go
- lnd_certwatch.go
- lnd_config.go
- lnd_provision.go
- lnd_service.go
- login_password.go
- onion.go
- operator_access.go
- operator_sudo.go
- p2p_upgrade.go
- packages.go
- reboot.go
- rpcauth.go
- service_control.go
- ssh_observation.go
- sshd.go
- staging.go
- syncthing.go
- syncthing_artifact.go
- syncthing_install.go
- syncthing_provision.go
- syncthing_template.go
- tor.go
- update_artifacts.go
- update_health.go
- update_services.go
- vpn_update.go
- wallet_state.go