mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-11-04 10:47:47 +00:00
Improve DNS error handling
This commit is contained in:
1 parent
72211674fa
commit
c42303e93e
2 files changed
+8
-2
No files matched your search
@@ -198,7 +198,10 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
|
||||
log.Printf("HTTP error: %s\n", resp.Status)
|
||||
reply.Rcode = dns.RcodeServerFailure
|
||||
w.WriteMsg(reply)
|
||||
return
|
||||
contentType := resp.Header.Get("Content-Type")
|
||||
if contentType != "application/json" && !strings.HasPrefix(contentType, "application/json;") {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
@@ -218,6 +221,10 @@ func (c *Client) handlerFunc(w dns.ResponseWriter, r *dns.Msg, isTCP bool) {
|
||||
return
|
||||
}
|
||||
|
||||
if respJson.Status != dns.RcodeSuccess && respJson.Comment != "" {
|
||||
log.Printf("DNS error: %s\n", respJson.Comment)
|
||||
}
|
||||
|
||||
fullReply := jsonDNS.Unmarshal(reply, &respJson, udpSize, ednsClientNetmask)
|
||||
buf, err := fullReply.Pack()
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user