plugin/dnstap: feature: added incoming connection support (#8086)

* plugin/dnstap: added incoming connection support feature to dnstap plugin

Signed-off-by: Endre Szabo <git@end.re>

* fixed problems pointed out by ci linter

Signed-off-by: Endre Szabo <git@end.re>

---------

Signed-off-by: Endre Szabo <git@end.re>
This commit is contained in:
Endre Szabo
2026-05-20 04:23:53 +02:00
committed by GitHub
parent f4f767fb4e
commit ee7ff82cf5
7 changed files with 728 additions and 70 deletions

View File

@@ -149,3 +149,30 @@ func TestTapMessage(t *testing.T) {
}
h.TapMessage(tapq.GetMessage())
}
// TestNilIoAndListener tests that the handler works correctly when io or listener is nil
func TestNilIoAndListener(t *testing.T) {
testMsg := testMessage()
msg.SetType(testMsg, tap.Message_CLIENT_QUERY)
// Test with nil io (listener-only mode)
h1 := Dnstap{
io: nil,
listener: nil,
}
// Should not panic
h1.TapMessage(testMsg)
// Test with only io set
w := &writer{t: t}
tapq := &tap.Dnstap{Message: testMsg}
w.queue = append(w.queue, tapq)
h2 := Dnstap{
io: w,
listener: nil,
}
h2.TapMessage(testMsg)
if len(w.queue) != 0 {
t.Errorf("Expected io to receive message")
}
}