// Package config holds process bootstrap configuration: everything needed // before the database is even open. Runtime/admin-tunable settings (ACME // email, retention, trusted proxies, etc.) live in the database instead — // see internal/database's settings table — so they can change without a // restart. package config import ( "flag" "os" ) type Config struct { DataDir string DBPath string HTTPAddr string HTTPSAddr string AdminAddr string } func Default() Config { return Config{ DataDir: "./data", DBPath: "./data/vibeproxy.db", HTTPAddr: ":80", HTTPSAddr: ":443", AdminAddr: ":8081", } } // RegisterFlags binds cfg's fields to flags on fs, seeded from environment // variables (VIBEPROXY_*) so the same binary works under systemd or Docker // without a wrapper script. func RegisterFlags(fs *flag.FlagSet, cfg *Config) { fs.StringVar(&cfg.DataDir, "data-dir", envOr("VIBEPROXY_DATA_DIR", cfg.DataDir), "directory for the database, certificates, and backups") fs.StringVar(&cfg.DBPath, "db-path", envOr("VIBEPROXY_DB_PATH", cfg.DBPath), "path to the SQLite database file") fs.StringVar(&cfg.HTTPAddr, "http-addr", envOr("VIBEPROXY_HTTP_ADDR", cfg.HTTPAddr), "address for the plain HTTP proxy listener") fs.StringVar(&cfg.HTTPSAddr, "https-addr", envOr("VIBEPROXY_HTTPS_ADDR", cfg.HTTPSAddr), "address for the HTTPS proxy listener") fs.StringVar(&cfg.AdminAddr, "admin-addr", envOr("VIBEPROXY_ADMIN_ADDR", cfg.AdminAddr), "address for the admin web UI, REST API, and /metrics, /healthz, /readyz") } func envOr(key, def string) string { if v := os.Getenv(key); v != "" { return v } return def }