From 179eec707fccbe79ba739d48485f44b6dc441480 Mon Sep 17 00:00:00 2001 From: hmol233 <82594500+hmol233@users.noreply.github.com> Date: Sun, 16 May 2021 19:12:04 +0800 Subject: [PATCH] Fix DNS query log --- app/dns/nameserver_doh.go | 4 ++-- app/dns/nameserver_quic.go | 4 ++-- app/dns/nameserver_udp.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/dns/nameserver_doh.go b/app/dns/nameserver_doh.go index 81e5561d..92ced968 100644 --- a/app/dns/nameserver_doh.go +++ b/app/dns/nameserver_doh.go @@ -371,9 +371,9 @@ func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, clientIP net } else { ips, err := s.findIPsForDomain(fqdn, option) if err != errRecordNotFound { - if cs == CacheStrategy_Cache_NOERROR && err == nil { + if cs == CacheStrategy_Cache_ALL || (cs == CacheStrategy_Cache_NOERROR && err == nil) { newError(s.name, " cache HIT ", domain, " -> ", ips).Base(err).AtDebug().WriteToLog() - log.Record(&log.DNSLog{s.name, domain, ips, log.DNSCacheHit, 0, err}) + log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Error: err}) return ips, err } } diff --git a/app/dns/nameserver_quic.go b/app/dns/nameserver_quic.go index f7f08927..1ad7fd58 100644 --- a/app/dns/nameserver_quic.go +++ b/app/dns/nameserver_quic.go @@ -276,9 +276,9 @@ func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, clientIP ne } else { ips, err := s.findIPsForDomain(fqdn, option) if err != errRecordNotFound { - if cs == CacheStrategy_Cache_NOERROR && err == nil { + if cs == CacheStrategy_Cache_ALL || (cs == CacheStrategy_Cache_NOERROR && err == nil) { newError(s.name, " cache HIT ", domain, " -> ", ips).Base(err).AtDebug().WriteToLog() - log.Record(&log.DNSLog{s.name, domain, ips, log.DNSCacheHit, 0, err}) + log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Error: err}) return ips, err } } diff --git a/app/dns/nameserver_udp.go b/app/dns/nameserver_udp.go index fa6327c5..20dc06d8 100644 --- a/app/dns/nameserver_udp.go +++ b/app/dns/nameserver_udp.go @@ -253,9 +253,9 @@ func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP } else { ips, err := s.findIPsForDomain(fqdn, option) if err != errRecordNotFound { - if cs == CacheStrategy_Cache_NOERROR && err == nil { + if cs == CacheStrategy_Cache_ALL || (cs == CacheStrategy_Cache_NOERROR && err == nil) { newError(s.name, " cache HIT ", domain, " -> ", ips).Base(err).AtDebug().WriteToLog() - log.Record(&log.DNSLog{s.name, domain, ips, log.DNSCacheHit, 0, err}) + log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Error: err}) return ips, err } }