Documentation
¶
Overview ¶
Package tunnel publishes a local HTTP listener on a public https URL through a third-party connector, so devices that cannot route to the host (a phone on cellular, a laptop on another network) can still enroll and join the mesh. Providers wrap external programs; the mesh only learns the resulting URL, which it advertises exactly like a configured external URL.
Index ¶
Constants ¶
const CloudflaredLicenseURL = "https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/license/"
CloudflaredLicenseURL is what a user accepts by installing cloudflared.
const CloudflaredVersion = "2026.9.1"
CloudflaredVersion is the cloudflared release this build knows how to install. Bump it together with cloudflaredAssets: the digests are the only thing standing between "download from GitHub" and "run whatever answered".
const DefaultCloudflaredReleaseURL = "https://github.com/cloudflare/cloudflared/releases/download/"
DefaultCloudflaredReleaseURL is the GitHub releases download prefix.
Variables ¶
ErrCloudflaredUnavailable is returned when no usable cloudflared exists and the provider was not allowed to install one.
Functions ¶
Types ¶
type Cloudflare ¶
type Cloudflare struct {
// Binary is an explicit cloudflared executable; when set, nothing else
// is tried.
Binary string
// Timeout bounds how long Open waits for the URL; defaults to 30s.
Timeout time.Duration
// InstallDir is where a downloaded cloudflared is kept (sam-one uses
// <data-dir>/bin). Empty disables both the cache and downloads.
InstallDir string
// Consent is asked before downloading; installing cloudflared means
// accepting Cloudflare's license, so this must be an explicit choice.
// Nil never downloads.
Consent func(version, url string) bool
// ReleaseURL overrides the GitHub release download prefix (mirrors,
// tests). The pinned digests still apply.
ReleaseURL string
// HTTPClient performs the download; nil uses a 10 minute timeout.
HTTPClient *http.Client
}
Cloudflare opens a TryCloudflare quick tunnel: `cloudflared tunnel --url <target>` publishes the target on a random https://*.trycloudflare.com subdomain with no account or login. Quick tunnels are a development convenience with no SLA; cloudflared prints the assigned URL on its log output, which is the only thing this provider parses.
The connector binary is resolved in order: Binary if set, `cloudflared` on PATH, a previously installed copy under InstallDir whose digest still matches the pin, and finally a fresh download of the pinned release, which happens only if Consent agrees. A cached copy that fails verification is never run.
type Provider ¶
type Provider interface {
// Name is the operator-facing identifier (e.g. "cloudflare").
Name() string
// Open publishes target, a local http://host:port URL, and returns once
// the public URL is known or ctx expires.
Open(ctx context.Context, target string) (Tunnel, error)
}
Provider opens tunnels through one connector implementation.
type Tunnel ¶
type Tunnel interface {
// URL is the public https base URL that reaches the local target.
URL() string
// Done is closed once the tunnel has stopped forwarding, for whatever
// reason; Err then reports why (nil after Close).
Done() <-chan struct{}
Err() error
// Close tears the tunnel down.
Close() error
}
Tunnel is an open public endpoint forwarding to a local target.