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 Peers
- type Service
- func (s *Service) BlockPeer(_ context.Context, req *connect.Request[holtv1.BlockPeerRequest]) (*connect.Response[holtv1.BlockPeerResponse], error)
- func (s *Service) ForgetPeer(ctx context.Context, req *connect.Request[holtv1.ForgetPeerRequest]) (*connect.Response[holtv1.ForgetPeerResponse], 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) ListEvents(_ context.Context, _ *connect.Request[holtv1.ListEventsRequest]) (*connect.Response[holtv1.ListEventsResponse], error)
- func (s *Service) ListPeers(ctx context.Context, _ *connect.Request[holtv1.ListPeersRequest]) (*connect.Response[holtv1.ListPeersResponse], 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 WithPeers ¶ added in v0.48.0
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
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 ¶
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) ForgetPeer ¶ added in v0.48.0
func (s *Service) ForgetPeer( ctx context.Context, req *connect.Request[holtv1.ForgetPeerRequest], ) (*connect.Response[holtv1.ForgetPeerResponse], error)
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 ¶
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) ListEvents ¶ added in v0.48.0
func (s *Service) ListEvents( _ context.Context, _ *connect.Request[holtv1.ListEventsRequest], ) (*connect.Response[holtv1.ListEventsResponse], error)
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
func (s *Service) ListPeers( ctx context.Context, _ *connect.Request[holtv1.ListPeersRequest], ) (*connect.Response[holtv1.ListPeersResponse], error)
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) 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).