Pull request 1961: 6106-fix-dns-filter

Updates #6106.

Squashed commit of the following:

commit e06ae2195c9231901dda76b7afc00f45021ee369
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Aug 15 14:13:15 2023 +0300

    dnsforward: add docs

commit c9d77fa04b4d358593e492a9abdca94053ace631
Author: Stanislav Chzhen <s.chzhen@adguard.com>
Date:   Tue Aug 15 14:02:32 2023 +0300

    dnsforward: fix dns filter
This commit is contained in:
Stanislav Chzhen 2023-08-15 14:29:08 +03:00
parent 85e87b9c1d
commit 887c48cee8
2 changed files with 4 additions and 2 deletions

View File

@ -667,7 +667,8 @@ func (s *Server) parseUpstreamLine(
PreferIPv6: opts.PreferIPv6,
}
if s.dnsFilter.EtcHosts != nil {
// dnsFilter can be nil during application update.
if s.dnsFilter != nil && s.dnsFilter.EtcHosts != nil {
resolved := s.resolveUpstreamHost(extractUpstreamHost(upstreamAddr))
sortNetIPAddrs(resolved, opts.PreferIPv6)
opts.ServerIPAddrs = resolved

View File

@ -94,7 +94,8 @@ func (s *Server) prepareUpstreamConfig(
uc.Upstreams = defaultUpstreamConfig.Upstreams
}
if s.dnsFilter.EtcHosts != nil {
// dnsFilter can be nil during application update.
if s.dnsFilter != nil && s.dnsFilter.EtcHosts != nil {
err = s.replaceUpstreamsWithHosts(uc, opts)
if err != nil {
return nil, fmt.Errorf("resolving upstreams with hosts: %w", err)