mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-08-27 21:59:49 +00:00
@@ -163,6 +163,11 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
|||||||
fixEmptyNames(&respJSON)
|
fixEmptyNames(&respJSON)
|
||||||
|
|
||||||
fullReply := jsondns.Unmarshal(req.reply, &respJSON, req.udpSize, req.ednsClientNetmask)
|
fullReply := jsondns.Unmarshal(req.reply, &respJSON, req.udpSize, req.ednsClientNetmask)
|
||||||
|
if isTCP {
|
||||||
|
fullReply.Truncate(dns.MaxMsgSize)
|
||||||
|
} else {
|
||||||
|
fullReply.Truncate(int(req.udpSize))
|
||||||
|
}
|
||||||
buf, err := fullReply.Pack()
|
buf, err := fullReply.Pack()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@@ -170,15 +175,6 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
|||||||
w.WriteMsg(req.reply)
|
w.WriteMsg(req.reply)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !isTCP && len(buf) > int(req.udpSize) {
|
|
||||||
fullReply.Truncated = true
|
|
||||||
buf, err = fullReply.Pack()
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
buf = buf[:req.udpSize]
|
|
||||||
}
|
|
||||||
w.Write(buf)
|
w.Write(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-9
@@ -231,6 +231,11 @@ func (c *Client) parseResponseIETF(ctx context.Context, w dns.ResponseWriter, r
|
|||||||
_ = fixRecordTTL(rr, timeDelta)
|
_ = fixRecordTTL(rr, timeDelta)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isTCP {
|
||||||
|
fullReply.Truncate(dns.MaxMsgSize)
|
||||||
|
} else {
|
||||||
|
fullReply.Truncate(int(req.udpSize))
|
||||||
|
}
|
||||||
buf, err := fullReply.Pack()
|
buf, err := fullReply.Pack()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("packing error with upstream %s: %v\n", req.currentUpstream, err)
|
log.Printf("packing error with upstream %s: %v\n", req.currentUpstream, err)
|
||||||
@@ -238,15 +243,6 @@ func (c *Client) parseResponseIETF(ctx context.Context, w dns.ResponseWriter, r
|
|||||||
w.WriteMsg(req.reply)
|
w.WriteMsg(req.reply)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !isTCP && len(buf) > int(req.udpSize) {
|
|
||||||
fullReply.Truncated = true
|
|
||||||
buf, err = fullReply.Pack()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("re-packing error with upstream %s: %v\n", req.currentUpstream, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
buf = buf[:req.udpSize]
|
|
||||||
}
|
|
||||||
_, err = w.Write(buf)
|
_, err = w.Write(buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to write to client: %v\n", err)
|
log.Printf("failed to write to client: %v\n", err)
|
||||||
|
|||||||
Reference in New Issue
Block a user