mirror of
https://github.com/m13253/dns-over-https.git
synced 2026-03-30 07:30:09 +00:00
@@ -163,6 +163,11 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
||||
fixEmptyNames(&respJSON)
|
||||
|
||||
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()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -170,15 +175,6 @@ func (c *Client) parseResponseGoogle(ctx context.Context, w dns.ResponseWriter,
|
||||
w.WriteMsg(req.reply)
|
||||
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)
|
||||
}
|
||||
|
||||
|
||||
@@ -231,6 +231,11 @@ func (c *Client) parseResponseIETF(ctx context.Context, w dns.ResponseWriter, r
|
||||
_ = fixRecordTTL(rr, timeDelta)
|
||||
}
|
||||
|
||||
if isTCP {
|
||||
fullReply.Truncate(dns.MaxMsgSize)
|
||||
} else {
|
||||
fullReply.Truncate(int(req.udpSize))
|
||||
}
|
||||
buf, err := fullReply.Pack()
|
||||
if err != nil {
|
||||
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)
|
||||
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)
|
||||
if err != nil {
|
||||
log.Printf("failed to write to client: %v\n", err)
|
||||
|
||||
Reference in New Issue
Block a user