diff --git a/dnsforward/dnsforward.go b/dnsforward/dnsforward.go index 8d5ec767..87093879 100644 --- a/dnsforward/dnsforward.go +++ b/dnsforward/dnsforward.go @@ -82,9 +82,9 @@ func NewServer(p DNSCreateParams) *Server { s.dnsFilter = p.DNSFilter s.stats = p.Stats s.queryLog = p.QueryLog - s.dhcpServer = p.DHCPServer - if s.dhcpServer != nil { + if p.DHCPServer != nil { + s.dhcpServer = p.DHCPServer s.dhcpServer.SetOnLeaseChanged(s.onDHCPLeaseChanged) s.onDHCPLeaseChanged(dhcpd.LeaseChangedAdded) } diff --git a/home/dns.go b/home/dns.go index 1ff0da32..2d647f94 100644 --- a/home/dns.go +++ b/home/dns.go @@ -62,10 +62,12 @@ func initDNSServer() error { Context.dnsFilter = dnsfilter.New(&filterConf, nil) p := dnsforward.DNSCreateParams{ - DNSFilter: Context.dnsFilter, - Stats: Context.stats, - QueryLog: Context.queryLog, - DHCPServer: Context.dhcpServer, + DNSFilter: Context.dnsFilter, + Stats: Context.stats, + QueryLog: Context.queryLog, + } + if Context.dhcpServer != nil { + p.DHCPServer = Context.dhcpServer } Context.dnsServer = dnsforward.NewServer(p) dnsConfig := generateServerConfig()