Copy DNS message struct instead of deep copy

This commit is contained in:
世界 2024-02-10 23:46:52 +08:00
parent 8332878cdc
commit bca0b86549
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -270,7 +270,8 @@ func truncateDNSMessage(response *mDNS.Msg, maxLen int) *mDNS.Msg {
if responseLen <= maxLen { if responseLen <= maxLen {
return response return response
} }
response = response.Copy() newResponse := *response
response = &newResponse
for len(response.Answer) > 0 && responseLen > maxLen { for len(response.Answer) > 0 && responseLen > maxLen {
response.Answer = response.Answer[:len(response.Answer)-1] response.Answer = response.Answer[:len(response.Answer)-1]
response.Truncated = true response.Truncated = true