From 1a9f547cfe47121220e709b74544e30190e10b36 Mon Sep 17 00:00:00 2001 From: Vladislav Yarmak Date: Tue, 14 Apr 2020 11:45:03 +0300 Subject: [PATCH] minor improvements --- handler.go | 2 +- resolver.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/handler.go b/handler.go index 75e5f27..52efb6a 100644 --- a/handler.go +++ b/handler.go @@ -154,7 +154,7 @@ func (s *ProxyHandler) ServeHTTP(wr http.ResponseWriter, req *http.Request) { proxyReq, err := makeConnReq(orig_req.RequestURI, s.resolver) if err != nil { s.logger.Error("Can't rewrite request: %v", err) - http.Error(wr, "Can't rewrite request", http.StatusInternalServerError) + http.Error(wr, "Can't rewrite request", http.StatusBadGateway) return } proxyReq.Header.Set("Proxy-Authorization", s.auth()) diff --git a/resolver.go b/resolver.go index 548c9dd..6c77054 100644 --- a/resolver.go +++ b/resolver.go @@ -74,8 +74,9 @@ func (r *Resolver) ResolveAAAA(domain string) []string { } func (r *Resolver) Resolve(domain string) []string { - res := make([]string, 0) - res = append(res, r.ResolveA(domain)...) - res = append(res, r.ResolveAAAA(domain)...) + res := r.ResolveA(domain) + if len(res) == 0 { + res = r.ResolveAAAA(domain) + } return res }