Merge pull request #202 in DNS/adguard-dns from fix/647 to master
* commit '528c1a72cac331f08de5fdee4538529c70dff1bb': - use 127.0.0.1 as a resolver address when DNS binding address is 0.0.0.0 - app: don't print filter update error messages on first launch before DNS server is set up
This commit is contained in:
commit
8e6f7be5b8
6
dns.go
6
dns.go
|
@ -50,7 +50,11 @@ func generateServerConfig() dnsforward.ServerConfig {
|
|||
FilteringConfig: config.DNS.FilteringConfig,
|
||||
Filters: filters,
|
||||
}
|
||||
newconfig.ResolverAddress = fmt.Sprintf("%s:%d", config.DNS.BindHost, config.DNS.Port)
|
||||
bindhost := config.DNS.BindHost
|
||||
if config.DNS.BindHost == "0.0.0.0" {
|
||||
bindhost = "127.0.0.1"
|
||||
}
|
||||
newconfig.ResolverAddress = fmt.Sprintf("%s:%d", bindhost, config.DNS.Port)
|
||||
|
||||
if config.TLS.Enabled {
|
||||
newconfig.TLSConfig = config.TLS.TLSConfig
|
||||
|
|
|
@ -178,6 +178,10 @@ func periodicallyRefreshFilters() {
|
|||
func refreshFiltersIfNecessary(force bool) int {
|
||||
var updateFilters []filter
|
||||
|
||||
if config.firstRun {
|
||||
return 0
|
||||
}
|
||||
|
||||
config.RLock()
|
||||
for i := range config.Filters {
|
||||
f := &config.Filters[i] // otherwise we will be operating on a copy
|
||||
|
|
|
@ -323,7 +323,11 @@ func customDialContext(ctx context.Context, network, addr string) (net.Conn, err
|
|||
return con, err
|
||||
}
|
||||
|
||||
resolverAddr := fmt.Sprintf("%s:%d", config.DNS.BindHost, config.DNS.Port)
|
||||
bindhost := config.DNS.BindHost
|
||||
if config.DNS.BindHost == "0.0.0.0" {
|
||||
bindhost = "127.0.0.1"
|
||||
}
|
||||
resolverAddr := fmt.Sprintf("%s:%d", bindhost, config.DNS.Port)
|
||||
r := upstream.NewResolver(resolverAddr, 30*time.Second)
|
||||
addrs, e := r.LookupIPAddr(ctx, host)
|
||||
log.Tracef("LookupIPAddr: %s: %v", host, addrs)
|
||||
|
|
Loading…
Reference in New Issue