Debian Codegraph @

dnsutil/truncate.go

raw
1 package dnsutil
2
3 import "codeberg.org/miekg/dns"
4
5 // Truncate helps ensure the reply message will fit into the requested buffer
6 // size by removing all records and only leaving the question section and the pseudo section.
7 // After which the TC bit is set.
8 //
9 // Comparing the length of the message with the message's UDPSize is a good indication if the truncation
10 // was sufficient, i.e. m.Len() < m.UDPSize.
11 func Truncate(m *dns.Msg) {
12 m.Truncated = true
13 m.Answer = m.Answer[:0]
14 m.Ns = m.Ns[:0]
15 m.Extra = m.Extra[:0]
16 }