dial

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 13 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 dial is the client half of the holt: a persistent attach loop that dials the hub, serves an http.Handler over the reverse tunnel, and redials with jittered backoff until the context ends or the hub sends a terminal GoAway.

The loop rides an existing *grpc.ClientConn, so it reuses whatever connection (and auth interceptors) the application already holds to the hub — the tunnel is one more stream on that connection, not a second dial.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, opts Options) error

Run attaches to the hub and serves Handler over the tunnel, redialing with jittered exponential backoff (500 ms doubling to 30 s) until ctx is cancelled or the hub sends a terminal GoAway. A successful handshake resets the backoff. Returns nil on a terminal GoAway (clean exit) and ctx.Err() on shutdown.

Types

type Options

type Options struct {
	// Conn is the peer's existing gRPC connection to the hub. The
	// attach loop opens one Tunnel.Attach stream on it.
	Conn grpc.ClientConnInterface
	// Handler is served over the tunnel — the hub dials it as if it
	// were a normal HTTP server.
	Handler http.Handler
	// Version is the peer build version, sent in Hello (observability).
	Version string
	Logger  *zap.Logger

	// TLSConfig, when set, encrypts the payload end-to-end INSIDE the
	// tunnel: after the plaintext holt handshake the peer runs a
	// TLS server over the stream and serves Handler over HTTPS. The
	// hub must dial with a matching client config (hub.WithPeerTLS).
	// This is independent of any TLS on the outer gRPC connection —
	// it stays encrypted even if that hop is plaintext or terminated
	// at a proxy. NextProtos is forced to h2.
	TLSConfig *tls.Config
}

Options wires one attach loop.

Jump to

Keyboard shortcuts

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