mirror of
https://github.com/coredns/coredns.git
synced 2025-11-15 00:12:16 -05:00
plugin/dnstap: some cleanup (#1172)
Some cleanup in proxy and dnstap: * just use time pkg directly and side step the indirection for Epoch * Use Set in SetQueryEpoch to be more Go like. (Looked like a reader) * Don't maintain two sets of time, we already track start, so use that. * Use time.Time and convert when needed * dedent the toDnstap function and put in a separate file
This commit is contained in:
@@ -4,6 +4,7 @@ package taprw
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/coredns/coredns/plugin/dnstap/msg"
|
||||
|
||||
@@ -41,9 +42,9 @@ func (w ResponseWriter) DnstapError() error {
|
||||
return w.err
|
||||
}
|
||||
|
||||
// QueryEpoch sets the query epoch as reported by dnstap.
|
||||
func (w *ResponseWriter) QueryEpoch() {
|
||||
w.queryEpoch = msg.Epoch()
|
||||
// SetQueryEpoch sets the query epoch as reported by dnstap.
|
||||
func (w *ResponseWriter) SetQueryEpoch() {
|
||||
w.queryEpoch = uint64(time.Now().Unix())
|
||||
}
|
||||
|
||||
// WriteMsg writes back the response to the client and THEN works on logging the request
|
||||
@@ -51,7 +52,7 @@ func (w *ResponseWriter) QueryEpoch() {
|
||||
// Dnstap errors are to be checked by DnstapError.
|
||||
func (w *ResponseWriter) WriteMsg(resp *dns.Msg) (writeErr error) {
|
||||
writeErr = w.ResponseWriter.WriteMsg(resp)
|
||||
writeEpoch := msg.Epoch()
|
||||
writeEpoch := uint64(time.Now().Unix())
|
||||
|
||||
b := w.TapBuilder()
|
||||
b.TimeSec = w.queryEpoch
|
||||
|
||||
Reference in New Issue
Block a user