From ef286f8f39898f3b6c497b85334a086a0d4ece40 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Wed, 14 Oct 2020 08:42:57 +0200 Subject: [PATCH] Update doc for Truncate (#1173) Follow up after #1171, update the docs about TC and use the MinMsgSize constant for 512 in the code. Signed-off-by: Miek Gieben --- msg_truncate.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/msg_truncate.go b/msg_truncate.go index d3d1b1c7..156c5a0e 100644 --- a/msg_truncate.go +++ b/msg_truncate.go @@ -9,7 +9,8 @@ package dns // requested buffer size. // // The TC bit will be set if any records were excluded from the message. -// This indicates to that the client should retry over TCP. +// If the TC bit is already set on the message it will be retained. +// TC indicates that the client should retry over TCP. // // According to RFC 2181, the TC bit should only be set if not all of the // "required" RRs can be included in the response. Unfortunately, we have @@ -28,11 +29,11 @@ func (dns *Msg) Truncate(size int) { } // RFC 6891 mandates that the payload size in an OPT record - // less than 512 bytes must be treated as equal to 512 bytes. + // less than 512 (MinMsgSize) bytes must be treated as equal to 512 bytes. // // For ease of use, we impose that restriction here. - if size < 512 { - size = 512 + if size < MinMsgSize { + size = MinMsgSize } l := msgLenWithCompressionMap(dns, nil) // uncompressed length