diff --git a/dnsutils/dns_parser.go b/dnsutils/dns_parser.go index ea0fe85f..578042fc 100644 --- a/dnsutils/dns_parser.go +++ b/dnsutils/dns_parser.go @@ -263,6 +263,12 @@ func DecodePayload(dm *DNSMessage, header *DNSHeader, config *pkgconfig.Config) if header.Ad == 1 { dm.DNS.Flags.AD = true } + if header.Rd == 1 { + dm.DNS.Flags.RD = true + } + if header.Cd == 1 { + dm.DNS.Flags.CD = true + } var payloadOffset int // decode DNS question diff --git a/dnsutils/message.go b/dnsutils/message.go index b1bc0449..23b3c481 100644 --- a/dnsutils/message.go +++ b/dnsutils/message.go @@ -79,6 +79,8 @@ type DNSFlags struct { AA bool `json:"aa" msgpack:"aa"` RA bool `json:"ra" msgpack:"ra"` AD bool `json:"ad" msgpack:"ad"` + RD bool `json:"rd" msgpack:"rd"` + CD bool `json:"cd" msgpack:"cd"` } type DNSNetInfo struct { diff --git a/dnsutils/message_test.go b/dnsutils/message_test.go index 26fe45cb..a3acbb29 100644 --- a/dnsutils/message_test.go +++ b/dnsutils/message_test.go @@ -175,7 +175,9 @@ func TestDnsMessage_Json_Reference(t *testing.T) { "tc": false, "aa": false, "ra": false, - "ad": false + "ad": false, + "rd": false, + "cd": false }, "resource-records": { "an": [], @@ -230,6 +232,8 @@ func TestDnsMessage_JsonFlatten_Reference(t *testing.T) { "dns.flags.qr": false, "dns.flags.ra": false, "dns.flags.tc": false, + "dns.flags.rd": false, + "dns.flags.cd": false, "dns.length": 0, "dns.malformed-packet": false, "dns.id": 0, diff --git a/docs/dnsjson.md b/docs/dnsjson.md index 27b3507f..ead67908 100644 --- a/docs/dnsjson.md +++ b/docs/dnsjson.md @@ -27,12 +27,15 @@ Example: "rcode": "NOERROR", "qname": "eu.org", "qtype": "A", + "id": 23455, "flags": { "qr": true, "tc": false, "aa": false, "ra": true, - "ad": true + "ad": true, + "rd": true, + "cd": true }, "resource-records": { "an": [ @@ -89,8 +92,11 @@ Using flat-json requires more processing on the host running go-dnscollector but "dns.flags.qr": true, "dns.flags.ra": true, "dns.flags.tc": false, + "dns.flags.rd": false, + "dns.flags.cd": false, "dns.length": 82, "dns.malformed-packet": false, + "dns.id": 34555, "dns.opcode": 0, "dns.qname": "google.nl", "dns.qtype": "A",