* rDNS: refactor
This commit is contained in:
14
home/dns.go
14
home/dns.go
@@ -5,27 +5,19 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"github.com/AdguardTeam/AdGuardHome/dnsfilter"
|
||||
"github.com/AdguardTeam/AdGuardHome/dnsforward"
|
||||
"github.com/AdguardTeam/AdGuardHome/querylog"
|
||||
"github.com/AdguardTeam/AdGuardHome/stats"
|
||||
"github.com/AdguardTeam/dnsproxy/proxy"
|
||||
"github.com/AdguardTeam/dnsproxy/upstream"
|
||||
"github.com/AdguardTeam/golibs/log"
|
||||
"github.com/joomcode/errorx"
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
type dnsContext struct {
|
||||
rdnsChannel chan string // pass data from DNS request handling thread to rDNS thread
|
||||
// contains IP addresses of clients to be resolved by rDNS
|
||||
// if IP address couldn't be resolved, it stays here forever to prevent further attempts to resolve the same IP
|
||||
rdnsIP map[string]bool
|
||||
rdnsLock sync.Mutex // synchronize access to rdnsIP
|
||||
upstream upstream.Upstream // Upstream object for our own DNS server
|
||||
|
||||
rdns *RDNS
|
||||
whois *Whois
|
||||
}
|
||||
|
||||
@@ -57,7 +49,7 @@ func initDNSServer(baseDir string) {
|
||||
config.auth = InitAuth(sessFilename, config.Users)
|
||||
config.Users = nil
|
||||
|
||||
initRDNS()
|
||||
config.dnsctx.rdns = InitRDNS(&config.clients)
|
||||
config.dnsctx.whois = initWhois(&config.clients)
|
||||
initFiltering()
|
||||
}
|
||||
@@ -133,7 +125,7 @@ func onDNSRequest(d *proxy.DNSContext) {
|
||||
|
||||
ipAddr := net.ParseIP(ip)
|
||||
if !ipAddr.IsLoopback() {
|
||||
beginAsyncRDNS(ip)
|
||||
config.dnsctx.rdns.Begin(ip)
|
||||
}
|
||||
if isPublicIP(ipAddr) {
|
||||
config.dnsctx.whois.Begin(ip)
|
||||
|
||||
Reference in New Issue
Block a user