Adds the dnstap I/O routines and should fix some issues (#1083)

* adds the dnstap I/O thread and should fix a lot of mistakes

* docs

* -race test

* oops

* docs
This commit is contained in:
varyoo
2017-09-26 17:45:33 +02:00
committed by John Belamaric
parent 2a32cd4159
commit daf8ef0da8
7 changed files with 164 additions and 22 deletions

View File

@@ -7,9 +7,10 @@ import (
"github.com/golang/protobuf/proto"
)
func wrap(m *lib.Message) *lib.Dnstap {
// Wrap a dnstap message in the top-level dnstap type.
func Wrap(m *lib.Message) lib.Dnstap {
t := lib.Dnstap_MESSAGE
return &lib.Dnstap{
return lib.Dnstap{
Type: &t,
Message: m,
}
@@ -17,7 +18,8 @@ func wrap(m *lib.Message) *lib.Dnstap {
// Marshal encodes the message to a binary dnstap payload.
func Marshal(m *lib.Message) (data []byte, err error) {
data, err = proto.Marshal(wrap(m))
payload := Wrap(m)
data, err = proto.Marshal(&payload)
if err != nil {
err = fmt.Errorf("proto: %s", err)
return