cf

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const TXT_PREFIX = "_managed."

TXT_PREFIX is the prefix added to TXT records for whom the corresponding DNS records are managed by the operator.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Log              logr.Logger
	TunnelName       string
	TunnelId         string
	AccountName      string
	AccountId        string
	Domain           string
	ValidAccountId   string
	ValidTunnelId    string
	ValidTunnelName  string
	ValidZoneId      string
	CloudflareClient *cloudflare.API
}

API config object holding all relevant fields to use the API

func (*API) CreateTunnel

func (c *API) CreateTunnel() (string, string, error)

CreateTunnel creates a Cloudflare Tunnel and returns the tunnel Id and credentials file

func (*API) DeleteDNSId

func (c *API) DeleteDNSId(fqdn, dnsId string, created bool) error

DeleteDNSId deletes DNS entry for the given dnsId

func (*API) DeleteTunnel

func (c *API) DeleteTunnel() error

DeleteTunnel deletes a Cloudflare Tunnel

func (*API) GetAccountId

func (c *API) GetAccountId() (string, error)

GetAccountId gets AccountId from Account Name

func (*API) GetDNSCNameId

func (c *API) GetDNSCNameId(fqdn string) (string, error)

GetDNSCNameId returns the ID of the CNAME record requested

func (*API) GetManagedDnsTxt

func (c *API) GetManagedDnsTxt(fqdn string) (string, DnsManagedRecordTxt, bool, error)

GetManagedDnsTxt gets the TXT record corresponding to the fqdn

func (*API) GetTunnelCreds

func (c *API) GetTunnelCreds(tunnelSecret string) (string, error)

GetTunnelCreds gets Tunnel Credentials from Tunnel secret

func (*API) GetTunnelId

func (c *API) GetTunnelId() (string, error)

GetTunnelId gets Tunnel Id from available information

func (*API) GetZoneId

func (c *API) GetZoneId() (string, error)

GetZoneId gets Zone Id from DNS domain

func (*API) InsertOrUpdateCName

func (c *API) InsertOrUpdateCName(fqdn, dnsId string) (string, error)

InsertOrUpdateCName upsert DNS CNAME record for the given FQDN to point to the tunnel

func (*API) InsertOrUpdateTXT

func (c *API) InsertOrUpdateTXT(fqdn, txtId, dnsId string) error

InsertOrUpdateTXT upsert DNS TXT record for the given FQDN to point to the tunnel

func (*API) ValidateAll

func (c *API) ValidateAll() error

ValidateAll validates the contents of the API struct

type Configuration

type Configuration struct {
	TunnelId      string                   `yaml:"tunnel"`
	Ingress       []UnvalidatedIngressRule `yaml:"ingress,omitempty"`
	WarpRouting   WarpRoutingConfig        `yaml:"warp-routing,omitempty"`
	OriginRequest OriginRequestConfig      `yaml:"originRequest,omitempty"`
	SourceFile    string                   `yaml:"credentials-file"`
	Metrics       string                   `yaml:"metrics,omitempty"`
	NoAutoUpdate  bool                     `yaml:"no-autoupdate,omitempty"`
}

Configuration is a cloudflared configuration yaml model https://github.com/cloudflare/cloudflared/blob/master/config/configuration.go

type DnsManagedRecordTxt

type DnsManagedRecordTxt struct {
	DnsId      string // DnsId of the managed record
	TunnelName string // TunnelName of the managed record
	TunnelId   string // TunnelId of the managed record
}

DnsManagedRecordTxt object that represents each managed DNS record in a separate TXT record

type IngressIPRule

type IngressIPRule struct {
	Prefix *string `yaml:"prefix,omitempty"`
	Ports  []int   `yaml:"ports,omitempty"`
	Allow  bool    `yaml:"allow,omitempty"`
}

IngressIPRule is a cloudflared origin ingress IP rule config model

type OriginRequestConfig

type OriginRequestConfig struct {
	// HTTP proxy timeout for establishing a new connection
	ConnectTimeout *time.Duration `yaml:"connectTimeout,omitempty"`
	// HTTP proxy timeout for completing a TLS handshake
	TLSTimeout *time.Duration `yaml:"tlsTimeout,omitempty"`
	// HTTP proxy TCP keepalive duration
	TCPKeepAlive *time.Duration `yaml:"tcpKeepAlive,omitempty"`
	// HTTP proxy should disable "happy eyeballs" for IPv4/v6 fallback
	NoHappyEyeballs *bool `yaml:"noHappyEyeballs,omitempty"`
	// HTTP proxy maximum keepalive connection pool size
	KeepAliveConnections *int `yaml:"keepAliveConnections,omitempty"`
	// HTTP proxy timeout for closing an idle connection
	KeepAliveTimeout *time.Duration `yaml:"keepAliveTimeout,omitempty"`
	// Sets the HTTP Host header for the local webserver.
	HTTPHostHeader *string `yaml:"httpHostHeader,omitempty"`
	// Hostname on the origin server certificate.
	OriginServerName *string `yaml:"originServerName,omitempty"`
	// Path to the CA for the certificate of your origin.
	// This option should be used only if your certificate is not signed by Cloudflare.
	CAPool *string `yaml:"caPool,omitempty"`
	// Disables TLS verification of the certificate presented by your origin.
	// Will allow any certificate from the origin to be accepted.
	// Note: The connection from your machine to Cloudflare's Edge is still encrypted.
	NoTLSVerify *bool `yaml:"noTLSVerify,omitempty"`
	// Attempt to connect to origin using HTTP2. Origin must be configured as https.
	Http2Origin *bool `yaml:"http2Origin,omitempty"`
	// Disables chunked transfer encoding.
	// Useful if you are running a WSGI server.
	DisableChunkedEncoding *bool `yaml:"disableChunkedEncoding,omitempty"`
	// Runs as jump host
	BastionMode *bool `yaml:"bastionMode,omitempty"`
	// Listen address for the proxy.
	ProxyAddress *string `yaml:"proxyAddress,omitempty"`
	// Listen port for the proxy.
	ProxyPort *uint `yaml:"proxyPort,omitempty"`
	// Valid options are 'socks' or empty.
	ProxyType *string `yaml:"proxyType,omitempty"`
	// IP rules for the proxy service
	IPRules []IngressIPRule `yaml:"ipRules,omitempty"`
}

OriginRequestConfig is a cloudflared origin request configuration model

type TunnelCredentialsFile

type TunnelCredentialsFile struct {
	AccountTag   string `json:"AccountTag"`
	TunnelID     string `json:"TunnelID"`
	TunnelName   string `json:"TunnelName"`
	TunnelSecret string `json:"TunnelSecret"`
}

TunnelCredentialsFile object containing the fields that make up a Cloudflare Tunnel's credentials

type UnvalidatedIngressRule

type UnvalidatedIngressRule struct {
	Hostname      string `yaml:"hostname,omitempty"`
	Path          string `yaml:"path,omitempty"`
	Service       string
	OriginRequest OriginRequestConfig `yaml:"originRequest,omitempty"`
}

UnvalidatedIngressRule is a cloudflared ingress entry model

type WarpRoutingConfig

type WarpRoutingConfig struct {
	Enabled bool `yaml:"enabled,omitempty"`
}

WarpRoutingConfig is a cloudflared warp routing model

Jump to

Keyboard shortcuts

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