Updated qr code events and tls server
Some checks failed
CI / Test (1.22) (push) Failing after -25m23s
CI / Test (1.23) (push) Failing after -25m25s
CI / Build (push) Failing after -25m51s
CI / Lint (push) Failing after -25m40s

This commit is contained in:
2025-12-29 17:22:06 +02:00
parent bb9aa01519
commit 94fc899bab
17 changed files with 929 additions and 26 deletions

View File

@@ -18,12 +18,30 @@ type Config struct {
// ServerConfig holds server-specific configuration
type ServerConfig struct {
Host string `json:"host"`
Port int `json:"port"`
DefaultCountryCode string `json:"default_country_code,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
AuthKey string `json:"auth_key,omitempty"`
Host string `json:"host"`
Port int `json:"port"`
DefaultCountryCode string `json:"default_country_code,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
AuthKey string `json:"auth_key,omitempty"`
TLS TLSConfig `json:"tls,omitempty"`
}
// TLSConfig holds TLS/HTTPS configuration
type TLSConfig struct {
Enabled bool `json:"enabled"` // Enable HTTPS
Mode string `json:"mode"` // "self-signed", "custom", or "autocert"
CertFile string `json:"cert_file,omitempty"` // Path to certificate file (for custom mode)
KeyFile string `json:"key_file,omitempty"` // Path to key file (for custom mode)
// Self-signed certificate options
CertDir string `json:"cert_dir,omitempty"` // Directory to store generated certificates
// Let's Encrypt / autocert options
Domain string `json:"domain,omitempty"` // Domain name for Let's Encrypt
Email string `json:"email,omitempty"` // Email for Let's Encrypt notifications
CacheDir string `json:"cache_dir,omitempty"` // Cache directory for autocert
Production bool `json:"production,omitempty"` // Use Let's Encrypt production (default: staging)
}
// WhatsAppConfig holds configuration for a WhatsApp account
@@ -139,6 +157,19 @@ func Load(path string) (*Config, error) {
}
}
// Set TLS defaults if enabled
if cfg.Server.TLS.Enabled {
if cfg.Server.TLS.Mode == "" {
cfg.Server.TLS.Mode = "self-signed"
}
if cfg.Server.TLS.CertDir == "" {
cfg.Server.TLS.CertDir = "./data/certs"
}
if cfg.Server.TLS.CacheDir == "" {
cfg.Server.TLS.CacheDir = "./data/autocert"
}
}
return &cfg, nil
}