Fix logic to disable DNS periodic update

This commit is contained in:
Quentin McGaw
2020-05-05 22:02:23 +00:00
parent c39affeb12
commit d12668d57f
2 changed files with 10 additions and 2 deletions

View File

@@ -137,5 +137,9 @@ func (p *reader) GetDNSOverTLSIPv6() (ipv6 bool, err error) {
// GetDNSUpdatePeriod obtains the period to use to update the block lists and cryptographic files
// and restart Unbound from the environment variable DNS_UPDATE_PERIOD
func (p *reader) GetDNSUpdatePeriod() (period time.Duration, err error) {
return p.envParams.GetDuration("DNS_UPDATE_PERIOD", libparams.Default("24h"))
s, err := p.envParams.GetEnv("DNS_UPDATE_PERIOD", libparams.Default("24h"))
if err != nil {
return period, err
}
return time.ParseDuration(s)
}

View File

@@ -55,6 +55,10 @@ func (d *DNS) String() string {
for i := range d.Providers {
providersStr[i] = string(d.Providers[i])
}
update := "deactivated"
if d.UpdatePeriod > 0 {
update = fmt.Sprintf("every %s", d.UpdatePeriod)
}
settingsList := []string{
"DNS over TLS settings:",
"DNS over TLS provider:\n |--" + strings.Join(providersStr, "\n |--"),
@@ -68,7 +72,7 @@ func (d *DNS) String() string {
"Verbosity details level: " + fmt.Sprintf("%d/4", d.VerbosityDetailsLevel),
"Validation log level: " + fmt.Sprintf("%d/2", d.ValidationLogLevel),
"IPv6 resolution: " + ipv6,
"Update period: " + d.UpdatePeriod.String(),
"Update: " + update,
}
return strings.Join(settingsList, "\n |--")
}