config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfigDir

func GetConfigDir() string

GetConfigDir returns the configuration directory following XDG spec

func GetDefaultCADir

func GetDefaultCADir() string

GetDefaultCADir returns the default CA directory path following XDG spec

func GetDefaultConfigPath

func GetDefaultConfigPath() string

GetDefaultConfigPath returns the default configuration file path

Types

type Config

type Config struct {
	// Network settings
	Verbose      bool
	ExtraVerbose bool // Extra verbose mode (-vv)
	DNSIP        string
	DNSPort      int
	ProxyPort    int
	CADir        string
	KeepCA       bool // Keep CA directory after exit

	// HTTP traffic interception
	EnableHTTP bool // Enable HTTP traffic interception on port 80
	HTTPPort   int  // HTTP proxy port (default 80)

	// Connection settings
	ConnectionTimeout int // Client connection idle timeout in seconds (default 30)

	// SOCKS5 proxy settings
	SOCKS5Enabled  bool   // Enable SOCKS5 proxy for upstream connections
	SOCKS5Address  string // SOCKS5 proxy address (e.g., "127.0.0.1:1080")
	SOCKS5Username string // SOCKS5 username (optional)
	SOCKS5Password string // SOCKS5 password (optional)

	// Command execution
	Command     string
	CommandArgs []string

	// Traffic logging and output
	OutputFile          string       // File to save traffic logs
	OutputFormat        OutputFormat // Output format (text, json, csv)
	LogLevel            LogLevel     // Console traffic logging verbosity
	FileLogLevel        LogLevel     // File traffic logging verbosity (can be different from console)
	LogFile             string       // File to save system logs (separate from traffic)
	Quiet               bool         // Suppress console output
	MaxBodySize         int          // Maximum body size to log (bytes), 0 = unlimited
	FilterDomains       []string     // Only log these domains (empty = all)
	ExcludeContentTypes []string     // Exclude these content types
	DecompressResponse  bool         // Decompress compressed response bodies for logging (default: true)

	// Wireshark integration
	EnableMirror bool // Enable HTTP mirror server for Wireshark analysis
	MirrorPort   int  // HTTP mirror server port
}

Config holds the application configuration

func (*Config) MergeWithFileConfig

func (c *Config) MergeWithFileConfig(fileConfig *FileConfig)

MergeWithFileConfig merges file configuration with CLI configuration CLI parameters take precedence over file configuration

type FileConfig

type FileConfig struct {
	// Network settings
	Verbose      *bool   `json:"verbose,omitempty"`
	ExtraVerbose *bool   `json:"extra_verbose,omitempty"`
	DNSIP        *string `json:"dns_ip,omitempty"`
	DNSPort      *int    `json:"dns_port,omitempty"`
	ProxyPort    *int    `json:"proxy_port,omitempty"`
	CADir        *string `json:"ca_dir,omitempty"`
	KeepCA       *bool   `json:"keep_ca,omitempty"`

	// HTTP traffic interception
	EnableHTTP *bool `json:"enable_http,omitempty"`
	HTTPPort   *int  `json:"http_port,omitempty"`

	// Connection settings
	ConnectionTimeout *int `json:"connection_timeout,omitempty"`

	// SOCKS5 proxy settings
	SOCKS5Enabled  *bool   `json:"socks5_enabled,omitempty"`
	SOCKS5Address  *string `json:"socks5_address,omitempty"`
	SOCKS5Username *string `json:"socks5_username,omitempty"`
	SOCKS5Password *string `json:"socks5_password,omitempty"`

	// Traffic logging and output
	OutputFile          *string   `json:"output_file,omitempty"`
	OutputFormat        *string   `json:"output_format,omitempty"`
	LogLevel            *string   `json:"log_level,omitempty"`
	FileLogLevel        *string   `json:"file_log_level,omitempty"`
	LogFile             *string   `json:"log_file,omitempty"`
	Quiet               *bool     `json:"quiet,omitempty"`
	MaxBodySize         *int      `json:"max_body_size,omitempty"`
	FilterDomains       *[]string `json:"filter_domains,omitempty"`
	ExcludeContentTypes *[]string `json:"exclude_content_types,omitempty"`
	DecompressResponse  *bool     `json:"decompress_response,omitempty"`

	// Wireshark integration
	EnableMirror *bool `json:"enable_mirror,omitempty"`
	MirrorPort   *int  `json:"mirror_port,omitempty"`
}

FileConfig represents the configuration file structure with JSON tags

func LoadConfigFile

func LoadConfigFile(path string) (*FileConfig, error)

LoadConfigFile loads configuration from a JSON file

type LogLevel

type LogLevel string

LogLevel represents different logging verbosity levels

const (
	LogLevelNone         LogLevel = "none"          // No traffic logging
	LogLevelMinimal      LogLevel = "minimal"       // Only basic request/response info
	LogLevelNormal       LogLevel = "normal"        // Headers and summary
	LogLevelVerbose      LogLevel = "verbose"       // Everything including text bodies
	LogLevelExtraVerbose LogLevel = "extra-verbose" // Everything including all bodies (text and binary)
)

type OutputFormat

type OutputFormat string

OutputFormat represents different output formats

const (
	FormatText OutputFormat = "text"
	FormatJSON OutputFormat = "json"
	FormatCSV  OutputFormat = "csv"
	FormatHAR  OutputFormat = "har"
)

Jump to

Keyboard shortcuts

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