config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 4 Imported by: 0

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 BackendConfig

type BackendConfig struct {
	// Host is the hostname to match
	Host string `yaml:"host"`
	// 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"`
}

BackendConfig holds backend server configuration.

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"`
}

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"`

	// Upstream proxy configuration
	Upstream string `yaml:"upstream,omitempty"`
}

Config represents the OmniProxy configuration file.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration.

func Load

func Load(path string) (*Config, error)

Load loads configuration from a YAML file.

func LoadOrDefault

func LoadOrDefault(path string) (*Config, error)

LoadOrDefault loads configuration from a file, or returns default if not found.

func (*Config) Save

func (c *Config) Save(path string) error

Save saves configuration to a YAML file.

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 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"`
}

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.

Jump to

Keyboard shortcuts

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