Documentation
¶
Overview ¶
Package config provides configuration file support for OmniProxy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigPath ¶
func DefaultConfigPath() string
DefaultConfigPath returns the default configuration file path.
func ExampleConfig ¶
func ExampleConfig() string
ExampleConfig returns an example configuration as YAML string.
Types ¶
type AsyncConfig ¶ added in v0.2.0
type AsyncConfig struct {
// QueueSize is the async traffic queue size
QueueSize int `yaml:"queueSize"`
// BatchSize is the async batch size
BatchSize int `yaml:"batchSize"`
// Workers is the number of async workers
Workers int `yaml:"workers"`
}
AsyncConfig tunes the asynchronous traffic store.
type BackendConfig ¶
type BackendConfig struct {
// Host is the hostname to match
Host string `yaml:"host"`
// PathPrefix matches requests by URL path prefix (e.g., "/api"). When set, Host is ignored.
PathPrefix string `yaml:"pathPrefix,omitempty"`
// Target is the backend URL
Target string `yaml:"target"`
// StripPrefix removes a path prefix before forwarding
StripPrefix string `yaml:"stripPrefix,omitempty"`
// AddHeaders are headers to add to proxied requests
AddHeaders map[string]string `yaml:"addHeaders,omitempty"`
// HealthCheck is the health check path
HealthCheck string `yaml:"healthCheck,omitempty"`
// CORSOrigin adds CORS headers to proxied responses (e.g., "*")
CORSOrigin string `yaml:"corsOrigin,omitempty"`
// TLS configures the client certificate presented to an HTTPS backend requiring mTLS
TLS *BackendTLSConfig `yaml:"tls,omitempty"`
}
BackendConfig holds backend server configuration.
type BackendTLSConfig ¶ added in v0.2.0
type BackendTLSConfig struct {
// CertFile is the PEM client certificate to present to the backend
CertFile string `yaml:"certFile,omitempty"`
// KeyFile is the PEM private key for CertFile (defaults to CertFile if it holds both)
KeyFile string `yaml:"keyFile,omitempty"`
// CAFile is a PEM bundle of CAs used to verify the backend server certificate
CAFile string `yaml:"caFile,omitempty"`
// InsecureSkipVerify disables backend certificate verification (UNSAFE; dev only)
InsecureSkipVerify bool `yaml:"insecureSkipVerify,omitempty"`
}
BackendTLSConfig configures the TLS client used to reach an HTTPS backend.
type CaptureConfig ¶
type CaptureConfig struct {
// Output is the output file path
Output string `yaml:"output,omitempty"`
// Format is the output format (ndjson, json, har, ir)
Format string `yaml:"format"`
// IncludeHeaders controls whether to include headers
IncludeHeaders bool `yaml:"includeHeaders"`
// IncludeBody controls whether to include bodies
IncludeBody bool `yaml:"includeBody"`
// MaxBodySize is the maximum body size to capture
MaxBodySize int64 `yaml:"maxBodySize"`
// FilterHeaders is a list of headers to exclude
FilterHeaders []string `yaml:"filterHeaders,omitempty"`
// SkipBinary skips capturing binary content (images, videos, etc.)
SkipBinary bool `yaml:"skipBinary"`
}
CaptureConfig holds capture-related configuration.
type Config ¶
type Config struct {
// Server configuration
Server ServerConfig `yaml:"server"`
// MITM configuration
MITM MITMConfig `yaml:"mitm"`
// Reverse proxy configuration
Reverse ReverseConfig `yaml:"reverse,omitempty"`
// Capture configuration
Capture CaptureConfig `yaml:"capture"`
// Filter configuration
Filter FilterConfig `yaml:"filter"`
// Observability configuration (metrics and health endpoints)
Observability ObservabilityConfig `yaml:"observability"`
// Storage configuration (traffic database and async writer)
Storage StorageConfig `yaml:"storage"`
// Upstream proxy configuration
Upstream string `yaml:"upstream,omitempty"`
}
Config represents the OmniProxy configuration file.
func LoadOrDefault ¶
LoadOrDefault loads configuration from a file, or returns default if not found.
type FilterConfig ¶
type FilterConfig struct {
// IncludeHosts is a list of hosts to include
IncludeHosts []string `yaml:"includeHosts,omitempty"`
// ExcludeHosts is a list of hosts to exclude
ExcludeHosts []string `yaml:"excludeHosts,omitempty"`
// IncludePaths is a list of paths to include
IncludePaths []string `yaml:"includePaths,omitempty"`
// ExcludePaths is a list of paths to exclude
ExcludePaths []string `yaml:"excludePaths,omitempty"`
// IncludeMethods is a list of methods to include
IncludeMethods []string `yaml:"includeMethods,omitempty"`
// ExcludeMethods is a list of methods to exclude
ExcludeMethods []string `yaml:"excludeMethods,omitempty"`
}
FilterConfig holds request/response filtering configuration.
type MITMConfig ¶
type MITMConfig struct {
// Enabled enables HTTPS interception
Enabled bool `yaml:"enabled"`
// CertPath is the path to the CA certificate
CertPath string `yaml:"certPath,omitempty"`
// KeyPath is the path to the CA private key
KeyPath string `yaml:"keyPath,omitempty"`
// SkipHosts is a list of hosts to skip MITM for
SkipHosts []string `yaml:"skipHosts,omitempty"`
}
MITMConfig holds MITM-related configuration.
type OTLPConfig ¶ added in v0.2.0
type OTLPConfig struct {
// Endpoint is the OTLP gRPC collector address (host:port). Empty disables OTLP push.
Endpoint string `yaml:"endpoint,omitempty"`
// Insecure sends OTLP over plaintext gRPC (for local collectors without TLS).
Insecure bool `yaml:"insecure"`
}
OTLPConfig configures OTLP push export.
type ObservabilityConfig ¶ added in v0.2.0
type ObservabilityConfig struct {
// Metrics enables the Prometheus pull metrics endpoint (requires MetricsPort)
Metrics bool `yaml:"metrics"`
// MetricsPort is the port for metrics/health endpoints (0 = disabled)
MetricsPort int `yaml:"metricsPort"`
// Traces enables distributed tracing (exported when OTLP.Endpoint is set)
Traces bool `yaml:"traces"`
// Logs exports structured logs via OpenTelemetry (requires OTLP.Endpoint)
Logs bool `yaml:"logs"`
// TraceSampleRatio is the head sampling ratio for traces (0..1, default 1.0)
TraceSampleRatio float64 `yaml:"traceSampleRatio"`
// ServiceName identifies this service in telemetry (default "omniproxy")
ServiceName string `yaml:"serviceName,omitempty"`
// ServiceVersion identifies this build in telemetry
ServiceVersion string `yaml:"serviceVersion,omitempty"`
// OTLP configures push export to an OpenTelemetry collector.
OTLP OTLPConfig `yaml:"otlp"`
}
ObservabilityConfig holds metrics, tracing, logging, and health configuration. It maps onto observops.Setup, which wires the OpenTelemetry providers and exporters.
type ReverseConfig ¶
type ReverseConfig struct {
// HTTPPort is the HTTP port (default: 80)
HTTPPort int `yaml:"httpPort"`
// HTTPSPort is the HTTPS port (default: 443)
HTTPSPort int `yaml:"httpsPort"`
// Backends is the list of backend configurations
Backends []BackendConfig `yaml:"backends,omitempty"`
// ACMEEmail is the email for Let's Encrypt registration
ACMEEmail string `yaml:"acmeEmail,omitempty"`
// ACMECacheDir is the directory to cache ACME certificates
ACMECacheDir string `yaml:"acmeCacheDir,omitempty"`
// ACMEStaging uses Let's Encrypt staging environment
ACMEStaging bool `yaml:"acmeStaging,omitempty"`
// RedirectHTTP redirects HTTP to HTTPS
RedirectHTTP bool `yaml:"redirectHTTP"`
// ClientCAPaths are PEM files holding the CAs used to verify client certificates (mTLS)
ClientCAPaths []string `yaml:"clientCAPaths,omitempty"`
// ClientAuth controls client certificate verification: none, request, require-any,
// verify-if-given, or require-and-verify. Defaults to require-and-verify when
// ClientCAPaths is set.
ClientAuth string `yaml:"clientAuth,omitempty"`
// StaticDir serves files from this directory as fallback when no backend matches
StaticDir string `yaml:"staticDir,omitempty"`
}
ReverseConfig holds reverse proxy configuration.
type ServerConfig ¶
type ServerConfig struct {
// Host to bind to
Host string `yaml:"host"`
// Port to listen on
Port int `yaml:"port"`
// Verbose logging
Verbose bool `yaml:"verbose"`
}
ServerConfig holds server-related configuration.
type StorageConfig ¶ added in v0.2.0
type StorageConfig struct {
// DatabaseURL is the database connection string (sqlite://path or postgres://...).
// When empty, traffic is written to the capture output file instead.
DatabaseURL string `yaml:"databaseURL,omitempty"`
// Async tunes the non-blocking traffic writer.
Async AsyncConfig `yaml:"async"`
}
StorageConfig holds traffic storage configuration.