DNS: Do not hit cache if encounted err (#3784)

This commit is contained in:
风扇滑翔翼 2024-09-12 22:34:45 +08:00 committed by GitHub
parent 7496413e5c
commit 1b607ff874
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4 additions and 4 deletions

View file

@ -365,7 +365,7 @@ func (s *DoHNameServer) QueryIP(ctx context.Context, domain string, clientIP net
errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name)
} else {
ips, err := s.findIPsForDomain(fqdn, option)
if err != errRecordNotFound {
if err == nil || err == dns_feature.ErrEmptyResponse {
errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips)
log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err})
return ips, err

View file

@ -300,7 +300,7 @@ func (s *QUICNameServer) QueryIP(ctx context.Context, domain string, clientIP ne
errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name)
} else {
ips, err := s.findIPsForDomain(fqdn, option)
if err != errRecordNotFound {
if err == nil || err == dns_feature.ErrEmptyResponse {
errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips)
log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err})
return ips, err

View file

@ -323,7 +323,7 @@ func (s *TCPNameServer) QueryIP(ctx context.Context, domain string, clientIP net
errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name)
} else {
ips, err := s.findIPsForDomain(fqdn, option)
if err != errRecordNotFound {
if err == nil || err == dns_feature.ErrEmptyResponse {
errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips)
log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err})
return ips, err

View file

@ -250,7 +250,7 @@ func (s *ClassicNameServer) QueryIP(ctx context.Context, domain string, clientIP
errors.LogDebug(ctx, "DNS cache is disabled. Querying IP for ", domain, " at ", s.name)
} else {
ips, err := s.findIPsForDomain(fqdn, option)
if err != errRecordNotFound {
if err == nil || err == dns_feature.ErrEmptyResponse {
errors.LogDebugInner(ctx, err, s.name, " cache HIT ", domain, " -> ", ips)
log.Record(&log.DNSLog{Server: s.name, Domain: domain, Result: ips, Status: log.DNSCacheHit, Elapsed: 0, Error: err})
return ips, err