Documentation
¶
Overview ¶
Package attach is the hub's tunnel front door: an http.Handler that accepts a peer's WebSocket upgrade, runs the holt handshake, and registers the resulting tunnel in the registry. Identity is the application's concern: the Handler is constructed with an Identity func that extracts the peer ID from the request context (JWT claims, mTLS SAN, header — whatever the surrounding middleware established). The handshake itself carries no identity.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler accepts reverse-tunnel attachments over WebSockets: the peer upgrades a plain HTTP request, then every binary message carries one TunnelFrame. WebSockets are the carrier precisely because they pass through the layers that gRPC cannot — CDN public hostnames, access proxies, HTTP/1.1-only edges.
Mount it behind the application's auth middleware; the Identity func reads whatever that middleware established from the upgrade request's context.
func NewHandler ¶
func NewHandler(registry *registry.Registry, identity Identity, logger *zap.Logger, opts ...HandlerOption) *Handler
NewHandler builds the attach handler. identity maps the authenticated request context to the registry key.
type HandlerOption ¶
type HandlerOption func(*Handler)
HandlerOption configures a Handler.
func WithPeerTLS ¶
func WithPeerTLS(cfg *tls.Config) HandlerOption
WithPeerTLS makes the hub run a TLS client over each tunnel before speaking HTTP/2, so the payload is encrypted end-to-end between hub and peer. Peers must attach with a matching TLS server config (dial.Options.TLSConfig). Use it to verify peer certificates and to keep the payload confidential even when the outer WebSocket hop is plaintext or TLS-terminated at a proxy. NextProtos is forced to h2.
func WithTracerProvider ¶
func WithTracerProvider(tp trace.TracerProvider) HandlerOption
WithTracerProvider sets the OTel TracerProvider used to span each tunnel's lifetime. Optional — without it the global provider is used, which is a no-op until the application installs an SDK.