chore(settings): refactor settings processing (#756)
- Better settings tree structure logged using `qdm12/gotree` - Read settings from environment variables, then files, then secret files - Settings methods to default them, merge them and override them - `DNS_PLAINTEXT_ADDRESS` default changed to `127.0.0.1` to use DoT. Warning added if set to something else. - `HTTPPROXY_LISTENING_ADDRESS` instead of `HTTPPROXY_PORT` (with retro-compatibility)
This commit is contained in:
50
internal/configuration/sources/env/updater.go
vendored
Normal file
50
internal/configuration/sources/env/updater.go
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
package env
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
)
|
||||
|
||||
func readUpdater() (updater settings.Updater, err error) {
|
||||
updater.Period, err = readUpdaterPeriod()
|
||||
if err != nil {
|
||||
return updater, err
|
||||
}
|
||||
|
||||
updater.DNSAddress, err = readUpdaterDNSAddress()
|
||||
if err != nil {
|
||||
return updater, err
|
||||
}
|
||||
|
||||
// TODO use current provider being used
|
||||
updater.Providers = constants.AllProviders()
|
||||
|
||||
return updater, nil
|
||||
}
|
||||
|
||||
func readUpdaterPeriod() (period *time.Duration, err error) {
|
||||
s := os.Getenv("UPDATER_PERIOD")
|
||||
if s == "" {
|
||||
return nil, nil //nolint:nilnil
|
||||
}
|
||||
period = new(time.Duration)
|
||||
*period, err = time.ParseDuration(s)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("environment variable UPDATER_PERIOD: %w", err)
|
||||
}
|
||||
return period, nil
|
||||
}
|
||||
|
||||
func readUpdaterDNSAddress() (ip net.IP, err error) {
|
||||
// TODO this is currently using Cloudflare in
|
||||
// plaintext to not be blocked by DNS over TLS by default.
|
||||
// If a plaintext address is set in the DNS settings, this one will be used.
|
||||
// use custom future encrypted DNS written in Go without blocking
|
||||
// as it's too much trouble to start another parallel unbound instance for now.
|
||||
return nil, nil
|
||||
}
|
||||
Reference in New Issue
Block a user