diff --git a/dnsutils/dnsmessage_text.go b/dnsutils/dnsmessage_text.go index d99786cd..ea52490e 100644 --- a/dnsutils/dnsmessage_text.go +++ b/dnsutils/dnsmessage_text.go @@ -463,7 +463,7 @@ func (dm *DNSMessage) ToTextLine(format []string, fieldDelimiter string, fieldBo s.WriteByte('-') } case directive == "rd": - if flags.AD { + if flags.RD { s.WriteString("RD") } else { s.WriteByte('-') diff --git a/dnsutils/dnsmessage_text_test.go b/dnsutils/dnsmessage_text_test.go index b6891bec..dec529a3 100644 --- a/dnsutils/dnsmessage_text_test.go +++ b/dnsutils/dnsmessage_text_test.go @@ -188,9 +188,14 @@ func TestDnsMessage_TextFormat_DefaultDirectives(t *testing.T) { expected: "PKTERR", }, { - format: "tc aa ra ad rd", - dm: DNSMessage{DNS: DNS{Flags: DNSFlags{TC: true, AA: true, RA: true, AD: true, RD: true}}}, - expected: "TC AA RA AD RD", + format: "tc aa ra ad", + dm: DNSMessage{DNS: DNS{Flags: DNSFlags{TC: true, AA: true, RA: true, AD: true}}}, + expected: "TC AA RA AD", + }, + { + format: "rd", + dm: DNSMessage{DNS: DNS{Flags: DNSFlags{RD: true}}}, + expected: "RD", }, { format: "tc aa ra ad rd",