echo

command
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 10 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.

README

echo — minimal reverse-tunnel demo

Stands up a hub and a peer in one process. The peer serves an HTTP handler and never listens; the hub reaches that handler by dialing back through the tunnel the peer opened.

go run ./examples/echo

Output:

hub → peer GET /whoami  ⇒  200  "I am the peer; the hub reached me through the tunnel"

The only inbound listener in the program is the hub's. That is the whole point: the peer is reachable without a port, a public address, or a hole in its firewall.

Key calls, in order:

  1. hub.NewRegistry + hub.NewHandler mounted on a plain HTTP server, the hub side (the handler accepts the WebSocket upgrade itself).
  2. dial.Run(ctx, dial.Options{URL, Handler}), the peer attaches over a ws:// WebSocket and serves.
  3. registry.RoundTripper(peer) wrapped in an http.Client — the hub dials through.

For a hub that authenticates peers and derives their identity from a token, see ../authenticated.

Documentation

Overview

Command echo is the smallest end-to-end holt demo: it stands up a hub and a peer in one process, the peer serves an HTTP handler that only it could serve, and the hub reaches that handler by dialing back THROUGH the tunnel the peer opened.

Nothing listens on the peer. The only inbound listener in the whole program is the hub's — exactly the point of a reverse tunnel.

Run:

go run ./examples/echo

Expected output:

hub → peer GET /whoami  ⇒  200  "I am the peer; the hub reached me through the tunnel"

Jump to

Keyboard shortcuts

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