hubapi

package
v0.44.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT 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 hubapi is the hub's own HTTP surface on the admin listener, alongside the Admin gRPC service: the enroll endpoint that mints join tokens, and — with --ui — the web console with its config and rotate-secret endpoints.

Each endpoint group is a config struct that mounts itself, so the command reads as what it exposes:

hubapi.Enroll{Secret: secret, TunnelURL: advertised, TTL: ttl}.Mount(mux)
hubapi.Console{...}.Mount(mux)

The listener is plaintext and has no built-in auth (these endpoints mint tokens and rotate secrets): keep it on loopback or behind an authenticating proxy, and use httpsrv.HostGuard in front.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaptureManager added in v0.44.0

type CaptureManager interface {
	Create(name string, ttl time.Duration) (capture.Bin, error)
	List() []capture.Bin
	Stop(name string) bool
}

CaptureManager is the endpoint lifecycle the console drives; *capture.Manager satisfies it.

type Captures added in v0.44.0

type Captures struct {
	Manager CaptureManager
}

Captures serves the console's capture endpoints. Console-only, like the rest of the UI surface.

func (Captures) Mount added in v0.44.0

func (c Captures) Mount(mux *http.ServeMux)

Mount registers the capture endpoints on mux.

type Config

type Config struct {
	RouteHeader  string `json:"routeHeader"`
	ProxyPort    string `json:"proxyPort"`
	ExternalURL  string `json:"externalURL"`
	TunnelURL    string `json:"tunnelURL"`
	MetricsPort  string `json:"metricsPort"`
	ProxyRouting string `json:"proxyRouting"`
	ProxyDomain  string `json:"proxyDomain"`
}

Config is what GET /api/config reports to the console: the addresses and routing settings the UI needs to show working commands. The JSON names are the console's contract — ui/src/App.tsx reads exactly these keys.

type Console

type Console struct {
	// Identity is where the signing secret lives, whichever backend
	// the hub was pointed at.
	Identity hubsecret.Store
	// Secret is the live signing secret, hot-swapped by rotate.
	Secret *jwtauth.Secret
	// Tunnels are closed when the secret rotates.
	Tunnels Tunnels
	// Settings is the payload GET /api/config answers with.
	Settings Config
	// Path serves the console from this directory instead of the
	// embedded build. Empty uses the embedded one.
	Path string
	// Logger records the rotate, which is worth a line in the log.
	Logger *zap.Logger
}

Console serves the web console: its static build, the settings it reads at startup, and the danger-zone rotate endpoint. Identity, Secret, Tunnels, and Logger are required — rotating without any one of them would leave tokens alive that the operator was told are dead.

func (Console) Mount

func (c Console) Mount(mux *http.ServeMux)

Mount registers the console endpoints and the static build on mux. The static handler takes "/", so mount it after any other route.

type Enroll

type Enroll struct {
	// Secret signs the minted token. Read per request, so a rotate
	// takes effect immediately.
	Secret *jwtauth.Secret
	// TunnelURL is the URL stamped into tokens when the caller names
	// none: what peers dial to reach this hub.
	TunnelURL string
	// TTL is how long a minted token stays valid.
	TTL time.Duration
}

Enroll serves POST /api/enroll: mint a join token for a peer. It is always mounted, not gated on the console, so `holt enroll` works against a remote hub — the hub supplies its own advertise address.

func (Enroll) Mount

func (e Enroll) Mount(mux *http.ServeMux)

Mount registers the enroll endpoint on mux.

type Tunnels

type Tunnels interface {
	// CountTunnels reports how many peers are attached right now.
	CountTunnels() int
	// StopAllTunnels closes every tunnel with the given GoAway reason.
	StopAllTunnels(reason string)
}

Tunnels is the live-tunnel side rotate-secret closes: *registry.Registry satisfies it.

Jump to

Keyboard shortcuts

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