config

package
v0.0.0-...-c79a5c9 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config handles configuration loading from YAML, CLI flags, and environment variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigDir

func ConfigDir() (string, error)

ConfigDir returns the platform-specific config directory.

func DefaultConfigPath

func DefaultConfigPath() (string, error)

DefaultConfigPath returns the default config file path.

func DefaultDBPath

func DefaultDBPath() (string, error)

DefaultDBPath returns the default database path.

func GenerateToken

func GenerateToken() (string, error)

GenerateToken generates a cryptographically random auth token. Exported for use by CLI commands (token rotate).

Types

type AnalyticsConfig

type AnalyticsConfig struct {
	AnomalyContextTokens       int `yaml:"anomaly_context_tokens"`
	AnomalyToolDelayMs         int `yaml:"anomaly_tool_delay_ms"`
	AnomalyRapidCallsWindowS   int `yaml:"anomaly_rapid_calls_window_s"`
	AnomalyRapidCallsThreshold int `yaml:"anomaly_rapid_calls_threshold"`
}

AnalyticsConfig configures anomaly detection thresholds.

type AuthConfig

type AuthConfig struct {
	Token string `yaml:"token"` // Bearer token for API access
}

AuthConfig configures API authentication.

type Config

type Config struct {
	Proxy       ProxyConfig       `yaml:"proxy"`
	Memory      MemoryConfig      `yaml:"memory"`
	Persistence PersistenceConfig `yaml:"persistence"`
	Analytics   AnalyticsConfig   `yaml:"analytics"`
	Retention   RetentionConfig   `yaml:"retention"`
	Redaction   RedactionConfig   `yaml:"redaction"`
	Auth        AuthConfig        `yaml:"auth"`
	Task        TaskConfig        `yaml:"task"`
}

Config is the root configuration structure.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with secure defaults.

func Load

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

Load loads configuration from file, with environment variable overrides.

func (*Config) Save

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

Save writes the config to the specified path with secure permissions.

type MemoryConfig

type MemoryConfig struct {
	MaxFlows         int `yaml:"max_flows"`           // N - flows in RAM
	MaxEventsPerFlow int `yaml:"max_events_per_flow"` // M - events per flow in RAM
}

MemoryConfig configures in-memory caching.

type PersistenceConfig

type PersistenceConfig struct {
	DBPath              string `yaml:"db_path"`
	BodyMaxBytes        int    `yaml:"body_max_bytes"`
	EventBatchSize      int    `yaml:"event_batch_size"`
	EventBatchTimeoutMs int    `yaml:"event_batch_timeout_ms"`
	QueueMaxSize        int    `yaml:"queue_max_size"`
}

PersistenceConfig configures SQLite persistence.

type ProxyConfig

type ProxyConfig struct {
	Listen         string   `yaml:"listen"`          // e.g., "localhost:9090"
	Host           string   `yaml:"host"`            // Bind host
	Port           int      `yaml:"port"`            // Bind port (alternative to listen)
	InterceptHosts []string `yaml:"intercept_hosts"` // Additional hosts to MITM (e.g., Azure OpenAI, OpenRouter)
}

ProxyConfig configures the HTTP/TLS proxy.

func (*ProxyConfig) ListenAddr

func (c *ProxyConfig) ListenAddr() string

Listen returns the listen address, handling host:port vs listen field.

type RedactionConfig

type RedactionConfig struct {
	AlwaysRedactHeaders  []string `yaml:"always_redact_headers"`
	PatternRedactHeaders []string `yaml:"pattern_redact_headers"`
	RedactAPIKeys        bool     `yaml:"redact_api_keys"`
	RedactBase64Images   bool     `yaml:"redact_base64_images"`
	DisableBodyStorage   bool     `yaml:"disable_body_storage"`
}

RedactionConfig configures credential redaction.

func (*RedactionConfig) HeaderShouldRedact

func (c *RedactionConfig) HeaderShouldRedact(name string) bool

HeaderShouldRedact checks if a header name should be redacted.

type RetentionConfig

type RetentionConfig struct {
	FlowsTTLDays   int `yaml:"flows_ttl_days"`
	EventsTTLDays  int `yaml:"events_ttl_days"`
	BodiesTTLDays  int `yaml:"bodies_ttl_days"`
	DropLogTTLDays int `yaml:"drop_log_ttl_days"`
}

RetentionConfig configures data retention TTLs.

type TaskConfig

type TaskConfig struct {
	IdleGapMinutes int `yaml:"idle_gap_minutes"` // Minutes of inactivity before starting new task
}

TaskConfig configures task grouping behavior.

Jump to

Keyboard shortcuts

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