Documentation
¶
Overview ¶
Package tunnel manages a Cloudflare "quick tunnel" (cloudflared) as a child process, exposing the local control plane at a public https://*.trycloudflare.com URL with no account or public IP required. It parses the assigned URL from cloudflared's stderr and surfaces start/stop/status so the UI can drive it.
cloudflared is an EXTERNAL binary (not a Go dependency): the manager detects it on PATH and never downloads it — a supply-chain-hygiene choice matching how the project treats adb/idevice tooling. When it is absent, Status.Installed is false and the UI shows install guidance.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("tunnel manager is closed")
ErrClosed is returned when Start is called after Manager.Close.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager owns at most one cloudflared process at a time.
func New ¶
New builds a Manager. controlPort returns the loopback port string (e.g. "9966") the tunnel should forward to.
func (*Manager) Close ¶ added in v1.6.0
func (m *Manager) Close()
Close stops the child process, waits for every child to be reaped, then stops the callback dispatcher. It is safe to call repeatedly.
func (*Manager) SetOnURL ¶
SetOnURL registers a callback fired when the public URL becomes known, and again with "" when the tunnel stops. Used to broadcast a live UI update.
func (*Manager) Start ¶
Start launches cloudflared if not already running. It is idempotent — a second call while running just returns the current status. The public URL is filled in asynchronously as cloudflared reports it. The caller is responsible for ensuring authentication is configured before exposing the surface (see the control layer, which refuses to start a tunnel with no API keys).
type Status ¶
type Status struct {
Installed bool `json:"installed"` // cloudflared is on PATH
Running bool `json:"running"` // a tunnel process is live
URL string `json:"url"` // public URL (fills in shortly after start)
Err string `json:"err"` // last error (start failure / crash)
StartedAt int64 `json:"startedAt"` // unix millis
}
Status is a snapshot of the tunnel manager's state.