From d3f7665529394f80dd051b2b8bec16f9ba508e93 Mon Sep 17 00:00:00 2001 From: Star Brilliant Date: Wed, 29 Nov 2017 10:33:16 +0800 Subject: [PATCH] Check HTTP status code --- doh-client/client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doh-client/client.go b/doh-client/client.go index 4d76cc9..717658f 100644 --- a/doh-client/client.go +++ b/doh-client/client.go @@ -183,6 +183,12 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) { w.WriteMsg(reply) return } + if resp.StatusCode != 200 { + log.Printf("Server returned error: %s\n", resp.Status) + reply.Rcode = dns.RcodeServerFailure + w.WriteMsg(reply) + return + } body, err := ioutil.ReadAll(resp.Body) if err != nil {