starter-client

command
v0.42.0 Latest Latest
Warning

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

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

README

starter-client — a peer you can copy

The smallest useful holt peer: it joins a hub with a token from holt enroll, serves one HTTP handler over the tunnel, and listens on nothing. Copy main.go and replace the handler with your own service — it has no dependency on the holt CLI's internals (the join token is decoded inline).

# on the hub machine
holt hub &
holt enroll myservice        # prints a token

# anywhere (paste the token)
go run ./cmd/starter-client --token eyJ...

# reach it through the hub
curl -H 'x-tunnel-peer: myservice' http://localhost:7202/
#   hello from myservice — reached through the tunnel

The three steps every peer does

main.go is organised around them:

  1. Decode the token: it is a JWT in compact serialization, so split on ., base64url-decode the payload, and read sub (the peer name) and aud (the tunnel URL to dial). The signature is not checked here, the peer holds no key; the hub verifies it on attach. Tokens minted before v0.20 were a base64 JSON envelope, which the holt CLI still accepts but this starter does not.
  2. Build your handler, the one thing you customise.
  3. dial.Run, attach and serve, redialing automatically. The token's tunnel URL picks the transport (wss is a TLS WebSocket verified with the system roots, ws is plaintext, http/https are aliases so older tokens keep working), and the JWT goes out as the Authorization header of the upgrade request.

That's the whole client. Everything else (the CLI, TLS files, SQLite, the admin API) is the hub's concern.

Documentation

Overview

Command starter-client is a minimal, self-contained holt peer — a template to copy when writing your own client. It joins a hub with a token from `holt enroll`, serves one HTTP handler over the tunnel, and listens on nothing.

Everything a peer needs is here and nothing else: token.Decode the join token, then holt.NewClient your handler (JWT auth rides the WebSocket upgrade; the tunnel URL's scheme picks the transport). Only public packages are used — copy this file and go.

# on the hub machine:
holt hub &
holt enroll myservice        # prints a token

# anywhere:
go run ./cmd/starter-client --token <paste>

# reach it through the hub:
curl -H 'x-tunnel-peer: myservice' http://localhost:7202/

Jump to

Keyboard shortcuts

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