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:
parent
25367a4329
commit
c2d93f7182
6 changed files with 64 additions and 61 deletions
|
@ -5,7 +5,6 @@ import (
|
|||
"errors"
|
||||
"net"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
tap "github.com/dnstap/golang-dnstap"
|
||||
"github.com/miekg/dns"
|
||||
|
@ -103,16 +102,6 @@ func (d *Data) Pack(m *dns.Msg) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Epoch returns the epoch time in seconds.
|
||||
func Epoch() uint64 {
|
||||
return uint64(time.Now().Unix())
|
||||
}
|
||||
|
||||
// Epoch sets the dnstap message epoch.
|
||||
func (d *Data) Epoch() {
|
||||
d.TimeSec = Epoch()
|
||||
}
|
||||
|
||||
// ToClientResponse transforms Data into a client response message.
|
||||
func (d *Data) ToClientResponse() *tap.Message {
|
||||
t := tap.Message_CLIENT_RESPONSE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue