helper

package
v0.7.0-rc.12 Latest Latest
Warning

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

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

View Source
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.

View Source
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

func Call(verb string, params, result any) error

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

func NothingChanged(err error) bool

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

func ReadBoard(path string) ([]byte, error)

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

func ReadBoardString(path string) (string, error)

ReadBoardString reads a board file as a trimmed string (hostname files and the API key are single lines).

func SelfUpdateStepNames

func SelfUpdateStepNames(version string) []string

SelfUpdateStepNames mirrors the server's self-update steps.

func SyncthingInstallStepNames

func SyncthingInstallStepNames(version string) []string

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

type EndError struct {
	Message string
	Code    string
}

EndError is the failure the helper reported in its end event. Its text is the helper's own words.

func (*EndError) Error

func (e *EndError) Error() string

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

type ServiceActionParams struct {
	Unit   string `json:"unit"`
	Action string `json:"action"`
}

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

func Start(verb string, params any) (*Session, error)

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

func StartContext(ctx context.Context, verb string, params any) (*Session, error)

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.

func (*Session) Wait

func (s *Session) Wait(result any) error

Wait blocks until the terminator, decoding its result payload into result (which may be nil), and closes the connection.

func (*Session) WaitStep

func (s *Session) WaitStep(i int) error

WaitStep blocks until step i (0-based) completes on the root side, a step fails, or the stream ends in an error.

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.

Jump to

Keyboard shortcuts

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