qcc/internal/config/config.go
2026-06-30 12:52:09 +03:00

64 lines
1.6 KiB
Go

package config
import (
"time"
"github.com/spf13/viper"
)
type Config struct {
Server ServerConfig `mapstructure:"server"`
ACME ACMEConfig `mapstructure:"acme"`
PoW PoWConfig `mapstructure:"pow"`
Identity IdentityConfig `mapstructure:"identity"`
CA CAConfig `mapstructure:"ca"`
Relay RelayConfig `mapstructure:"relay"`
DataDir string `mapstructure:"data_dir"`
LogLevel string `mapstructure:"log_level"`
}
type ServerConfig struct {
Listen string `mapstructure:"listen"`
}
type ACMEConfig struct {
Domains []string `mapstructure:"domains"`
Email string `mapstructure:"email"`
CA string `mapstructure:"ca"`
Type string `mapstructure:"type"`
DNS ACMEDNSConfig `mapstructure:"dns"`
}
type ACMEDNSConfig struct {
Name string `mapstructure:"name"`
Config map[string]string `mapstructure:"config"`
}
type PoWConfig struct {
Difficulty int `mapstructure:"difficulty"`
ChallengeTTL time.Duration `mapstructure:"challenge_ttl"`
}
type IdentityConfig struct {
Cooldown time.Duration `mapstructure:"cooldown"`
Prefix string `mapstructure:"prefix"`
}
type CAConfig struct {
KeyType string `mapstructure:"key_type"`
Validity time.Duration `mapstructure:"validity"`
}
type RelayConfig struct {
BandwidthUp string `mapstructure:"bandwidth_up"`
BandwidthDown string `mapstructure:"bandwidth_down"`
MediaTimeout time.Duration `mapstructure:"media_timeout"`
}
func Load() *Config {
cfg := &Config{}
if err := viper.Unmarshal(cfg); err != nil {
panic(err)
}
return cfg
}