Skip to content

v0.3.1 — Lease-based attach + control-plane bearer token

Choose a tag to compare

@kolkov kolkov released this 12 Sep 14:21
· 13 commits to main since this release
4231b40

Lease-based connection tracking and control-plane bearer token. Additive patch -- no API breakage, full backward compat with v0.3.0.

Added

  • GET /daemon/attach -- lease-based connection tracking (ADR-003). The TCP connection IS the lease: when the client process dies (SIGKILL, OOM, closed terminal), the kernel closes the socket and the connection count drops. No heartbeats, no timers. Replaces counting-based connect/disconnect for new clients
  • Bearer token on /daemon/* endpoints -- rand.Text() (crypto/rand) stored in PID file (0600). Authorization: Bearer <token> required for /daemon/attach, /daemon/connect, /daemon/disconnect, /daemon/shutdown. /health stays open. Constant-time comparison via crypto/subtle
  • Config.RequireToken -- when true, the bearer token is also required for the application handler (everything outside /health and /daemon/). Default false for curl debugging compatibility
  • Proxy attach with fallback -- proxy tries GET /daemon/attach first; if daemon returns 404 (v0.3.0), falls back to POST /daemon/connect + POST /daemon/disconnect. Token sent on all daemon requests when available
  • ADR-003 -- design document: why counting fails, lease via TCP, token via PID file, mixed-version matrix, alternatives rejected (heartbeats, SSE, mTLS)
  • 12 new tests (3 integration), coverage 75.5% → 85%

Deprecated

  • POST /daemon/connect and POST /daemon/disconnect -- use GET /daemon/attach instead. Kept functional for backward compatibility with v0.3.0 proxies

Security

  • DNS rebinding hardening completed: loopbackGuard (v0.1.1) + bearer token (v0.3.1). A page with a rebinding domain that passes the Host check still cannot authenticate
  • Token never appears in proxy.log, daemon stderr, or error messages

Mixed-version compatibility

Proxy Daemon Behavior
v0.3.1 v0.3.1 Lease attach + bearer token (optimal)
v0.3.1 v0.3.0 Fallback to connect/disconnect, no token (compatible)
v0.3.0 v0.3.1 connect/disconnect with token from PID file (compatible)

Full Changelog: v0.3.0...v0.3.1