Pull request 1840: 5752-unspec-ipv6

Merge in DNS/adguard-home from 5752-unspec-ipv6 to master

Closes .

Squashed commit of the following:

commit 654b808d17c6d2374b6be919515113b361fc5ff7
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Fri Apr 21 18:11:34 2023 +0300

    home: imp docs

commit 28b4c36df790f1eaa05b11a1f0a7b986894d37dc
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Fri Apr 21 16:50:16 2023 +0300

    all: fix empty bind host
This commit is contained in:
Eugene Burkov 2023-04-21 18:57:53 +03:00
parent 757ddb06f8
commit 620b51e3ea
4 changed files with 32 additions and 2 deletions
internal/home

View file

@ -414,6 +414,22 @@ func getLogSettings() logSettings {
return l
}
// validateBindHosts returns error if any of binding hosts from configuration is
// not a valid IP address.
func validateBindHosts(conf *configuration) (err error) {
if !conf.BindHost.IsValid() {
return errors.Error("bind_host is not a valid ip address")
}
for i, addr := range conf.DNS.BindHosts {
if !addr.IsValid() {
return fmt.Errorf("dns.bind_hosts at index %d is not a valid ip address", i)
}
}
return nil
}
// parseConfig loads configuration from the YAML file
func parseConfig() (err error) {
var fileData []byte
@ -425,6 +441,13 @@ func parseConfig() (err error) {
config.fileData = nil
err = yaml.Unmarshal(fileData, &config)
if err != nil {
// Don't wrap the error since it's informative enough as is.
return err
}
err = validateBindHosts(config)
if err != nil {
// Don't wrap the error since it's informative enough as is.
return err
}