Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dnstap collector: add version #230

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Additionally, DNS-collector also contains DNS parser with [`EDNS`](doc/dnsparser

**Collectors**:
- *Listen for logging traffic with streaming network protocols*
- [`DNStap`](doc/collectors.md#dns-tap) with `tls`, `tcp` or `unix` support and [`proxifier`](doc/collectors.md#dns-tap-proxifier)
- [`PowerDNS`](doc/collectors.md#protobuf-powerdns) streams with full [`support`](doc/powerdns.md)
- [`TZSP`](doc/collectors.md#tzsp)(TaZmen Sniffer Protocol) support
- [`DNStap`](doc/collectors.md#dns-tap) with `tls`|`tcp`|`unix` transports support and [`proxifier`](doc/collectors.md#dns-tap-proxifier)
- [`PowerDNS`](doc/collectors.md#protobuf-powerdns) streams with [`full`](doc/powerdns.md) support
- [`TZSP`](doc/collectors.md#tzsp) protocol support
- *Live capture on a network interface*
- [`AF_PACKET`](doc/collectors.md#live-capture-with-af_packet) socket with BPF filter
- [`eBPF XDP`](doc/collectors.md#live-capture-with-ebpf-xdp) ingress traffic
Expand Down
4 changes: 4 additions & 0 deletions collectors/dnstap_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ func (d *DnstapProcessor) Run(sendTo []chan dnsutils.DnsMessage) {
if len(identity) > 0 {
dm.DnsTap.Identity = string(identity)
}
version := dt.GetVersion()
if len(identity) > 0 {
dm.DnsTap.Version = string(version)
}

dm.DnsTap.Operation = dt.GetMessage().GetType().String()
dm.NetworkInfo.Family = dt.GetMessage().GetSocketFamily().String()
Expand Down
4 changes: 4 additions & 0 deletions dnsutils/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ type DnsExtended struct {
type DnsTap struct {
Operation string `json:"operation" msgpack:"operation"`
Identity string `json:"identity" msgpack:"identity"`
Version string `json:"version" msgpack:"version"`
TimestampRFC3339 string `json:"timestamp-rfc3339ns" msgpack:"timestamp-rfc3339ns"`
Timestamp float64 `json:"-" msgpack:"-"`
TimeSec int `json:"-" msgpack:"-"`
Expand Down Expand Up @@ -180,6 +181,7 @@ func (dm *DnsMessage) Init() {
dm.DnsTap = DnsTap{
Operation: "-",
Identity: "-",
Version: "-",
TimestampRFC3339: "-",
LatencySec: "-",
}
Expand Down Expand Up @@ -362,6 +364,8 @@ func (dm *DnsMessage) Bytes(format []string, delimiter string) []byte {
s.WriteString(ts.Format("2006-01-02 15:04:05.999999999"))
case directive == "identity":
s.WriteString(dm.DnsTap.Identity)
case directive == "version":
s.WriteString(dm.DnsTap.Version)
case directive == "operation":
s.WriteString(dm.DnsTap.Operation)
case directive == "rcode":
Expand Down
1 change: 1 addition & 0 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Default directives:
- `timestamp-unixns`: unix timestamp with nano support
- `localtime`: local time
- `identity`: dnstap identity
- `version`: dnstap version
- `operation`: dnstap operation
- `opcode`: dns opcode (integer)
- `rcode`: dns return code
Expand Down
1 change: 1 addition & 0 deletions doc/dnsjson.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Example:
"dnstap": {
"operation": "CLIENT_RESPONSE",
"identity": "dnsdist1",
"version": "-",
"timestamp-rfc3339ns": "2021-12-27T14:33:44.559002118Z",
"latency": "0.014617"
}
Expand Down