aboutsummaryrefslogtreecommitdiff
path: root/middleware/dnstap/msg/wrapper.go
blob: 0cb6a76c064dc7200cc6f3be3070e35aed2c52dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package msg

import (
	"fmt"

	lib "github.com/dnstap/golang-dnstap"
	"github.com/golang/protobuf/proto"
)

func wrap(m *lib.Message) *lib.Dnstap {
	t := lib.Dnstap_MESSAGE
	return &lib.Dnstap{
		Type:    &t,
		Message: m,
	}
}

func Marshal(m *lib.Message) (data []byte, err error) {
	data, err = proto.Marshal(wrap(m))
	if err != nil {
		err = fmt.Errorf("proto: %s", err)
		return
	}
	return
}