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 ¶
- type BlockedPeer
- type Blocker
- type HubInfo
- type Option
- type Service
- func (s *Service) BlockPeer(_ context.Context, req *connect.Request[holtv1.BlockPeerRequest]) (*connect.Response[holtv1.BlockPeerResponse], error)
- func (s *Service) Info(_ context.Context, _ *connect.Request[holtv1.InfoRequest]) (*connect.Response[holtv1.InfoResponse], error)
- func (s *Service) ListBlocked(_ context.Context, _ *connect.Request[holtv1.ListBlockedRequest]) (*connect.Response[holtv1.ListBlockedResponse], error)
- func (s *Service) ListTunnels(_ context.Context, _ *connect.Request[holtv1.ListTunnelsRequest]) (*connect.Response[holtv1.ListTunnelsResponse], error)
- func (s *Service) StopTunnel(_ context.Context, req *connect.Request[holtv1.StopTunnelRequest]) (*connect.Response[holtv1.StopTunnelResponse], error)
- func (s *Service) UnblockPeer(_ context.Context, req *connect.Request[holtv1.UnblockPeerRequest]) (*connect.Response[holtv1.UnblockPeerResponse], error)
- func (s *Service) WatchRequests(ctx context.Context, req *connect.Request[holtv1.WatchRequestsRequest], ...) error
- func (s *Service) WatchTunnels(ctx context.Context, _ *connect.Request[holtv1.WatchTunnelsRequest], ...) error
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 ¶
WithBlocker enables BlockPeer/UnblockPeer, wiring them to the given credential denylist.
func WithRequests ¶ added in v0.37.0
WithRequests enables WatchRequests, streaming from the broker the proxy publishes into. Without it the RPC is Unimplemented.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service implements holtv1connect.AdminHandler against a Registry.
func NewService ¶
NewService wires the Admin service to a Registry.
func (*Service) BlockPeer ¶
func (s *Service) BlockPeer( _ context.Context, req *connect.Request[holtv1.BlockPeerRequest], ) (*connect.Response[holtv1.BlockPeerResponse], error)
BlockPeer blocks a peer's credential and closes its live tunnel with a token-revoked GoAway.
func (*Service) Info ¶
func (s *Service) Info( _ context.Context, _ *connect.Request[holtv1.InfoRequest], ) (*connect.Response[holtv1.InfoResponse], error)
Info reports a snapshot of the hub: the static metadata supplied via WithInfo, plus the live tunnel and blocked counts.
func (*Service) ListBlocked ¶
func (s *Service) ListBlocked( _ context.Context, _ *connect.Request[holtv1.ListBlockedRequest], ) (*connect.Response[holtv1.ListBlockedResponse], error)
ListBlocked returns the currently-blocked peers, or an empty list when no blocker is configured.
func (*Service) ListTunnels ¶
func (*Service) StopTunnel ¶
func (*Service) UnblockPeer ¶
func (*Service) WatchRequests ¶ added in v0.37.0
func (s *Service) WatchRequests( ctx context.Context, req *connect.Request[holtv1.WatchRequestsRequest], stream *connect.ServerStream[holtv1.RequestEvent], ) error
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 ¶
func (s *Service) WatchTunnels( ctx context.Context, _ *connect.Request[holtv1.WatchTunnelsRequest], stream *connect.ServerStream[holtv1.TunnelEvent], ) error
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).