admin

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 9 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 admin implements the holt hub's Admin gRPC service over a *registry.Registry: list live tunnels, force one closed, and — when a Blocker is supplied — ban/unban a peer id. Mount the returned connect handler behind whatever operator auth you use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockedPeer

type BlockedPeer = blocklist.BlockedPeer

BlockedPeer is one entry in the peer-id denylist.

type Blocker

type Blocker interface {
	Block(peer string)
	Unblock(peer string)
	Blocked() []BlockedPeer
}

Blocker is the hub-side peer-id denylist BlockPeer/UnblockPeer drive, and ListBlocked reads. The ban is on the identity, not one token. The holt library has no notion of credentials, so the application supplies this (e.g. a JWT-subject blocklist the auth middleware consults). Optional — without it, BlockPeer/UnblockPeer return Unimplemented and ListBlocked is empty.

type HubInfo

type HubInfo struct {
	Version       string
	Commit        string
	AdvertiseAddr string
	ProxyAddr     string
	RouteHeader   string
	MetricsAddr   string // empty when metrics are off
	ExternalURL   string
	TokenTTL      time.Duration
	// ProxyRouting is how the proxy picks the target peer: "header",
	// "subdomain", or "both". ProxyDomain is the base domain the
	// subdomain strategies match (<peer>.<domain>), empty when
	// subdomain routing is off.
	ProxyRouting string
	ProxyDomain  string
}

HubInfo is the static hub metadata Info reports alongside the live counts. The library has no notion of these (build, listener addresses), so the application supplies them.

type Option

type Option func(*Service)

Option configures a Service.

func WithBlocker

func WithBlocker(b Blocker) Option

WithBlocker enables BlockPeer/UnblockPeer, wiring them to the given credential denylist.

func WithInfo

func WithInfo(i HubInfo) Option

WithInfo supplies the static metadata Info reports.

func WithPeers added in v0.48.0

func WithPeers(p Peers) Option

WithPeers supplies the durable peer log ListPeers reports. Without it, ListPeers reports only what is attached right now.

func WithRequests added in v0.37.0

func WithRequests(b *reqlog.Broker) Option

WithRequests enables WatchRequests, streaming from the broker the proxy publishes into. Without it the RPC is Unimplemented.

type Peers added in v0.48.0

type Peers interface {
	List(ctx context.Context) ([]peerlog.Record, error)
	// Forget drops one peer's record, for a name enrolled by mistake.
	Forget(ctx context.Context, peer string) error
}

Peers reads the hub's durable peer log, the set of peers it knows whether or not they are attached. Optional: without it ListPeers falls back to the live tunnels, which is what a hub keeping no log can honestly report.

type Service

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

Service implements holtv1connect.AdminHandler against a Registry.

func NewService

func NewService(registry *registry.Registry, opts ...Option) *Service

NewService wires the Admin service to a Registry.

func (*Service) BlockPeer

BlockPeer blocks a peer's credential and closes its live tunnel with a token-revoked GoAway.

func (*Service) ForgetPeer added in v0.48.0

ForgetPeer drops peer from the peer log. An attached peer is refused: the tunnel list would still show it, so the only thing forgetting could achieve is a list that disagrees with itself.

func (*Service) Info

Info reports a snapshot of the hub: the static metadata supplied via WithInfo, plus the live tunnel and blocked counts.

func (*Service) ListBlocked

ListBlocked returns the currently-blocked peers, or an empty list when no blocker is configured.

func (*Service) ListEvents added in v0.48.0

ListEvents returns the attach/detach backlog the registry still holds, oldest first: what a client that subscribed just now would have missed.

func (*Service) ListPeers added in v0.48.0

ListPeers reports every peer the hub remembers, with the live ones marked. The peer log is the source of the set; the registry is the source of "attached", since only this hub knows its own tunnels. A peer attached but missing from the log (a log write that failed, or no log at all) is still reported: what is demonstrably connected cannot be absent from the list.

func (*Service) WatchRequests added in v0.37.0

WatchRequests streams what the proxy carried, as each response completes: the few events the broker still holds, then live ones. A request naming a peer gets only that peer's, filtered here. Without a Requests broker the hub carries no such view, which is Unimplemented rather than a stream that never sends. Returns when the client goes away.

func (*Service) WatchTunnels

WatchTunnels streams the live-tunnel set: a snapshot of the current tunnels as ATTACHED events, then live attach/detach transitions. The subscription is opened before the snapshot is read, so nothing falls in the gap; the overlap can produce a duplicate ATTACHED, which clients must treat as idempotent. Returns when the client goes away or the registry drops this watcher for being too slow (the client resubscribes and gets a fresh snapshot).

Jump to

Keyboard shortcuts

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