DNS_UPDATE_PERIOD environment variable

This commit is contained in:
Quentin McGaw
2020-05-05 18:00:56 +00:00
parent 37282c014b
commit d73765a5f5
7 changed files with 27 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"net"
"strings"
"time"
libparams "github.com/qdm12/golibs/params"
"github.com/qdm12/private-internet-access-docker/internal/constants"
@@ -132,3 +133,9 @@ func (p *reader) GetDNSOverTLSPrivateAddresses() (privateAddresses []string, err
func (p *reader) GetDNSOverTLSIPv6() (ipv6 bool, err error) {
return p.envParams.GetOnOff("DOT_IPV6", libparams.Default("off"))
}
// 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"))
}

View File

@@ -3,6 +3,7 @@ package params
import (
"net"
"os"
"time"
"github.com/qdm12/golibs/logging"
libparams "github.com/qdm12/golibs/params"
@@ -27,6 +28,7 @@ type Reader interface {
GetDNSUnblockedHostnames() (hostnames []string, err error)
GetDNSOverTLSPrivateAddresses() (privateAddresses []string, err error)
GetDNSOverTLSIPv6() (ipv6 bool, err error)
GetDNSUpdatePeriod() (period time.Duration, err error)
// System
GetUID() (uid int, err error)

View File

@@ -3,6 +3,7 @@ package settings
import (
"fmt"
"strings"
"time"
"github.com/qdm12/private-internet-access-docker/internal/constants"
"github.com/qdm12/private-internet-access-docker/internal/models"
@@ -23,6 +24,7 @@ type DNS struct {
VerbosityDetailsLevel uint8
ValidationLogLevel uint8
IPv6 bool
UpdatePeriod time.Duration
}
func (d *DNS) String() string {
@@ -66,6 +68,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(),
}
return strings.Join(settingsList, "\n |--")
}
@@ -120,6 +123,10 @@ func GetDNSSettings(paramsReader params.Reader) (settings DNS, err error) {
if err != nil {
return settings, err
}
settings.UpdatePeriod, err = paramsReader.GetDNSUpdatePeriod()
if err != nil {
return settings, err
}
// Consistency check
IPv6Support := false