Check HTTP status code

This commit is contained in:
Star Brilliant
2017-11-29 10:33:16 +08:00
parent 1df71ac2b8
commit d3f7665529

View File

@@ -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 {