examples/

directory
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: MIT

README

holt examples

Two runnable demos, in learning order. Each is a hub and a peer as separate programs — run the server, run the client, then reach the listenerless peer through the hub's proxy with curl.

Example Shows
echo Start here. The minimal pair: holt.NewServer() with zero configuration, and a peer that listens on nothing, reached through the tunnel it opened.
authenticated The identity seam: the hub derives each peer's ID from a bearer token, so tunnels are keyed by an authenticated identity the handshake never carries.
go run ./examples/echo/server           # terminal 1
go run ./examples/echo/client           # terminal 2
curl -H 'x-tunnel-peer: peer' http://127.0.0.1:7202/whoami

The tunnel's carrier is a WebSocket, so a peer names the hub by URL and the scheme picks the transport: ws:// is plaintext, wss:// is TLS on the WebSocket hop (http/https are accepted as aliases). TLS wiring — a tls.Listener on the tunnel via WithListener, or end-to-end TLS inside the tunnel via WithTunnelTLS/WithPeerTLS — is documented in the library guide.

To write a peer for the holt CLI specifically (JWT + tunnel URL from a join token), copy cmd/starter-client; it lives next to the CLI because it's coupled to that token format, not to the library.

Directories

Path Synopsis
authenticated
client command
Command client is a standalone holt peer.
Command client is a standalone holt peer.
server command
Command server is a standalone holt hub with a real identity: it accepts reverse tunnels from peers on one port and reaches those peers on another by dialing back THROUGH their tunnels.
Command server is a standalone holt hub with a real identity: it accepts reverse tunnels from peers on one port and reaches those peers on another by dialing back THROUGH their tunnels.
echo
client command
Command client is the peer half of the echo example: it dials the hub and serves an HTTP handler back over the reverse tunnel, while listening on nothing itself.
Command client is the peer half of the echo example: it dials the hub and serves an HTTP handler back over the reverse tunnel, while listening on nothing itself.
server command
Command server is the hub half of the echo example, with zero configuration: holt.NewServer() serves the tunnel on 127.0.0.1:7200 and a proxy on :7202.
Command server is the hub half of the echo example, with zero configuration: holt.NewServer() serves the tunnel on 127.0.0.1:7200 and a proxy on :7202.

Jump to

Keyboard shortcuts

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