mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-06-13 21:54:13 +08:00
Update client_truncate.go
Signed-off-by: songee2020 <61627765+songee2020@users.noreply.github.com>
This commit is contained in:
parent
0d6e834066
commit
b2e02f4500
@ -10,14 +10,14 @@ func TruncateDNSMessage(request *dns.Msg, response *dns.Msg, headroom int) (*buf
|
|||||||
maxLen := 512
|
maxLen := 512
|
||||||
if edns0Option := request.IsEdns0(); edns0Option != nil {
|
if edns0Option := request.IsEdns0(); edns0Option != nil {
|
||||||
if udpSize := int(edns0Option.UDPSize()); udpSize > 512 {
|
if udpSize := int(edns0Option.UDPSize()); udpSize > 512 {
|
||||||
dns.Compress = true
|
response.Compress = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
responseLen := response.Len()
|
responseLen := response.Len()
|
||||||
if responseLen > maxLen {
|
if responseLen > maxLen {
|
||||||
copyResponse := *response
|
copyResponse := *response
|
||||||
response = ©Response
|
response = ©Response
|
||||||
dns.Compress = true
|
dresponse.Compress = true
|
||||||
response.Truncate(maxLen)
|
response.Truncate(maxLen)
|
||||||
}
|
}
|
||||||
buffer := buf.NewSize(headroom*2 + 1 + maxLen)
|
buffer := buf.NewSize(headroom*2 + 1 + maxLen)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user