Skip to content

Commit 0458b3a

Browse files
committed
add DNS Name
1 parent 1654142 commit 0458b3a

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

cmd/config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,15 @@ columns:
552552
default: false
553553
width: 5
554554
feature: dnsTracking
555+
- id: DNSName
556+
group: DNS
557+
name: DNS Name
558+
tooltip: DNS name.
559+
field: DnsName
560+
filter: dns_name
561+
default: false
562+
width: 15
563+
feature: dnsTracking
555564
- id: DNSLatency
556565
group: DNS
557566
name: DNS Latency

cmd/flow_db.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func createFlowsDBTable(db *sql.DB) error {
5959
"PktDropBytes" INTEGER,
6060
"PktDropPackets" INTEGER,
6161
"DnsId" INTEGER,
62+
"DnsName" TEXT,
6263
"DnsFlagsResponseCode" TEXT,
6364
"DnsLatencyMs" TIMESTAMP,
6465
"TimeFlowRTTNs" TIMESTAMP
@@ -99,13 +100,13 @@ func insertFlowToDB(db *sql.DB, buf []byte) error {
99100
switch {
100101
case flow["PktDropPackets"] != 0 && flow["DnsId"] != 0:
101102
flowSQL =
102-
`INSERT INTO flow(DnsErrno, Dscp, DstAddr, DstPort, Interface, Proto, SrcAddr, SrcPort, Bytes, Packets, PktDropLatestDropCause, PktDropBytes, PktDropPackets, DnsId, DnsFlagsResponseCode, DnsLatencyMs, TimeFlowRttNs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
103+
`INSERT INTO flow(DnsErrno, Dscp, DstAddr, DstPort, Interface, Proto, SrcAddr, SrcPort, Bytes, Packets, PktDropLatestDropCause, PktDropBytes, PktDropPackets, DnsId, DnsName, DnsFlagsResponseCode, DnsLatencyMs, TimeFlowRttNs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
103104
case flow["PktDropPackets"] != 0:
104105
flowSQL =
105106
`INSERT INTO flow(DnsErrno, Dscp, DstAddr, DstPort, Interface, Proto, SrcAddr, SrcPort, Bytes, Packets, PktDropLatestDropCause, PktDropBytes, PktDropPackets, TimeFlowRttNs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
106107
case flow["DnsId"] != 0:
107108
flowSQL =
108-
`INSERT INTO flow(DnsErrno, Dscp, DstAddr, DstPort, Interface, Proto, SrcAddr, SrcPort, Bytes, Packets, DnsId, DnsFlagsResponseCode, DnsLatencyMs, TimeFlowRttNs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
109+
`INSERT INTO flow(DnsErrno, Dscp, DstAddr, DstPort, Interface, Proto, SrcAddr, SrcPort, Bytes, Packets, DnsId, DnsName, DnsFlagsResponseCode, DnsLatencyMs, TimeFlowRttNs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
109110
default:
110111
flowSQL =
111112
`INSERT INTO flow(DnsErrno, Dscp, DstAddr, DstPort, Interface, Proto, SrcAddr, SrcPort, Bytes, Packets, TimeFlowRttNs) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
@@ -123,7 +124,7 @@ func insertFlowToDB(db *sql.DB, buf []byte) error {
123124
flow["DNSErrno"], flow["Dscp"], flow["DstAddr"], flow["DstPort"], flow["Interface"],
124125
flow["Proto"], flow["SrcAddr"], flow["SrcPort"], flow["Bytes"], flow["Packets"],
125126
flow["PktDropLatestDropCause"], flow["PktDropBytes"], flow["PktDropPackets"],
126-
flow["DnsId"], flow["DnsFlagsResponseCode"], flow["DnsLatencyMs"],
127+
flow["DnsId"], flow["DnsName"], flow["DnsFlagsResponseCode"], flow["DnsLatencyMs"],
127128
flow["TimeFlowRttNs"])
128129
case flow["PktDropLatestDropCause"] != 0:
129130
_, err = statement.Exec(
@@ -135,7 +136,7 @@ func insertFlowToDB(db *sql.DB, buf []byte) error {
135136
_, err = statement.Exec(
136137
flow["DNSErrno"], flow["Dscp"], flow["DstAddr"], flow["DstPort"], flow["Interface"],
137138
flow["Proto"], flow["SrcAddr"], flow["SrcPort"], flow["Bytes"], flow["Packets"],
138-
flow["DnsId"], flow["DnsFlagsResponseCode"], flow["DnsLatencyMs"],
139+
flow["DnsId"], flow["DnsName"], flow["DnsFlagsResponseCode"], flow["DnsLatencyMs"],
139140
flow["TimeFlowRttNs"])
140141
default:
141142
_, err = statement.Exec(

cmd/flow_display_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ func TestFlowDisplayAdvancedDisplay(t *testing.T) {
114114
// set display without enrichment
115115
rows := getRows(allOptions, []string{pktDropFeature, dnsFeature, rttFeature, networkEventsDisplay}, noOptions, []string{})
116116
assert.Equal(t, 2, len(rows))
117-
assert.Equal(t, "End Time Src IP Src Port Dst IP Dst Port Interfaces Interface Dirs Drop BytesDrop… Drop State Drop Cause Drop Flags DNS Id DNS… DNS RCode DNS Error Flow RTT Network Events ", rows[0])
118-
assert.Equal(t, "17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 f18b970c2ce8fddEgress 32B 1 TCP_INVALID… SKB_DROP… 16 31319 1ms NoError 0 10µs Allowed by default… ", rows[1])
117+
assert.Equal(t, "End Time Src IP Src Port Dst IP Dst Port Interfaces Interface Dirs Drop BytesDrop… Drop State Drop Cause Drop Flags DNS Id DNS Name DNS… DNS RCode DNS Error Flow RTT Network Events ", rows[0])
118+
assert.Equal(t, "17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 f18b970c2ce8fddEgress 32B 1 TCP_INVALID… SKB_DROP… 16 31319 example.com 1ms NoError 0 10µs Allowed by default… ", rows[1])
119119

120120
// set display to standard
121121
rows = getRows(standardDisplay, []string{}, noOptions, []string{})
@@ -135,8 +135,8 @@ func TestFlowDisplayAdvancedDisplay(t *testing.T) {
135135
rows = getRows("DNS", []string{dnsFeature}, noOptions, []string{})
136136

137137
assert.Equal(t, 2, len(rows))
138-
assert.Equal(t, "End Time Src IP Src Port Dst IP Dst Port Interfaces Interface Dirs DNS Id DNS… DNS RCode DNS Error ", rows[0])
139-
assert.Equal(t, "17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 f18b970c2ce8fddEgress 31319 1ms NoError 0 ", rows[1])
138+
assert.Equal(t, "End Time Src IP Src Port Dst IP Dst Port Interfaces Interface Dirs DNS Id DNS Name DNS… DNS RCode DNS Error ", rows[0])
139+
assert.Equal(t, "17:25:28.703000 10.128.0.29 1234 10.129.0.26 5678 f18b970c2ce8fddEgress 31319 example.com 1ms NoError 0 ", rows[1])
140140

141141
// set display to RTT
142142
rows = getRows("RTT", []string{rttFeature}, noOptions, []string{})

cmd/root_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const (
1717
"DnsFlags":34176,
1818
"DnsFlagsResponseCode":"NoError",
1919
"DnsId":31319,
20+
"DnsName":"example.com",
2021
"DnsLatencyMs":1,
2122
"Dscp":0,
2223
"DstAddr":"10.129.0.26",

0 commit comments

Comments
 (0)