mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-10-23 19:32:33 +00:00
Merge pull request #79 from leiless/json-fix-empty-rr-names
[JSON-DOH] Fix DNS response empty []RR.Name
This commit is contained in:
1 file changed
+17
@@ -157,6 +157,7 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
|||||||
if respJSON.Status != dns.RcodeSuccess && respJSON.Comment != "" {
|
if respJSON.Status != dns.RcodeSuccess && respJSON.Comment != "" {
|
||||||
log.Printf("DNS error: %s\n", respJSON.Comment)
|
log.Printf("DNS error: %s\n", respJSON.Comment)
|
||||||
}
|
}
|
||||||
|
fixEmptyNames(&respJSON)
|
||||||
|
|
||||||
fullReply := jsonDNS.Unmarshal(req.reply, &respJSON, req.udpSize, req.ednsClientNetmask)
|
fullReply := jsonDNS.Unmarshal(req.reply, &respJSON, req.udpSize, req.ednsClientNetmask)
|
||||||
buf, err := fullReply.Pack()
|
buf, err := fullReply.Pack()
|
||||||
@@ -177,3 +178,19 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
|||||||
}
|
}
|
||||||
w.Write(buf)
|
w.Write(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fix DNS response empty []RR.Name
|
||||||
|
// Additional section won't be rectified
|
||||||
|
// see: https://stackoverflow.com/questions/52136176/what-is-additional-section-in-dns-and-how-it-works
|
||||||
|
func fixEmptyNames(respJSON *jsonDNS.Response) {
|
||||||
|
for i := range respJSON.Answer {
|
||||||
|
if respJSON.Answer[i].Name == "" {
|
||||||
|
respJSON.Answer[i].Name = "."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for i := range respJSON.Authority {
|
||||||
|
if respJSON.Authority[i].Name == "" {
|
||||||
|
respJSON.Authority[i].Name = "."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user