config

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHarpoonMaxResponseBytes = 100 * 1024
	DefaultHarpoonMaxRedirects     = 5
)
View Source
const (
	ProfileEnvName     = "TUNNEL_CLIENT_PROFILE"
	ProfileFileEnvName = "TUNNEL_CLIENT_PROFILE_FILE"
	ProfileDirEnvName  = "TUNNEL_CLIENT_PROFILE_DIR"
	ConfigEnvName      = "TUNNEL_CLIENT_CONFIG"
)

Variables

This section is empty.

Functions

func DefaultProfileDir

func DefaultProfileDir(lookupEnv func(string) (string, bool)) (string, error)

DefaultProfileDir returns the XDG-backed default profile directory.

func EnvProxyConfigured

func EnvProxyConfigured(lookupEnv func(string) (string, bool)) bool

func NormalizeControlPlaneURLPath

func NormalizeControlPlaneURLPath(raw string) (string, error)

NormalizeControlPlaneURLPath validates and normalizes the optional control-plane URL prefix.

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 RedactProxyURL(proxyURL *url.URL) string

func RegisterAdminFlags

func RegisterAdminFlags(fs *pflag.FlagSet)

RegisterAdminFlags attaches admin/tunnel-management flags to the provided flag set.

func RegisterFlags

func RegisterFlags(fs *pflag.FlagSet)

RegisterFlags attaches all supported CLI flags to the provided flag set.

func ResolveControlPlanePath

func ResolveControlPlanePath(baseURL *url.URL, urlPath, routePath string) *url.URL

ResolveControlPlanePath resolves routePath from the control-plane host root plus urlPath.

func ResolveProfileDir

func ResolveProfileDir(explicitDir string, lookupEnv func(string) (string, bool)) (string, error)

ResolveProfileDir returns the directory used to store named profile files.

func ValidateProfileBytes

func ValidateProfileBytes(path string, data []byte) error

ValidateProfileBytes parses profile contents without resolving referenced secrets.

func ValidateProfileFile

func ValidateProfileFile(path string) error

ValidateProfileFile parses a profile file without resolving referenced secrets.

func ValidateProfileName

func ValidateProfileName(name string) error

ValidateProfileName verifies that name can be mapped to exactly one YAML file.

func ValidateTunnelID

func ValidateTunnelID(tunnelID string) error

ValidateTunnelID verifies that the tunnel id matches the runtime contract.

func WriteUsage

func WriteUsage(fs *pflag.FlagSet, w io.Writer)

WriteUsage prints the tunnel-client CLI usage text for the provided flag set.

Types

type AdminConfig

type AdminConfig struct {
	BaseURL         *url.URL
	URLPath         string
	AdminKey        string
	OrganizationIDs []string
	WorkspaceIDs    []string
	TLS             *tlsconfig.Bundle
}

AdminConfig captures the options required for tunnel management API calls.

The admin CLI surface is intentionally narrower than the runtime client configuration: it only needs a base URL, an admin API key, and the scoped organization/workspace headers required by the control plane.

func LoadAdminConfig

func LoadAdminConfig(fs *pflag.FlagSet, lookupEnv func(string) (string, bool)) (*AdminConfig, error)

LoadAdminConfig builds an AdminConfig from the provided flag set and environment.

It enforces that an admin API key is present and that at least one of organization_id or workspace_id is supplied to scope the request context.

type AdminUIConfig

type AdminUIConfig struct {
	// AllowRemote controls whether the embedded web UI and log endpoints are
	// accessible from non-loopback clients.
	//
	// When false, the UI endpoints only respond to loopback requests (127.0.0.1/::1),
	// even if the health server is bound to 0.0.0.0/::.
	AllowRemote bool
	// OpenBrowser controls whether tunnel-client attempts to open the embedded UI
	// in the default browser on startup.
	OpenBrowser bool
	// LogBufferEvents controls how many recent log events the admin UI keeps in memory.
	LogBufferEvents int
}

AdminUIConfig defines runtime behavior for the embedded admin web UI.

type Config

type Config struct {
	ControlPlane ControlPlaneConfig
	Logging      LoggingConfig
	Health       HealthConfig
	Process      ProcessConfig
	MCP          MCPConfig
	AdminUI      AdminUIConfig
	Harpoon      HarpoonConfig
	ProxyHealth  ProxyHealthConfig
	TLS          *tlsconfig.Bundle
	Runtime      RuntimeConfig
}

Config captures the runtime values required to start the tunnel client.

func Load

func Load(args []string, lookupEnv func(string) (string, bool)) (*Config, error)

Load builds a Config by combining CLI flag arguments with environment variables.

Flags take precedence over environment variables. Environment variables take precedence over the built-in defaults.

func LoadFromFlagSet

func LoadFromFlagSet(fs *pflag.FlagSet, lookupEnv func(string) (string, bool)) (*Config, error)

LoadFromFlagSet builds a Config using the parsed values from the provided flag set.

It respects the same precedence rules as Load(): flags override environment variables, which override defaults.

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
	// 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
	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 HarpoonConfig

type HarpoonConfig struct {
	AllowPlaintextHTTP   bool
	MaxResponseBytes     int
	MaxRedirects         int
	AdditionalTransports []HarpoonTransportKind
	Targets              []HarpoonTarget
	CapturePayloads      bool
	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

type HealthConfig struct {
	ListenAddr string
	UnixSocket string
	URLFile    string
}

HealthConfig defines the health server behavior.

type LogFormat

type LogFormat int

LogFormat enumerates the supported logging formats.

const (
	LogFormatUnset LogFormat = iota
	LogFormatStructText
	LogFormatJSON
)

func ParseLogFormat

func ParseLogFormat(raw string) (LogFormat, error)

ParseLogFormat converts the provided raw string into a LogFormat value.

func (LogFormat) String

func (f LogFormat) String() string

String implements fmt.Stringer.

type LoggingConfig

type LoggingConfig struct {
	Level         slog.Level
	Format        LogFormat
	File          string
	HTTPRawUnsafe bool
}

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
	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 ProxyHealthConfig

type ProxyHealthConfig struct {
	CheckInterval time.Duration
}

ProxyHealthConfig controls proxy connectivity checks.

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

type RuntimeConfig

type RuntimeConfig struct {
	ConfigFile         string
	ConfigFileContents []byte
	ProfileName        string
	ProfilePath        string
	ProfileDir         string
	ProfileFile        bool
}

RuntimeConfig captures startup metadata that is useful for diagnostics but does not affect runtime behavior.

Jump to

Keyboard shortcuts

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