cloudflare

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 11, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package cloudflare routes apps through a Cloudflare Tunnel (R-160, design 03 §4.5).

cloudflared runs beside Pando and dials out to Cloudflare, so nothing on this machine needs to be reachable from the internet and Cloudflare issues the certificates. Every ingress rule this adapter writes sends traffic to Pando's proxy — never to an app's container. R-023 has no exception for a tunnel: a rule pointing at a workload would be a way to an app that skips authorization, and it would work, which is why the instinct is dangerous.

Cloudflare Access is not configured here. It could only ever be a layer in front of Pando's proxy, never the only check; whether Pando should manage it at all is O-23.

Index

Constants

View Source
const DefaultAPIBase = "https://api.cloudflare.com/client/v4"

DefaultAPIBase is Cloudflare's API.

View Source
const DefaultImage = "cloudflare/cloudflared:2025.1.0"

DefaultImage is the cloudflared this release of Pando runs.

View Source
const Kind = "cloudflare"

Kind is the adapter's kind string.

View Source
const ManagedComment = "Managed by Pando — changes are reset"

ManagedComment marks every DNS record Pando created. A record without it is not Pando's, and Pando never changes or removes one (design 03 §4.5).

Variables

This section is empty.

Functions

func Info

func Info() api.KindInfo

Info describes this kind of adapter for the forms that configure one (api.KindInfo, R-261).

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter writes a tunnel's ingress and DNS through Cloudflare's API.

func New

func New() *Adapter

func (*Adapter) Capabilities

func (a *Adapter) Capabilities(context.Context) (api.RoutingCapabilities, error)

Capabilities: subdomain by default, path under the console hostname (R-164).

TLS is Cloudflare's: its included certificate covers the zone and one level below, which is exactly where apps are named.

func (*Adapter) Category

func (a *Adapter) Category() api.Category

func (*Adapter) Configure

func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error

func (*Adapter) Edge

func (a *Adapter) Edge(ctx context.Context, r api.EdgeRequest) (api.EdgePlan, bool, error)

Edge makes sure the tunnel exists and routes the console, then describes the cloudflared that holds it open (R-174).

func (*Adapter) Ensure

func (a *Adapter) Ensure(ctx context.Context, r api.RouteRequest) (api.RouteHandle, error)

Ensure writes an app's ingress rule and, for its own hostname, a DNS record.

Idempotent: the rule is found by hostname and path and replaced whole, so a change someone made to it in Cloudflare's dashboard is reset here — which is how the reconciler's next pass undoes drift.

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(ctx context.Context) error

HealthCheck asks Cloudflare whether the token can see the zone.

func (*Adapter) Kind

func (a *Adapter) Kind() string

func (*Adapter) Observe

func (a *Adapter) Observe(ctx context.Context, h api.RouteHandle) (api.RouteState, error)

Observe reads the rule back. It reports and never remediates (design 05): a rule changed in the dashboard shows here as pointing elsewhere, and the reconciler's next Ensure puts it back.

func (*Adapter) Remove

func (a *Adapter) Remove(ctx context.Context, h api.RouteHandle) error

Remove deletes the app's rule, and its DNS record when Pando made one and no other rule still needs the name.

type Config

type Config struct {
	AccountID string `json:"account_id"`

	// Zone is the Cloudflare zone apps are named in, such as example.com. An
	// app is <app>.<zone>, never deeper: Cloudflare's included certificate
	// covers *.zone and nothing below it, so a deeper name would have no
	// HTTPS. There is deliberately no setting for one.
	Zone string `json:"zone"`

	// ConsoleHostname is where the console is served, and the host path-mode
	// apps are served under. Empty is the zone itself.
	ConsoleHostname string `json:"console_hostname,omitempty"`

	// TunnelID attaches to an existing tunnel instead of creating one. Pando
	// still writes its rules into that tunnel's ingress, and leaves the rules
	// it did not write alone.
	TunnelID string `json:"tunnel_id,omitempty"`

	// Image is the cloudflared image. Pinned by Pando's release; set to
	// override.
	Image string `json:"image,omitempty"`

	// APIBase is Cloudflare's API. Settable for tests, not offered in the form.
	APIBase string `json:"api_base,omitempty"`

	Credentials struct {
		APIToken secret.Value `json:"api_token,omitzero"`
	} `json:"credentials,omitzero"`
}

Config is the adapter's configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL