From 4e8b95e6cdacaed46bf1615c19a39aa58a8ae0cb Mon Sep 17 00:00:00 2001 From: Jiang Zhu <5499746+huskyii@users.noreply.github.com> Date: Mon, 31 Oct 2022 14:59:50 +0000 Subject: [PATCH] Fix issue 660 (#874) Co-authored-by: Juan Font --- CHANGELOG.md | 1 + config.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 870c88c..cb90e95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Add config flag to allow Headscale to start if OIDC provider is down [#829](https://github.com/juanfont/headscale/pull/829) - Random node DNS suffix only applied if names collide in namespace. [#766](https://github.com/juanfont/headscale/issues/766) - Remove `ip_prefix` configuration option and warning [#899](https://github.com/juanfont/headscale/pull/899) +- Fix some DNS config issues [#660](https://github.com/juanfont/headscale/issues/660) ## 0.16.4 (2022-08-21) diff --git a/config.go b/config.go index 1a9d0af..056d93f 100644 --- a/config.go +++ b/config.go @@ -434,17 +434,17 @@ func GetDNSConfig() (*tailcfg.DNSConfig, string) { } if viper.IsSet("dns_config.domains") { - dnsConfig.Domains = viper.GetStringSlice("dns_config.domains") + domains := viper.GetStringSlice("dns_config.domains") + if len(dnsConfig.Nameservers) > 0 { + dnsConfig.Domains = domains + } else if domains != nil { + log.Warn(). + Msg("Warning: dns_config.domains is set, but no nameservers are configured. Ignoring domains.") + } } if viper.IsSet("dns_config.magic_dns") { - magicDNS := viper.GetBool("dns_config.magic_dns") - if len(dnsConfig.Nameservers) > 0 { - dnsConfig.Proxied = magicDNS - } else if magicDNS { - log.Warn(). - Msg("Warning: dns_config.magic_dns is set, but no nameservers are configured. Ignoring magic_dns.") - } + dnsConfig.Proxied = viper.GetBool("dns_config.magic_dns") } var baseDomain string