Updated qr code events and tls server
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user