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
1 changed files with 2 additions and 1 deletions

View File

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