瀏覽代碼

Fix DNS query log

hmol233 4 年之前
父節點
當前提交
179eec707f
共有 3 個文件被更改,包括 6 次插入6 次删除
  1. 2 2
      app/dns/nameserver_doh.go
  2. 2 2
      app/dns/nameserver_quic.go
  3. 2 2
      app/dns/nameserver_udp.go

+ 2 - 2
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
 			}
 		}

+ 2 - 2
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
 			}
 		}

+ 2 - 2
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
 			}
 		}