package config import ( "fmt" "os" "gopkg.in/yaml.v3" ) // Config represents the proxy configuration type Config struct { Listen struct { Address string `yaml:"address"` Port int `yaml:"port"` } `yaml:"listen"` TLS struct { Enabled bool `yaml:"enabled"` CertFile string `yaml:"cert_file"` KeyFile string `yaml:"key_file"` LetsEncrypt struct { Enabled bool `yaml:"enabled"` Email string `yaml:"email"` // Email for Let's Encrypt registration CacheDir string `yaml:"cache_dir"` // Directory to store certificates (default: ./certs/letsencrypt) Staging bool `yaml:"staging"` // Use Let's Encrypt staging environment } `yaml:"letsencrypt"` } `yaml:"tls"` Mappings []struct { External string `yaml:"external"` Internal string `yaml:"internal"` Port int `yaml:"port"` // Optional, defaults to 5432 } `yaml:"mappings"` Debug bool `yaml:"debug"` } // loadConfig loads configuration from YAML file func LoadConfig(configPath string) (*Config, error) { data, err := os.ReadFile(configPath) if err != nil { return nil, fmt.Errorf("failed to read config file: %w", err) } var config Config if err := yaml.Unmarshal(data, &config); err != nil { return nil, fmt.Errorf("failed to parse config file: %w", err) } return &config, nil }