Documentation
¶
Index ¶
- Constants
- func BuildTLSBundle(fs *pflag.FlagSet, lookupEnv func(string) (string, bool)) (*tlsconfig.Bundle, error)
- func ControlPlaneURLPathRaw(fs *pflag.FlagSet, lookupEnv func(string) (string, bool)) string
- func DefaultProfileDir(lookupEnv func(string) (string, bool)) (string, error)
- func EnvProxyConfigured(lookupEnv func(string) (string, bool)) bool
- func LoadFullFromFlagSet(fs *pflag.FlagSet, lookupEnv func(string) (string, bool)) (*Config, CloudflaredSettings, LoadContext, error)
- func NormalizeControlPlaneURLPath(raw string) (string, error)
- func NormalizeExtraHeaders(source string, headers map[string]string) (map[string]string, error)
- func ParseProxyCheckInterval(raw string) (time.Duration, error)
- func ParseURL(raw string) (*url.URL, error)
- func ProfilePath(name string, explicitDir string, lookupEnv func(string) (string, bool)) (string, string, error)
- func ProxyLogFields(proxyURL *url.URL, source ProxySource) []any
- func RedactProxyURL(proxyURL *url.URL) string
- func RegisterFlags(fs *pflag.FlagSet, flavor Flavor)
- func RegisterTLSFlags(fs *pflag.FlagSet)
- func ResolveControlPlanePath(baseURL *url.URL, urlPath, routePath string) *url.URL
- func ResolveProfileDir(explicitDir string, lookupEnv func(string) (string, bool)) (string, error)
- func ValidateControlPlaneAPIKey(key string) error
- func ValidateFullProfileBytes(path string, data []byte) error
- func ValidateFullProfileFile(path string) error
- func ValidateProfileBytes(path string, data []byte) error
- func ValidateProfileFile(path string) error
- func ValidateProfileName(name string) error
- func ValidateTunnelID(tunnelID string) error
- func WriteUsage(fs *pflag.FlagSet, w io.Writer)
- type CloudflaredConfig
- type CloudflaredSettings
- type Config
- type ConfigSource
- type ControlPlaneConfig
- type Flavor
- type HarpoonConfig
- type HarpoonHostClassifierConfig
- type HarpoonTarget
- type HarpoonTransportKind
- type HealthConfig
- type LoadContext
- type LogFormat
- type LoggingConfig
- type MCPChannelBinding
- type MCPConfig
- type MCPTransportKind
- type ProcessConfig
- type ProxySource
- type RuntimeConfig
Constants ¶
const ( DefaultHarpoonMaxResponseBytes = 100 * 1024 DefaultHarpoonMaxRedirects = 5 )
const ( DefaultAdminUILogBufferEvents = 2000 DefaultProxyCheckInterval = 60 * time.Second )
These full-client extension defaults live beside the canonical profile loader because runtime flavors must recognize their harmless legacy values without importing pkg/config.
const ( ProfileEnvName = "TUNNEL_CLIENT_PROFILE" ProfileFileEnvName = "TUNNEL_CLIENT_PROFILE_FILE" ProfileDirEnvName = "TUNNEL_CLIENT_PROFILE_DIR" ConfigEnvName = "TUNNEL_CLIENT_CONFIG" )
const DefaultControlPlaneBaseURL = defaultControlPlaneBaseURL
DefaultControlPlaneBaseURL is the canonical production default shared by runtime and full-client administrative commands.
Variables ¶
This section is empty.
Functions ¶
func BuildTLSBundle ¶
func BuildTLSBundle(fs *pflag.FlagSet, lookupEnv func(string) (string, bool)) (*tlsconfig.Bundle, error)
BuildTLSBundle exposes the shared CA-bundle loader for narrow adapters.
func ControlPlaneURLPathRaw ¶
ControlPlaneURLPathRaw exposes shared flag/environment precedence for administrative commands that do not need the full runtime loader.
func DefaultProfileDir ¶
DefaultProfileDir returns the XDG-backed default profile directory.
func LoadFullFromFlagSet ¶
func LoadFullFromFlagSet(fs *pflag.FlagSet, lookupEnv func(string) (string, bool)) (*Config, CloudflaredSettings, LoadContext, error)
LoadFullFromFlagSet loads the shared production core for the full client and returns the approved companion settings plus the effective lookup used for full-only adapters. The returned Config never grows full-client-only fields.
func NormalizeControlPlaneURLPath ¶
NormalizeControlPlaneURLPath validates and normalizes the optional control-plane URL prefix.
func NormalizeExtraHeaders ¶
NormalizeExtraHeaders validates operator-supplied HTTP headers and returns a canonical copy. HTTP field names are case-insensitive, so conflicting case variants are rejected instead of depending on Go map iteration order.
func ParseProxyCheckInterval ¶
ParseProxyCheckInterval is the canonical parser for the full-client proxy health extension and its runtime profile/environment compatibility gate.
func ProfilePath ¶
func ProfilePath(name string, explicitDir string, lookupEnv func(string) (string, bool)) (string, string, error)
ProfilePath returns the on-disk path for a named profile.
func ProxyLogFields ¶
func ProxyLogFields(proxyURL *url.URL, source ProxySource) []any
ProxyLogFields builds log fields for proxy metadata, redacting credentials.
func RedactProxyURL ¶
func RegisterFlags ¶
RegisterFlags attaches only the approved customer runtime flags to fs. The normal runtime intentionally omits cloudflared flags; the cloudflared flavor adds only the approved companion settings.
func RegisterTLSFlags ¶
RegisterTLSFlags exposes the shared CA-bundle flag for narrow adapters such as the full client's administrative command surface.
func ResolveControlPlanePath ¶
ResolveControlPlanePath resolves routePath from the control-plane host root plus urlPath.
func ResolveProfileDir ¶
ResolveProfileDir returns the directory used to store named profile files.
func ValidateControlPlaneAPIKey ¶
ValidateControlPlaneAPIKey verifies that key can be safely used as an HTTP bearer token. It deliberately returns redacted errors: callers must not expose any key-derived details while reporting configuration failures.
func ValidateFullProfileBytes ¶
ValidateFullProfileBytes validates full-client profile contents without resolving referenced secrets. Shared field syntax remains owned here; only the approved full-only extension keys are additionally allowed.
func ValidateFullProfileFile ¶
ValidateFullProfileFile parses a full-client profile through the same canonical schema while allowing approved full-only extension fields.
func ValidateProfileBytes ¶
ValidateProfileBytes parses profile contents without resolving referenced secrets.
func ValidateProfileFile ¶
ValidateProfileFile parses a profile file without resolving referenced secrets.
func ValidateProfileName ¶
ValidateProfileName verifies that name can be mapped to exactly one YAML file.
func ValidateTunnelID ¶
ValidateTunnelID verifies that the tunnel id matches the runtime contract.
Types ¶
type CloudflaredConfig ¶
type CloudflaredConfig struct {
Runtime Config
Cloudflared CloudflaredSettings
}
CloudflaredConfig composes the shared runtime configuration with the only extra settings accepted by the runtime-cloudflared artifact.
func LoadCloudflaredFromFlagSet ¶
func LoadCloudflaredFromFlagSet(fs *pflag.FlagSet, lookupEnv func(string) (string, bool)) (*CloudflaredConfig, error)
LoadCloudflaredFromFlagSet builds runtime-cloudflared configuration from parsed flags, adding only the approved companion settings.
type CloudflaredSettings ¶
type CloudflaredSettings struct {
// Token is the pre-provisioned remotely managed Cloudflare Tunnel token.
// It is kept in memory only and is passed to cloudflared through its
// TUNNEL_TOKEN environment variable, never argv.
Token string
// Managed fetches the remotely managed Cloudflare Tunnel runtime token from
// tunnel-service during startup. A configured Token takes precedence so
// existing pre-provisioned deployments remain unchanged.
Managed bool
// Path overrides sibling-binary discovery for source builds and tests.
Path string
// ReadyTimeout bounds startup while waiting for cloudflared /ready.
ReadyTimeout time.Duration
}
CloudflaredSettings defines the optional bundled Cloudflare Tunnel companion process. A configured token or explicit managed mode enables supervision; otherwise the normal tunnel-client runtime is unchanged.
func (CloudflaredSettings) Enabled ¶
func (c CloudflaredSettings) Enabled() bool
Enabled reports whether the bundled cloudflared companion should run.
type Config ¶
type Config struct {
ControlPlane ControlPlaneConfig
Logging LoggingConfig
Health HealthConfig
Process ProcessConfig
MCP MCPConfig
Harpoon HarpoonConfig
TLS *tlsconfig.Bundle
Runtime RuntimeConfig
}
Config captures the runtime values required to start the tunnel client.
type ConfigSource ¶
type ConfigSource struct {
Path string
ProfileName string
ProfilePath string
ProfileDir string
ProfileFile bool
}
ConfigSource describes the config file selected for this process.
func ResolveConfigSource ¶
func ResolveConfigSource(fs *pflag.FlagSet, lookupEnv func(string) (string, bool)) (ConfigSource, error)
ResolveConfigSource returns the config file selected by flags or environment.
type ControlPlaneConfig ¶
type ControlPlaneConfig struct {
BaseURL *url.URL
UnixSocketPath string
URLPath string
TunnelID types.TunnelID
OrganizationID string
APIKey string
MaxInFlightRequests int
PollTimeout time.Duration
PollDeadlineGuardrail time.Duration
// PollChannels is an explicit, sorted allowlist of channels to drain. When
// PollChannelsConfigured is false, polling remains wire-compatible with
// older clients and sends no channel query parameters.
PollChannels []types.Channel
PollChannelsConfigured bool
// PollBackoffMin/PollBackoffMax allow overriding the poller's retry window.
// Zero values fall back to the internal defaults.
PollBackoffMin time.Duration
PollBackoffMax time.Duration
ClientCertificate *tlsconfig.ClientCertificate
ExtraHeaders map[string]string
// MCPServerInfoHeader returns metadata generated from effective MCP channel
// bindings and sent as a protected control-plane header. It is not
// operator-configurable.
MCPServerInfoHeader func() (string, error)
HTTPProxy *url.URL
HTTPProxySource ProxySource
}
ControlPlaneConfig defines how the client reaches the tunnel control plane.
func (ControlPlaneConfig) PollDeadlineGuardrailOrDefault ¶
func (c ControlPlaneConfig) PollDeadlineGuardrailOrDefault() time.Duration
PollDeadlineGuardrailOrDefault returns the configured client deadline guardrail or its runtime default.
func (ControlPlaneConfig) PollDeadlineTimeoutOrDefault ¶
func (c ControlPlaneConfig) PollDeadlineTimeoutOrDefault() time.Duration
PollDeadlineTimeoutOrDefault returns the client HTTP/context deadline for one poll cycle.
func (ControlPlaneConfig) PollTimeoutOrDefault ¶
func (c ControlPlaneConfig) PollTimeoutOrDefault() time.Duration
PollTimeoutOrDefault returns the configured requested service wait or its runtime default.
type Flavor ¶
type Flavor string
Flavor selects the deliberately narrow runtime configuration surface.
The flavor is part of the compile-time artifact boundary: the normal runtime never registers or accepts cloudflared configuration, while the cloudflared runtime accepts only the approved companion settings in addition to the shared runtime surface.
type HarpoonConfig ¶
type HarpoonConfig struct {
AllowPlaintextHTTP bool
MaxResponseBytes int
MaxRedirects int
AdditionalTransports []HarpoonTransportKind
Targets []HarpoonTarget
HostClassifier HarpoonHostClassifierConfig
HTTPProxy *url.URL
HTTPProxySource ProxySource
}
HarpoonConfig captures configuration for the embedded harpoon MCP server.
func (HarpoonConfig) AdditionalTransportEnabled ¶
func (h HarpoonConfig) AdditionalTransportEnabled(kind HarpoonTransportKind) bool
AdditionalTransportEnabled reports whether a transport is enabled.
type HarpoonHostClassifierConfig ¶
type HarpoonHostClassifierConfig struct {
IncludeSuffix []string
IncludeRegex []string
IncludeLoopback bool
IncludePrivate bool
}
HarpoonHostClassifierConfig controls which hosts are treated as private.
type HarpoonTarget ¶
type HarpoonTarget struct {
Label string
Description string
BaseURL *url.URL
UnixSocketPath string
}
HarpoonTarget describes a configured harpoon target.
type HarpoonTransportKind ¶
type HarpoonTransportKind string
HarpoonTransportKind enumerates supported harpoon transports.
const (
HarpoonTransportHTTPStreamable HarpoonTransportKind = "http-streamable"
)
type HealthConfig ¶
HealthConfig defines the health server behavior.
type LoadContext ¶
type LoadContext struct {
LookupEnv func(string) (string, bool)
Source ConfigSource
RawConfig []byte
}
LoadContext exposes the effective lookup and selected source produced by the shared loader so full-client-only adapters can apply their own settings without reimplementing shared precedence or profile parsing.
type LogFormat ¶
type LogFormat int
LogFormat enumerates the supported logging formats.
func ParseLogFormat ¶
ParseLogFormat converts the provided raw string into a LogFormat value.
type LoggingConfig ¶
LoggingConfig defines logging behavior for the client.
type MCPChannelBinding ¶
type MCPChannelBinding struct {
Channel types.Channel
TransportKind MCPTransportKind
ServerURL *url.URL
UnixSocketPath string
Command string
CommandArgs []string
ClientCertificate *tlsconfig.ClientCertificate
HTTPProxy *url.URL
HTTPProxySource ProxySource
}
MCPChannelBinding maps one tunnel-service channel to one MCP transport.
Exactly one binding may exist per channel. The reserved harpoon channel is supplied by the embedded Harpoon server, not by user MCP config. Streamable HTTP bindings may carry proxy and mTLS settings; stdio bindings deliberately ignore HTTP-only settings because they communicate over child-process stdin/stdout rather than a network socket.
type MCPConfig ¶
type MCPConfig struct {
ServerURL *url.URL
UnixSocketPath string
Command string
CommandArgs []string
TransportKind MCPTransportKind
ClientCertificate *tlsconfig.ClientCertificate
ChannelBindings []MCPChannelBinding
// AllowNoMain is set only for an explicit poll allowlist that excludes main.
// It keeps zero-value MCPConfig compatibility for older callers.
AllowNoMain bool
// StartupWaitTimeout enables an opt-in startup gate for the main
// HTTP-streamable MCP listener. Zero preserves legacy behavior.
StartupWaitTimeout time.Duration
// StdioSendInitializedNotification opts stdio bindings into completing the
// MCP lifecycle when an older caller omits notifications/initialized. False
// preserves the legacy verbatim-forwarding behavior for existing servers.
StdioSendInitializedNotification bool
ConnectionMaxTTL time.Duration
MaxConcurrentRequests int
ExtraHeaders map[string]string
DiscoveryExtraHeaders map[string]string
HTTPProxy *url.URL
HTTPProxySource ProxySource
}
MCPConfig captures configuration for the Model Context Protocol integration.
The legacy top-level ServerURL/Command fields mirror the main channel so older call sites can keep reading cfg.MCP.ServerURL while the dispatcher routes from ChannelBindings. New connector/channel behavior should be modeled as an MCPChannelBinding first, then projected to the legacy fields only for compatibility.
func (*MCPConfig) ChannelBindingFor ¶
func (c *MCPConfig) ChannelBindingFor(channel types.Channel) *MCPChannelBinding
ChannelBindingFor returns the configured binding for the provided channel.
func (*MCPConfig) MainChannelBinding ¶
func (c *MCPConfig) MainChannelBinding() *MCPChannelBinding
MainChannelBinding returns the binding for the main channel, if configured.
type MCPTransportKind ¶
type MCPTransportKind string
MCPTransportKind describes the available MCP transport types.
const ( MCPTransportHTTPStreamable MCPTransportKind = "http-streamable" MCPTransportStdio MCPTransportKind = "stdio" MCPTransportInMemory MCPTransportKind = "in-memory" )
type ProcessConfig ¶
type ProcessConfig struct {
PIDFile string
}
ProcessConfig defines process-level runtime settings.
type ProxySource ¶
type ProxySource string
ProxySource describes where an effective proxy value originated.
const ( ProxySourceNone ProxySource = "none" ProxySourceEnvironment ProxySource = "environment" ProxySourceIgnored ProxySource = "ignored" )
func (ProxySource) String ¶
func (s ProxySource) String() string