ops

package
v0.2.0-dev.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 40 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 ops is the panel's own diagnostics and data lifecycle for the owner: the log ring and its level, retention of the tables the sweep prunes, a scrubbed export, and the /metrics endpoint; and two reads for every admin, the panel's own resources and the fleet's load (internal/panel/capacity). It is the OpsService of proto/mistgate/ops/v1, a package of its own so the Cloudflare edition's admin Worker does not link it; that edition mounts a stub that answers UNIMPLEMENTED (internal/panel/app/ops_wiring_js.go).

Everything that leaves the process passes through Scrubber: addresses, the panel's secret names, key-shaped values, and only an allow-list of log attribute keys. The ring itself keeps raw records and never leaves this package unscrubbed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Store *store.Store
	// Ring and Level are the process logger's (logring.New). A panel built without them (a test) has no logs to show.
	Ring         *logring.Ring
	Level        *slog.LevelVar
	DefaultLevel slog.Level
	Format       string // "text" or "json"
	// Secrets are the panel's secret names (the agent SNI and the secret path prefixes), removed from everything that leaves.
	Secrets []string
	// StepUp is the fresh sign-in check (auth.Service.RequireStepUp) that retention changes, the export and the metrics switch ask for.
	StepUp func(context.Context) error
	// Fleet, Health and Relay are the raw admin services /metrics reads (no session in front of them: the metrics handler has its
	// own token). nil leaves that part of the metrics out.
	Fleet, Health, Relay http.Handler
	// Debug starts and stops the on-demand debug captures of a node (the fleet). nil answers UNIMPLEMENTED for them.
	Debug DebugBackend
	// RPC is the admin API's call counter that the HTTP middleware fills (httpserver.Config.RPCStats); nil leaves the RPC
	// load of GetPanelResources empty.
	RPC *rpcstat.Window
	// Capacity reads the nodes for GetFleetLoad over a window of hours (fleet.CapacityNodes); nil answers with no nodes.
	Capacity func(ctx context.Context, hours int) ([]capacity.Node, error)
	// NetworkTable is the panel's immutable, currently loaded signed ASN table. Nil means absent or invalid.
	NetworkTable func() NetworkTable
	// NetworkBundle returns the data/any file name and digest in the current trusted node bundle.
	NetworkBundle func() (name, sha256 string)
	// NetworkSettingsChanged refreshes the stream setting cache and asks connected nodes to reconcile.
	NetworkSettingsChanged func(mode uint32)
	Now                    func() time.Time
	Log                    *slog.Logger
}

Config configures Service.

type DebugBackend

type DebugBackend interface {
	StartDebugCapture(ctx context.Context, in fleet.DebugStart) (store.DebugCaptureRow, error)
	StopDebugCapture(ctx context.Context, captureID string) (store.DebugCaptureRow, error)
}

DebugBackend is what the service needs of the fleet.

type NetworkTable

type NetworkTable interface {
	Built() time.Time
	IPv4RangeCount() int
	IPv6RangeCount() int
	ASNCount() int
}

NetworkTable is the small read-only view the OpsService needs from the loaded table.

type Scrubber

type Scrubber struct {
	// contains filtered or unexported fields
}

Scrubber cleans text that leaves the panel. Its order matters: secret names first (they may sit inside an address-like string), then addresses, then the MCP scrubbers for credential-shaped text.

func NewScrubber

func NewScrubber(secrets []string) *Scrubber

NewScrubber takes the panel's secret names (SNI, path prefixes); names shorter than minSecret are ignored.

func (*Scrubber) Line

func (c *Scrubber) Line(s string) string

Line cleans one serialised JSON line (an export row): the same passes, with the JSON-aware credential scrubbers last.

func (*Scrubber) Secrets

func (c *Scrubber) Secrets(s string) string

Secrets cuts only the panel's secret names out of a text. It is the whole pass over text that was cleaned when it was stored (the logs people send): the names are the one thing that can have changed since.

func (*Scrubber) Text

func (c *Scrubber) Text(s string) string

Text cleans one piece of text.

func (*Scrubber) Value

func (c *Scrubber) Value(s string, n int) string

Value cleans an attribute value, which may also name a destination: DNS names go too. The result is cut to n bytes.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the OpsService.

func New

func New(cfg Config) *Service

New returns the service.

func (*Service) Handler

func (s *Service) Handler(opts ...connect.HandlerOption) (string, http.Handler)

Handler is the Connect handler, mounted at /api/mistgate.ops.v1.OpsService/ behind the session middleware.

func (*Service) MetricsHandler

func (s *Service) MetricsHandler() func(w http.ResponseWriter, r *http.Request) bool

MetricsHandler serves /metrics and reports whether it answered. Off, or with no token made yet, it writes nothing and returns false, so the admin answers as for any unknown path. A missing or wrong token: 401.

Jump to

Keyboard shortcuts

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