package config import ( "os" "gopkg.in/yaml.v3" ) type Config struct { Server ServerConfig `yaml:"server"` Database DatabaseConfig `yaml:"database"` Capture CaptureConfig `yaml:"capture"` Detectors DetectorsConfig `yaml:"detectors"` } type ServerConfig struct { Host string `yaml:"host"` Port int `yaml:"port"` } type DatabaseConfig struct { Path string `yaml:"path"` } type CaptureConfig struct { DefaultInterface string `yaml:"default_interface"` Snaplen int32 `yaml:"snaplen"` Promiscuous bool `yaml:"promiscuous"` } type DetectorsConfig struct { PortScan PortScanConfig `yaml:"port_scan"` BruteForce BruteForceConfig `yaml:"brute_force"` DoS DoSConfig `yaml:"dos"` ARPSpoof ARPSpoofConfig `yaml:"arp_spoof"` DNSAnomaly DNSAnomalyConfig `yaml:"dns_anomaly"` } type PortScanConfig struct { Enabled bool `yaml:"enabled"` Threshold int `yaml:"threshold"` WindowSeconds int `yaml:"window_seconds"` Severity string `yaml:"severity"` } type BruteForceConfig struct { Enabled bool `yaml:"enabled"` Threshold int `yaml:"threshold"` WindowSeconds int `yaml:"window_seconds"` Severity string `yaml:"severity"` Ports []int32 `yaml:"ports"` } type DoSConfig struct { Enabled bool `yaml:"enabled"` PPSThreshold int `yaml:"pps_threshold"` WindowSeconds int `yaml:"window_seconds"` Severity string `yaml:"severity"` } type ARPSpoofConfig struct { Enabled bool `yaml:"enabled"` Severity string `yaml:"severity"` } type DNSAnomalyConfig struct { Enabled bool `yaml:"enabled"` MaxLabelLength int `yaml:"max_label_length"` QueryThreshold int `yaml:"query_threshold"` WindowSeconds int `yaml:"window_seconds"` Severity string `yaml:"severity"` } func Load(path string) (*Config, error) { data, err := os.ReadFile(path) if err != nil { return nil, err } var cfg Config if err := yaml.Unmarshal(data, &cfg); err != nil { return nil, err } return &cfg, nil }