doctor

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package doctor implements `wg-guard doctor` (docs/operations/runbook.md): read-only environment and state checks with actionable remedies, plus `--fix` which re-runs the boot repairs (interface reconciliation, nftables, tc, sysctls) through the same orchestration `serve` uses. The fix path refuses to run while the service is up — it would race the serialized reconciler for the AWG subprocess.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendInspector

type BackendInspector interface {
	Dump(context.Context, string) (tunnel.InterfaceState, error)
}

BackendInspector is the read-only runtime surface used by diagnostics. Docker deployments provide an inspector backed by the running container, while repair orchestration retains its independently selected Backend.

type Check

type Check struct {
	Name   string
	Status Status
	Detail string
	Remedy string
}

Check is one diagnostic line. Detail and Remedy never contain secrets.

type Deps

type Deps struct {
	Cfg        *config.Config
	ConfigPath string
	DB         *database.DB
	Reg        *settings.Registry
	Ring       *secrets.KeyRing
	Backend    tunnel.Backend
	Inspector  BackendInspector
	Run        subprocess.Runner
	Shaper     *shaper.Manager
	Log        *slog.Logger

	// Fix applies the safe boot repairs after the read-only pass.
	Fix bool
	// ServiceUp lets the caller pre-check whether the node is serving
	// (the fix path refuses when it is).
	ServiceUp bool
}

Deps wires the doctor. DB/Reg may be nil where a check cannot run.

type Report

type Report struct {
	Checks []Check
	Fixes  []string // what --fix changed, in order
}

Report is the full doctor output.

func Run

func Run(ctx context.Context, d Deps) (*Report, error)

Run executes every check in order, then (--fix) the boot repairs and a re-check of the affected areas.

func (*Report) Failures

func (r *Report) Failures() int

Failures counts checks that need attention (exit-code driver).

func (*Report) Warnings

func (r *Report) Warnings() int

Warnings counts warn-grade checks.

type Status

type Status string

Status is one check outcome.

const (
	StatusPass Status = "pass"
	StatusWarn Status = "warn"
	StatusFail Status = "fail"
	StatusSkip Status = "skip"
)

Jump to

Keyboard shortcuts

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