diff --git a/doh-client/client.go b/doh-client/client.go index 20e6bfe..3ee543a 100644 --- a/doh-client/client.go +++ b/doh-client/client.go @@ -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 { diff --git a/json-dns/unmarshal.go b/json-dns/unmarshal.go index e26b3c5..c97fc69 100644 --- a/json-dns/unmarshal.go +++ b/json-dns/unmarshal.go @@ -52,7 +52,6 @@ func Unmarshal(msg *dns.Msg, resp *Response, udpSize uint16, ednsClientNetmask u reply := msg.Copy() reply.Truncated = resp.TC - reply.RecursionDesired = resp.RD reply.RecursionAvailable = resp.RA reply.AuthenticatedData = resp.AD reply.CheckingDisabled = resp.CD