Documentation
¶
Overview ¶
Package helper is the unprivileged side of the node's privilege boundary. It holds three things:
- the wire protocol shared by the root helper (vpn helperd) and its clients, one JSON request line per connection answered by zero or more progress events and exactly one ok/error terminator (wire.go),
- the client the TUI uses to request privileged operations over the helper's unix socket (client.go),
- the staging-board reader, which reads the root-written files under /var/lib/vpn/state that carry deliberately staged credentials and fixed facts to the admin user without any privileged code running on the read path (board.go).
Privileged operations live behind helperd. This package owns their IPC contract.
Index ¶
- Constants
- func Call(verb string, params, result any) error
- func NothingChanged(err error) bool
- func PackageUpdateStepNames() []string
- func ReadBoard(path string) ([]byte, error)
- func ReadBoardString(path string) (string, error)
- func SelfUpdateStepNames(version string) []string
- func SyncthingInstallStepNames(version string) []string
- func UpgradeP2PToHybridStepNames() []string
- type DirSizeParams
- type DirSizeResult
- type EndError
- type Event
- type KeyVerificationStateResult
- type NodeAddressesResult
- type PrepareUpdateParams
- type RebootResult
- type RebuildSSHConfigParams
- type Request
- type SSHAuthResult
- type SelfUpdateParams
- type ServiceActionParams
- type Session
- type StageWalletPasswordParams
- type UpdateApproval
- type UpdateResumeParams
- type UpgradeP2PParams
- type VerifyAdminLoginResult
- type WalletStateResult
Constants ¶
const ( // Simple verbs: one request, one terminator. VerbServiceAction = "service-action" VerbReboot = "reboot" VerbDirSize = "dir-size" VerbStageWalletPassword = "stage-wallet-password" VerbRemoveWalletPassword = "remove-wallet-password" VerbStageLNDCredentials = "stage-lnd-credentials" VerbStageLNDMacaroon = "stage-lnd-macaroon" VerbRebuildSSHConfig = "rebuild-ssh-config" // VerifyAdminLogin checks live journal evidence and may clear the // root-private pending marker. It accepts no caller-chosen state. VerbVerifyAdminLogin = "verify-admin-login" // Read-only verbs: no mutation, a typed // result. read-account accepts only a local account identity. // They exist for display facts the TUI needs // at human cadence (screen entry) whose truth lives in // root-readable places and can change outside any // operation of ours. Keeping a copy of such a fact // would risk rendering it confidently wrong, so no copy // exists and the screens ask here instead. VerbReadAccounts = "read-accounts" VerbReadAccount = "read-account" VerbReadNodeAddresses = "read-node-addresses" VerbReadSSHAuth = "read-ssh-auth" VerbReadWalletState = "read-wallet-state" VerbReadKeyVerificationState = "read-key-verification-state" // Streaming verbs: step progress events precede the // terminator, and feed the TUI's step renderer. VerbPackageUpdate = "package-update" VerbSelfUpdate = "self-update" VerbPrepareUpdate = "prepare-update" VerbStartUpdate = "start-update" VerbUpdateStatus = "update-status" VerbResumeUpdate = "resume-update" VerbCancelUpdate = "cancel-update" VerbUpgradeP2PToHybrid = "upgrade-p2p-to-hybrid" VerbSyncthingInstall = "syncthing-install" )
Verb names. The helper serves this fixed menu and nothing else. There is no verb that runs a caller-supplied command, and no verb that returns a caller-chosen file. Every verb validates its parameters against a closed set of accepted values before touching the system.
const CodeNothingChanged = "nothing_changed"
CodeNothingChanged is the end event's code for a request that failed before it changed anything on the node, such as a refusal at its first checks. A failure without it may have changed something.
Variables ¶
This section is empty.
Functions ¶
func Call ¶
Call performs a whole verb in one blocking call. It starts, drains any progress events and decodes the terminator. For streaming verbs it simply ignores per-step progress.
func NothingChanged ¶
NothingChanged reports whether err says for certain that the request changed nothing, because the helper said so or the request never reached it. A lost reply says nothing either way.
func PackageUpdateStepNames ¶
func PackageUpdateStepNames() []string
PackageUpdateStepNames mirrors the server's package-update steps.
func ReadBoard ¶
ReadBoard reads one staging-board file. The error is written for surfacing to the operator: it names the file and points at the helper's journal, because a missing board file means a staging step failed or was skipped — a real defect to report, not a condition to paper over.
func ReadBoardString ¶
ReadBoardString reads a board file as a trimmed string (hostname files and the API key are single lines).
func SelfUpdateStepNames ¶
SelfUpdateStepNames mirrors the server's self-update steps.
func SyncthingInstallStepNames ¶
SyncthingInstallStepNames mirrors the server's Syncthing install steps.
func UpgradeP2PToHybridStepNames ¶
func UpgradeP2PToHybridStepNames() []string
UpgradeP2PToHybridStepNames mirrors the server's one-way P2P transition.
Types ¶
type DirSizeParams ¶
type DirSizeParams struct {
Which string `json:"which"`
}
DirSizeParams: which data directory to measure. "lnd" is the only accepted value. The bitcoin data dir's size comes from bitcoind's own getblockchaininfo (size_on_disk) over RPC, with no privileged operation at all.
type DirSizeResult ¶
type DirSizeResult struct {
Size string `json:"size"`
}
DirSizeResult carries the measured size back, already formatted for the screen ("12.3 GB").
type EndError ¶
EndError is the failure the helper reported in its end event. Its text is the helper's own words.
type Event ¶
type Event struct {
Event string `json:"event"` // "step" or "end"
// step fields
Index int `json:"index,omitempty"`
Err string `json:"err,omitempty"`
// end fields
OK bool `json:"ok,omitempty"`
Error string `json:"error,omitempty"`
Code string `json:"code,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
}
Event is one response line from the helper. Two kinds:
- "step": progress from a streaming verb. Index is the 0-based position in the verb's fixed step list. The helper emits a step event on COMPLETION only. A step that fails produces no step event, and the failure arrives as the error terminator. Err is reserved wire surface for a per-step error report. The helper never sets it today, and clients treat a non-empty Err as fatal if one ever appears.
- "end": the terminator. Exactly one per connection. OK with an optional Result payload, or an Error message, with Code set when the failure came before any change.
type KeyVerificationStateResult ¶
type KeyVerificationStateResult struct {
Pending bool `json:"pending"`
}
KeyVerificationStateResult is the independent root-private workflow-marker observation. Wallet availability never depends on this read succeeding.
type NodeAddressesResult ¶
type NodeAddressesResult struct {
BitcoinP2POnion string `json:"bitcoin_p2p_onion"`
LNDGRPCOnion string `json:"lnd_grpc_onion"`
LNDRESTOnion string `json:"lnd_rest_onion"`
SyncthingOnion string `json:"syncthing_onion"`
SyncthingDeviceID string `json:"syncthing_device_id"`
}
NodeAddressesResult is the read-node-addresses answer, the node's Tor hidden-service hostnames and its Syncthing device ID, read from their sources at the moment of the request. An empty field means the observation is unavailable, including when a hostname file is missing or unreadable. It does not prove the service is unconfigured or that an observed address is reachable.
type PrepareUpdateParams ¶
type PrepareUpdateParams struct {
Version string `json:"version"`
}
PrepareUpdateParams selects a release for verification and review.
type RebootResult ¶
type RebootResult struct {
Accepted bool `json:"accepted"`
}
RebootResult confirms systemd accepted the request, not that the host rebooted.
type RebuildSSHConfigParams ¶
type RebuildSSHConfigParams struct {
PasswordAuthDisabled bool `json:"password_auth_disabled"`
}
RebuildSSHConfigParams: rewrite the SSH hardening drop-in. The template lives on the root side. The only caller-chosen value is the password-auth flag.
type Request ¶
type Request struct {
Verb string `json:"verb"`
Params json.RawMessage `json:"params,omitempty"`
}
Request is the single line a client writes after connecting.
type SSHAuthResult ¶
type SSHAuthResult struct {
PasswordAuthEnabled bool `json:"password_auth_enabled"`
}
SSHAuthResult is the read-ssh-auth answer, whether sshd's EFFECTIVE configuration permits password authentication for the admin user, asked of sshd itself at request time. This answer gates removing the last SSH key, so callers treat a verb error as "unavailable" and refuse the risky action.
type SelfUpdateParams ¶
type SelfUpdateParams struct {
Version string `json:"version"`
}
SelfUpdateParams: update the vpn binary to a release version. Validated root-side as a canonical stable version, strictly newer, and same-major only (a cross-major release requires reading its release notes, and the helper refuses it no matter what a client asks).
type ServiceActionParams ¶
ServiceActionParams: systemctl <action> <unit>. Both fields are validated against closed sets on the root side.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is one in-flight helper request. Callers either drain it with Wait (simple verbs) or step through it with WaitStep + Wait (streaming verbs feeding a step renderer).
func Start ¶
Start dials the helper and sends the request. It returns immediately after the request is written. The operation runs (and possibly queues) on the root side.
func StartContext ¶
StartContext owns the connection until Wait or Close. Cancellation stops local I/O, including a blocked progress read. It cannot undo an accepted mutation.
func (*Session) Close ¶
func (s *Session) Close()
Close stops observation and releases the connection. The helper deliberately continues an accepted mutation after disconnection. Close is not rollback. It may run concurrently with WaitStep or Wait. Reads must have one owner.
type StageWalletPasswordParams ¶
type StageWalletPasswordParams struct {
Password string `json:"password"`
}
StageWalletPasswordParams: enable LND auto-unlock. The password the operator typed is written root-side to LND's wallet_password file (which stays owned by the service user, never readable by the admin user) and the LND service is rewritten to use it.
type UpdateApproval ¶
type UpdateApproval struct {
Token string `json:"token"`
}
UpdateApproval binds start/retry to root-verified release bytes, not a mutable latest-version hint or a caller-provided execution plan.
type UpdateResumeParams ¶
type UpdateResumeParams struct {
ID string `json:"id"`
}
type UpgradeP2PParams ¶
type UpgradeP2PParams struct {
ExpectedIPv4 string `json:"expected_ipv4"`
}
UpgradeP2PParams carries the reviewed address only as a precondition. The root operation independently derives the address it will advertise.
type VerifyAdminLoginResult ¶
type VerifyAdminLoginResult struct {
Pending bool `json:"pending"`
Verified bool `json:"verified"`
}
VerifyAdminLoginResult reports the private marker state after the helper checked current sshd journal evidence and, when verified, cleared it.
type WalletStateResult ¶
type WalletStateResult struct {
WalletExists bool `json:"wallet_exists"`
}
WalletStateResult is the independent live wallet observation. It is not coupled to any private workflow marker, so a marker read failure cannot make an otherwise readable wallet appear unknown.