aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Uladzimir Trehubenka <utrehubenka@infoblox.com> 2018-03-02 15:50:31 +0300
committerGravatar Miek Gieben <miek@miek.nl> 2018-03-02 04:50:31 -0800
commit5546dbf3c6dc7a5b437f0b41534052395e20f329 (patch)
tree229b648d8ded44eba3e35344aed9592173a68fdf /plugin
parenta131c22d24d7d035d5da4d0067439dae367a5c5b (diff)
downloadcoredns-5546dbf3c6dc7a5b437f0b41534052395e20f329.tar.gz
coredns-5546dbf3c6dc7a5b437f0b41534052395e20f329.tar.zst
coredns-5546dbf3c6dc7a5b437f0b41534052395e20f329.zip
Added nanoseconds to dnstap plugin builder (#1583)
Diffstat (limited to 'plugin')
-rw-r--r--plugin/dnstap/msg/msg.go34
1 files changed, 20 insertions, 14 deletions
diff --git a/plugin/dnstap/msg/msg.go b/plugin/dnstap/msg/msg.go
index 44c88d3e5..d96fc6c9a 100644
--- a/plugin/dnstap/msg/msg.go
+++ b/plugin/dnstap/msg/msg.go
@@ -18,6 +18,7 @@ type Builder struct {
Address net.IP
Port uint32
TimeSec uint64
+ TimeNsec uint32
err error
}
@@ -95,6 +96,7 @@ func (b *Builder) HostPort(addr string) *Builder {
// Time adds the timestamp to the message.
func (b *Builder) Time(ts time.Time) *Builder {
b.TimeSec = uint64(ts.Unix())
+ b.TimeNsec = uint32(ts.Nanosecond())
return b
}
@@ -102,13 +104,14 @@ func (b *Builder) Time(ts time.Time) *Builder {
func (b *Builder) ToClientResponse() (*tap.Message, error) {
t := tap.Message_CLIENT_RESPONSE
return &tap.Message{
- Type: &t,
- SocketFamily: &b.SocketFam,
- SocketProtocol: &b.SocketProto,
- ResponseTimeSec: &b.TimeSec,
- ResponseMessage: b.Packed,
- QueryAddress: b.Address,
- QueryPort: &b.Port,
+ Type: &t,
+ SocketFamily: &b.SocketFam,
+ SocketProtocol: &b.SocketProto,
+ ResponseTimeSec: &b.TimeSec,
+ ResponseTimeNsec: &b.TimeNsec,
+ ResponseMessage: b.Packed,
+ QueryAddress: b.Address,
+ QueryPort: &b.Port,
}, b.err
}
@@ -120,6 +123,7 @@ func (b *Builder) ToClientQuery() (*tap.Message, error) {
SocketFamily: &b.SocketFam,
SocketProtocol: &b.SocketProto,
QueryTimeSec: &b.TimeSec,
+ QueryTimeNsec: &b.TimeNsec,
QueryMessage: b.Packed,
QueryAddress: b.Address,
QueryPort: &b.Port,
@@ -133,6 +137,7 @@ func (b *Builder) ToOutsideQuery(t tap.Message_Type) (*tap.Message, error) {
SocketFamily: &b.SocketFam,
SocketProtocol: &b.SocketProto,
QueryTimeSec: &b.TimeSec,
+ QueryTimeNsec: &b.TimeNsec,
QueryMessage: b.Packed,
ResponseAddress: b.Address,
ResponsePort: &b.Port,
@@ -142,12 +147,13 @@ func (b *Builder) ToOutsideQuery(t tap.Message_Type) (*tap.Message, error) {
// ToOutsideResponse transforms the data into a forwarder or resolver response message.
func (b *Builder) ToOutsideResponse(t tap.Message_Type) (*tap.Message, error) {
return &tap.Message{
- Type: &t,
- SocketFamily: &b.SocketFam,
- SocketProtocol: &b.SocketProto,
- ResponseTimeSec: &b.TimeSec,
- ResponseMessage: b.Packed,
- ResponseAddress: b.Address,
- ResponsePort: &b.Port,
+ Type: &t,
+ SocketFamily: &b.SocketFam,
+ SocketProtocol: &b.SocketProto,
+ ResponseTimeSec: &b.TimeSec,
+ ResponseTimeNsec: &b.TimeNsec,
+ ResponseMessage: b.Packed,
+ ResponseAddress: b.Address,
+ ResponsePort: &b.Port,
}, b.err
}