2021-08-15 19:37:11 +00:00
|
|
|
package service
|
|
|
|
|
|
|
|
import "github.com/spf13/viper"
|
|
|
|
|
|
|
|
type config struct {
|
2021-08-21 18:34:45 +00:00
|
|
|
DNSServer string
|
|
|
|
DNSDefaultTTL uint32
|
|
|
|
UsersConfigDir string
|
2021-08-15 19:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var C config
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
SetConfigDefaults()
|
|
|
|
}
|
|
|
|
|
|
|
|
func SetConfigDefaults() {
|
|
|
|
viper.SetDefault("Service.DNS.Server", "10.10.11.254:53")
|
|
|
|
viper.SetDefault("Service.DNS.DefaultTTL", 60)
|
2021-08-21 18:34:45 +00:00
|
|
|
viper.SetDefault("Service.Users.ConfigDir", "users/")
|
2021-08-15 19:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func LoadConfig() {
|
|
|
|
C.DNSServer = viper.GetString("Service.DNS.Server")
|
2021-08-21 18:34:45 +00:00
|
|
|
C.DNSDefaultTTL = viper.GetUint32("Service.DNS.DefaultTTL")
|
|
|
|
C.UsersConfigDir = viper.GetString("Service.Users.ConfigDir")
|
2021-08-15 19:37:11 +00:00
|
|
|
}
|