Pull request 2095: fix nil deref

Squashed commit of the following:

commit 74089af1bb05892ac5c1e4dfefde6256e1b55c02
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Dec 5 20:50:12 2023 +0300

    dnsforward: fix nil deref
This commit is contained in:
Eugene Burkov 2023-12-06 12:10:39 +03:00
parent 99af7f46de
commit a0ec0b2b57

View File

@ -247,7 +247,6 @@ func NewServer(p DNSCreateParams) (s *Server, err error) {
privateNets: p.PrivateNets,
// TODO(e.burkov): Use some case-insensitive string comparison.
localDomainSuffix: strings.ToLower(localDomainSuffix),
etcHosts: p.EtcHosts,
recDetector: newRecursionDetector(recursionTTL, cachedRecurrentReqNum),
clientIDCache: cache.New(cache.Config{
EnableLRU: true,
@ -258,6 +257,9 @@ func NewServer(p DNSCreateParams) (s *Server, err error) {
ServePlainDNS: true,
},
}
if p.EtcHosts != nil {
s.etcHosts = p.EtcHosts
}
s.sysResolvers, err = sysresolv.NewSystemResolvers(nil, defaultPlainDNSPort)
if err != nil {