How kernelshard/expose works
Expose is a Go CLI for publishing a local development server through LocalTunnel, Cloudflare, or a self-hosted server. The main workflow loads the configured or overridden local port, selects a provider, starts a tunnel service, displays its public URL, and closes it on shutdown. Configuration initialization and inspection are separate CLI capabilities; self-hosting adds server startup, client registration, and public request forwarding. The graph follows documented capabilities and sampled call paths; Cloudflare’s implementation and several CLI handlers were not sampled, so their internal wiring is limited.
Main entry points: server.go Tunnel server · selfhosted.go Self-hosted provider · root.go CLI commands · tunnel.go Tunnel command
Components 22
CLI and configuration
- CLI entry
cmd/expose/main.go - CLI commands
internal/cli/root.go - Tunnel command
internal/cli/tunnel.go - Config commands
internal/cli - Init command
internal/cli/init.go - YAML config
internal/config/config.go
Tunnel lifecycle
- Tunnel service
internal/tunnel/service.go - Provider interface
internal/tunnel/provider.go
Provider integrations
- LocalTunnel provider
internal/provider/localtunnel.go - Cloudflare provider
internal/provider/cloudflare.go - Self-hosted provider
internal/provider/selfhosted.go
Self-hosted server
- Server command
internal/cli/server.go - Tunnel server
internal/server/server.go - Tunnel protocol
internal/server/protocol/protocol.go - Subdomain assignment
internal/server/subdomain.go - Active tunnels
internal/server/server.go - Data connections
internal/server/server.go
Other components
- Developer
- Local HTTP server
- LocalTunnel service
- Cloudflare service
- Public HTTP client
Connections 33
- Developer → CLI entry: runs CLI
- CLI entry → CLI commands: executes
- CLI commands → Tunnel command: dispatches
- CLI commands → Config commands: dispatches
- CLI commands → Init command: dispatches
- Init command → YAML config: creates config
- Config commands → YAML config: reads or updates
- Tunnel command → YAML config: loads port
- Tunnel command → Tunnel service: starts service
- Tunnel service → Provider interface: calls provider
- Provider interface → LocalTunnel provider: implemented by
- Provider interface → Cloudflare provider: implemented by
- Provider interface → Self-hosted provider: implemented by
- LocalTunnel provider → LocalTunnel service: requests tunnel
- LocalTunnel service → LocalTunnel provider: returns tunnel details
- LocalTunnel provider → Local HTTP server: forwards traffic
- Cloudflare provider → Cloudflare service: connects to
- Cloudflare provider → Local HTTP server: forwards traffic
- Tunnel command → Server command: starts separately
- Server command → Tunnel server: starts server
- Self-hosted provider → Tunnel server: registers tunnel
- Self-hosted provider → Tunnel protocol: encodes request
- Tunnel server → Tunnel protocol: decodes request
- Tunnel server → Subdomain assignment: assigns subdomain
- Tunnel server → Active tunnels: registers tunnel
- Tunnel server → Data connections: queues data connection
- Self-hosted provider → Data connections: opens data connection
- Public HTTP client → Tunnel server: sends HTTP request
- Tunnel server → Data connections: takes connection
- Tunnel server → Self-hosted provider: forwards request
- Self-hosted provider → Local HTTP server: proxies request
- Self-hosted provider → Tunnel server: returns response
- Tunnel server → Public HTTP client: forwards response