cloudflare

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultPIDPath

func DefaultPIDPath() string

DefaultPIDPath returns the default path for the cloudflared PID file.

func IsRunning

func IsRunning(pid int) bool

IsRunning returns true if a process with the given PID exists and is alive.

func ReadPID

func ReadPID(pidPath string) (int, error)

ReadPID reads the PID from the given file. Returns an error if the file doesn't exist or is malformed.

func ReloadDaemon

func ReloadDaemon(cfgPath, tunnelID, pidPath string) error

ReloadDaemon restarts the cloudflared daemon so it picks up an updated config file. If the daemon is not running, this is a no-op (returns nil).

func StartDaemon

func StartDaemon(cfgPath, tunnelID, pidPath string) (int, error)

StartDaemon launches cloudflared as a background process using the given config file and tunnel ID. Returns the PID of the new process. If cloudflared is already running (valid PID file), returns an error.

func StopDaemon

func StopDaemon(pidPath string) (int, error)

StopDaemon sends SIGTERM to the cloudflared process identified by pidPath.

func SyncTunnel

func SyncTunnel(sessions map[string]*caddy.SessionInfo, tunnelID, credentialsFile, domain, cfgPath string) error

SyncTunnel generates the cloudflared config file from current sessions. Skips if domain or tunnelID is empty.

Types

type CloudflaredConfig

type CloudflaredConfig struct {
	Tunnel          string        `yaml:"tunnel"`
	CredentialsFile string        `yaml:"credentials-file"`
	Ingress         []IngressRule `yaml:"ingress"`
}

CloudflaredConfig represents the full cloudflared YAML config

type IngressRule

type IngressRule struct {
	Hostname      string         `yaml:"hostname,omitempty"`
	Service       string         `yaml:"service"`
	OriginRequest *OriginRequest `yaml:"originRequest,omitempty"`
}

IngressRule represents one cloudflared ingress rule

type OriginRequest

type OriginRequest struct {
	HTTPHostHeader string `yaml:"httpHostHeader,omitempty"`
}

OriginRequest holds per-rule origin connection options.

type TunnelCheckResult

type TunnelCheckResult struct {
	BinaryInstalled   bool
	TunnelExists      bool
	TunnelExistsError string
	ConfigExists      bool
	ConfigValid       bool
	ConfigError       string
	IngressMismatch   bool
	MissingRules      []string
	DNSValid          bool
	DNSError          string
}

TunnelCheckResult holds the result of a cloudflare tunnel health check

func CheckTunnel

func CheckTunnel(sessions map[string]*caddy.SessionInfo, tunnelID, domain, cfgPath string) TunnelCheckResult

CheckTunnel performs a comprehensive health check of the cloudflare tunnel setup.

Jump to

Keyboard shortcuts

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