From be19831cb601d945ce1bde713ff0c87f2604202d Mon Sep 17 00:00:00 2001 From: "weizhong.twz" Date: Thu, 7 Jan 2021 15:39:30 +0800 Subject: [PATCH] fix resp --- primitive/nsresolver.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/primitive/nsresolver.go b/primitive/nsresolver.go index f57d13b3..4e5917c8 100644 --- a/primitive/nsresolver.go +++ b/primitive/nsresolver.go @@ -130,12 +130,15 @@ func (h *HttpResolver) Description() string { func (h *HttpResolver) get() []string { resp, err := h.cli.Get(h.domain) - if err != nil || resp.StatusCode != 200 { - rlog.Error("name server http fetch failed", map[string]interface{}{ + if err != nil || resp == nil || resp.StatusCode != 200 { + data := map[string]interface{}{ "NameServerDomain": h.domain, - "StatusCode": resp.StatusCode, "err": err, - }) + } + if resp != nil { + data["StatusCode"] = resp.StatusCode + } + rlog.Error("name server http fetch failed", data) return nil }