feat: configure magic dns suffix

This commit is contained in:
Johan Siebens
2022-09-22 18:23:42 +02:00
parent 617575803c
commit 0051eec355
5 changed files with 53 additions and 26 deletions
+33 -4
View File
@@ -16,10 +16,24 @@ import (
"time"
)
var (
KeepAliveInterval = 1 * time.Minute
const (
defaultKeepAliveInterval = 1 * time.Minute
defaultMagicDNSSuffix = "ionscale.net"
)
var (
keepAliveInterval = defaultKeepAliveInterval
magicDNSSuffix = defaultMagicDNSSuffix
)
func KeepAliveInterval() time.Duration {
return keepAliveInterval
}
func MagicDNSSuffix() string {
return magicDNSSuffix
}
func LoadConfig(path string, flagsCfg *Config) (*Config, error) {
cfg := defaultConfig()
@@ -59,6 +73,9 @@ func LoadConfig(path string, flagsCfg *Config) (*Config, error) {
return nil, err
}
keepAliveInterval = cfg.PollNet.KeepAliveInterval
magicDNSSuffix = cfg.DNS.MagicDNSSuffix
return cfg, nil
}
@@ -79,8 +96,15 @@ func defaultConfig() *Config {
AcmeCA: certmagic.LetsEncryptProductionCA,
AcmePath: "./acme",
},
PollNet: PollNet{KeepAliveInterval: 1 * time.Minute},
Logging: Logging{Level: "info"},
PollNet: PollNet{
KeepAliveInterval: defaultKeepAliveInterval,
},
DNS: DNS{
MagicDNSSuffix: defaultMagicDNSSuffix,
},
Logging: Logging{
Level: "info",
},
}
}
@@ -100,6 +124,7 @@ type Config struct {
Keys Keys `yaml:"keys,omitempty" envPrefix:"KEYS_"`
Database Database `yaml:"database,omitempty" envPrefix:"DB_"`
AuthProvider AuthProvider `yaml:"auth_provider,omitempty"`
DNS DNS `yaml:"dns,omitempty"`
Logging Logging `yaml:"logging,omitempty" envPrefix:"LOGGING_"`
}
@@ -143,6 +168,10 @@ type AuthProvider struct {
SystemAdminPolicy SystemAdminPolicy `yaml:"system_admins"`
}
type DNS struct {
MagicDNSSuffix string `yaml:"magic_dns_suffix"`
}
type SystemAdminPolicy struct {
Subs []string `json:"subs,omitempty"`
Emails []string `json:"emails,omitempty"`