From 03520e0d6faeeba60d852033bb9232454912f9ca Mon Sep 17 00:00:00 2001 From: yaling888 <73897884+yaling888@users.noreply.github.com> Date: Wed, 18 Jan 2023 16:58:03 +0800 Subject: [PATCH] Fix: dns api panic on disable dns section (#2498) --- hub/route/dns.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hub/route/dns.go b/hub/route/dns.go index c02db022..2918b059 100644 --- a/hub/route/dns.go +++ b/hub/route/dns.go @@ -20,6 +20,12 @@ func dnsRouter() http.Handler { } func queryDNS(w http.ResponseWriter, r *http.Request) { + if resolver.DefaultResolver == nil { + render.Status(r, http.StatusInternalServerError) + render.JSON(w, r, newError("DNS section is disabled")) + return + } + name := r.URL.Query().Get("name") qTypeStr, _ := lo.Coalesce(r.URL.Query().Get("type"), "A")