Skip to main content

Module api

Module api 

Source
Expand description

POST /tunnel client for api.trycloudflare.com.

Returns the credentials the edge expects on the subsequent RegisterConnection RPC: a UUID-shaped id, the public hostname (<sub>.trycloudflare.com), the account_tag to quote on RPC, and 32 random bytes of secret that double as the TunnelSecret in the auth blob.

Mirrors cmd/cloudflared/tunnel/quick_tunnel.go upstream.

Structs§

QuickTunnel
The bits the QUIC + capnp-RPC dance needs.
QuickTunnelResponse
Public-facing JSON envelope returned by POST /tunnel.

Constants§

DEFAULT_HTTP_TIMEOUT
HTTP-level deadline for the POST.
DEFAULT_SERVICE_URL
Default endpoint (the public trycloudflare API).
DEFAULT_USER_AGENT
User-Agent we send. Mimic a recent cloudflared so the edge doesn’t trip a novelty filter. Bump in lockstep with the schema commit pinned in THIRD_PARTY_NOTICES.md.
MAX_RETRIES
How many times to retry on transient 5xx / network errors.

Functions§

request_tunnel
Fetch a fresh quick-tunnel handshake. Retries 5xx + network errors with exponential backoff (1s → 2s → 4s); never retries 4xx. Business errors inside a 200 response surface as TunnelError::ApiBusiness.