Fix dns log

This commit is contained in:
世界 2023-09-24 12:38:21 +08:00
parent fbaa2f9de9
commit 5a1ddea100
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -133,11 +133,11 @@ func (r *Router) Lookup(ctx context.Context, domain string, strategy dns.DomainS
addrs, err := r.dnsClient.Lookup(ctx, transport, domain, strategy) addrs, err := r.dnsClient.Lookup(ctx, transport, domain, strategy)
if len(addrs) > 0 { if len(addrs) > 0 {
r.dnsLogger.InfoContext(ctx, "lookup succeed for ", domain, ": ", strings.Join(F.MapToString(addrs), " ")) r.dnsLogger.InfoContext(ctx, "lookup succeed for ", domain, ": ", strings.Join(F.MapToString(addrs), " "))
} else { } else if err != nil {
r.dnsLogger.ErrorContext(ctx, E.Cause(err, "lookup failed for ", domain)) r.dnsLogger.ErrorContext(ctx, E.Cause(err, "lookup failed for ", domain))
if err == nil { } else {
err = dns.RCodeNameError r.dnsLogger.ErrorContext(ctx, "lookup failed for ", domain, ": empty result")
} err = dns.RCodeNameError
} }
return addrs, err return addrs, err
} }