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