attach

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 17 Imported by: ? 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 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 comes from an application-supplied func reading the request context (JWT claims, mTLS SAN, …); the handshake itself carries none.

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 because they pass through what gRPC cannot — CDN public hostnames, access proxies, HTTP/1.1-only edges. Mount it behind the application's auth middleware.

func NewHandler

func NewHandler(registry *registry.Registry, identity Identity, logger *zap.Logger, opts ...HandlerOption) *Handler

NewHandler builds the attach handler.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP accepts one peer's reverse tunnel and serves it until the peer disconnects or the registry closes it.

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.

type Identity

type Identity func(ctx context.Context) (peer string, err error)

Identity extracts the peer ID the surrounding auth middleware established from a request context. Returning ("", err) rejects the attach.

Jump to

Keyboard shortcuts

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