From 5a1ddea10038495da73e4598e285d6aeaa0e3695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 24 Sep 2023 12:38:21 +0800 Subject: [PATCH] Fix dns log --- route/router_dns.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/route/router_dns.go b/route/router_dns.go index 3c76e999..1532df94 100644 --- a/route/router_dns.go +++ b/route/router_dns.go @@ -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) if len(addrs) > 0 { 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)) - if err == nil { - err = dns.RCodeNameError - } + } else { + r.dnsLogger.ErrorContext(ctx, "lookup failed for ", domain, ": empty result") + err = dns.RCodeNameError } return addrs, err }