diff options
Diffstat (limited to 'plugin/dnstap')
-rw-r--r-- | plugin/dnstap/handler.go | 2 | ||||
-rw-r--r-- | plugin/dnstap/handler_test.go | 3 | ||||
-rw-r--r-- | plugin/dnstap/io.go | 10 | ||||
-rw-r--r-- | plugin/dnstap/io_test.go | 8 |
4 files changed, 11 insertions, 12 deletions
diff --git a/plugin/dnstap/handler.go b/plugin/dnstap/handler.go index 1ae0e3c62..04d29860e 100644 --- a/plugin/dnstap/handler.go +++ b/plugin/dnstap/handler.go @@ -23,7 +23,7 @@ type Dnstap struct { // TapMessage sends the message m to the dnstap interface. func (h Dnstap) TapMessage(m *tap.Message) { t := tap.Dnstap_MESSAGE - h.io.Dnstap(tap.Dnstap{Type: &t, Message: m}) + h.io.Dnstap(&tap.Dnstap{Type: &t, Message: m}) } func (h Dnstap) tapQuery(w dns.ResponseWriter, query *dns.Msg, queryTime time.Time) { diff --git a/plugin/dnstap/handler_test.go b/plugin/dnstap/handler_test.go index 74f72521d..2c54f70e6 100644 --- a/plugin/dnstap/handler_test.go +++ b/plugin/dnstap/handler_test.go @@ -18,7 +18,6 @@ func testCase(t *testing.T, tapq, tapr *tap.Message, q, r *dns.Msg) { h := Dnstap{ Next: test.HandlerFunc(func(_ context.Context, w dns.ResponseWriter, _ *dns.Msg) (int, error) { - return 0, w.WriteMsg(r) }), io: &w, @@ -34,7 +33,7 @@ type writer struct { queue []*tap.Message } -func (w *writer) Dnstap(e tap.Dnstap) { +func (w *writer) Dnstap(e *tap.Dnstap) { if len(w.queue) == 0 { w.t.Error("Message not expected") } diff --git a/plugin/dnstap/io.go b/plugin/dnstap/io.go index 857d860af..d15d5669b 100644 --- a/plugin/dnstap/io.go +++ b/plugin/dnstap/io.go @@ -18,7 +18,7 @@ const ( // tapper interface is used in testing to mock the Dnstap method. type tapper interface { - Dnstap(tap.Dnstap) + Dnstap(*tap.Dnstap) } // dio implements the Tapper interface. @@ -26,7 +26,7 @@ type dio struct { endpoint string proto string enc *encoder - queue chan tap.Dnstap + queue chan *tap.Dnstap dropped uint32 quit chan struct{} flushTimeout time.Duration @@ -38,7 +38,7 @@ func newIO(proto, endpoint string) *dio { return &dio{ endpoint: endpoint, proto: proto, - queue: make(chan tap.Dnstap, queueSize), + queue: make(chan *tap.Dnstap, queueSize), quit: make(chan struct{}), flushTimeout: flushTimeout, tcpTimeout: tcpTimeout, @@ -67,7 +67,7 @@ func (d *dio) connect() error { } // Dnstap enqueues the payload for log. -func (d *dio) Dnstap(payload tap.Dnstap) { +func (d *dio) Dnstap(payload *tap.Dnstap) { select { case d.queue <- payload: default: @@ -104,7 +104,7 @@ func (d *dio) serve() { d.enc.close() return case payload := <-d.queue: - if err := d.write(&payload); err != nil { + if err := d.write(payload); err != nil { d.dial() } case <-timeout.C: diff --git a/plugin/dnstap/io_test.go b/plugin/dnstap/io_test.go index 30f0c75fb..3e94f0556 100644 --- a/plugin/dnstap/io_test.go +++ b/plugin/dnstap/io_test.go @@ -65,7 +65,7 @@ func TestTransport(t *testing.T) { dio.flushTimeout = 30 * time.Millisecond dio.connect() - dio.Dnstap(tmsg) + dio.Dnstap(&tmsg) wg.Wait() l.Close() @@ -99,7 +99,7 @@ func TestRace(t *testing.T) { for i := 0; i < count; i++ { go func() { tmsg := tap.Dnstap_MESSAGE - dio.Dnstap(tap.Dnstap{Type: &tmsg}) + dio.Dnstap(&tap.Dnstap{Type: &tmsg}) wg.Done() }() } @@ -128,7 +128,7 @@ func TestReconnect(t *testing.T) { dio.connect() defer dio.close() - dio.Dnstap(tmsg) + dio.Dnstap(&tmsg) wg.Wait() @@ -149,7 +149,7 @@ func TestReconnect(t *testing.T) { for i := 0; i < count; i++ { time.Sleep(100 * time.Millisecond) - dio.Dnstap(tmsg) + dio.Dnstap(&tmsg) } wg.Wait() } |