From 785914071104c73515736aafd2b9d91501108b23 Mon Sep 17 00:00:00 2001 From: brad-defined <77982333+brad-defined@users.noreply.github.com> Date: Fri, 16 Apr 2021 14:33:56 -0400 Subject: [PATCH] Only set serveDns if the host is also configured to be a lighthouse. (#433) --- dns_server.go | 2 +- main.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dns_server.go b/dns_server.go index 881d06b..eef5486 100644 --- a/dns_server.go +++ b/dns_server.go @@ -133,7 +133,7 @@ func getDnsServerAddr(c *Config) string { func startDns(l *logrus.Logger, c *Config) { dnsAddr = getDnsServerAddr(c) dnsServer = &dns.Server{Addr: dnsAddr, Net: "udp"} - l.Debugf("Starting DNS responder at %s\n", dnsAddr) + l.WithField("dnsListener", dnsAddr).Infof("Starting DNS responder") err := dnsServer.ListenAndServe() defer dnsServer.Shutdown() if err != nil { diff --git a/main.go b/main.go index fae490f..a775599 100644 --- a/main.go +++ b/main.go @@ -341,7 +341,15 @@ func Main(config *Config, configTest bool, buildVersion string, logger *logrus.L //handshakeMACKey := config.GetString("handshake_mac.key", "") //handshakeAcceptedMACKeys := config.GetStringSlice("handshake_mac.accepted_keys", []string{}) - serveDns := config.GetBool("lighthouse.serve_dns", false) + serveDns := false + if config.GetBool("lighthouse.serve_dns", false) { + if config.GetBool("lighthouse.am_lighthouse", false) { + serveDns = true + } else { + l.Warn("DNS server refusing to run because this host is not a lighthouse.") + } + } + checkInterval := config.GetInt("timers.connection_alive_interval", 5) pendingDeletionInterval := config.GetInt("timers.pending_deletion_interval", 10) ifConfig := &InterfaceConfig{