Pull request: home: fix dns address fallback
Closes #2868. Squashed commit of the following: commit 7497b0d80233fa0f0fbdc94a85007d39566eea73 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Mar 24 14:23:41 2021 +0300 home: fix specified ip collecting commit 7b1dfa69f4edeb3e07cd1067f77ff8519bcdbe1c Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Mar 24 14:01:25 2021 +0300 home: fix dns address fallback
This commit is contained in:
@@ -9,7 +9,6 @@ import (
|
||||
"strconv"
|
||||
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/agherr"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/dnsfilter"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/dnsforward"
|
||||
"github.com/AdguardTeam/AdGuardHome/internal/querylog"
|
||||
@@ -144,10 +143,8 @@ func ipsToUDPAddrs(ips []net.IP, port int) (udpAddrs []*net.UDPAddr) {
|
||||
func generateServerConfig() (newConf dnsforward.ServerConfig, err error) {
|
||||
dnsConf := config.DNS
|
||||
hosts := dnsConf.BindHosts
|
||||
for i, h := range hosts {
|
||||
if h.IsUnspecified() {
|
||||
hosts[i] = net.IP{127, 0, 0, 1}
|
||||
}
|
||||
if len(hosts) == 0 {
|
||||
hosts = []net.IP{{127, 0, 0, 1}}
|
||||
}
|
||||
|
||||
newConf = dnsforward.ServerConfig{
|
||||
@@ -268,42 +265,6 @@ func getDNSEncryption() (de dnsEncryption) {
|
||||
return de
|
||||
}
|
||||
|
||||
// Get the list of DNS addresses the server is listening on
|
||||
func getDNSAddresses() (dnsAddrs []string) {
|
||||
if hosts := config.DNS.BindHosts; len(hosts) == 0 || hosts[0].IsUnspecified() {
|
||||
ifaces, e := aghnet.GetValidNetInterfacesForWeb()
|
||||
if e != nil {
|
||||
log.Error("Couldn't get network interfaces: %v", e)
|
||||
return []string{}
|
||||
}
|
||||
|
||||
for _, iface := range ifaces {
|
||||
for _, addr := range iface.Addresses {
|
||||
addDNSAddress(&dnsAddrs, addr)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, h := range hosts {
|
||||
addDNSAddress(&dnsAddrs, h)
|
||||
}
|
||||
}
|
||||
|
||||
de := getDNSEncryption()
|
||||
if de.https != "" {
|
||||
dnsAddrs = append(dnsAddrs, de.https)
|
||||
}
|
||||
|
||||
if de.tls != "" {
|
||||
dnsAddrs = append(dnsAddrs, de.tls)
|
||||
}
|
||||
|
||||
if de.quic != "" {
|
||||
dnsAddrs = append(dnsAddrs, de.quic)
|
||||
}
|
||||
|
||||
return dnsAddrs
|
||||
}
|
||||
|
||||
// applyAdditionalFiltering adds additional client information and settings if
|
||||
// the client has them.
|
||||
func applyAdditionalFiltering(clientAddr net.IP, clientID string, setts *dnsfilter.RequestFilteringSettings) {
|
||||
|
||||
Reference in New Issue
Block a user