From da4a9dadd52e0e56aa8cd852a3b543738df0fb63 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Mon, 4 Oct 2021 22:16:53 +0200 Subject: [PATCH] Warn users when MagicDNS is set with no DNS servers --- cmd/headscale/cli/utils.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/headscale/cli/utils.go b/cmd/headscale/cli/utils.go index 9aa63525..f879f91e 100644 --- a/cmd/headscale/cli/utils.go +++ b/cmd/headscale/cli/utils.go @@ -108,9 +108,13 @@ func GetDNSConfig() (*tailcfg.DNSConfig, string) { dnsConfig.Domains = viper.GetStringSlice("dns_config.domains") } - if len(dnsConfig.Nameservers) > 0 { - if viper.IsSet("dns_config.magic_dns") { - dnsConfig.Proxied = viper.GetBool("dns_config.magic_dns") + 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.") } } @@ -186,7 +190,7 @@ func getHeadscaleApp() (*headscale.Headscale, error) { TLSKeyPath: absPath(viper.GetString("tls_key_path")), DNSConfig: dnsConfig, - + ACMEEmail: viper.GetString("acme_email"), ACMEURL: viper.GetString("acme_url"), }