summaryrefslogtreecommitdiffstats
path: root/tests/dnstap/src/dnstap-test/main.go
diff options
context:
space:
mode:
authorVicky Shrestha <vicky@geeks.net.np>2017-01-17 09:08:17 +0100
committerOndřej Surý <ondrej@sury.org>2017-03-06 12:48:45 +0100
commitb682370ea8679e1cc432c9e0329c795b000a3bd3 (patch)
treeec60f8e11957cc23f16cebd1cb66979a0c9e5b83 /tests/dnstap/src/dnstap-test/main.go
parentadding dnstap to documentation (diff)
downloadknot-resolver-b682370ea8679e1cc432c9e0329c795b000a3bd3.tar.xz
knot-resolver-b682370ea8679e1cc432c9e0329c795b000a3bd3.zip
minor changes from https://github.com/CZ-NIC/knot-resolver/pull/39
Diffstat (limited to 'tests/dnstap/src/dnstap-test/main.go')
-rw-r--r--tests/dnstap/src/dnstap-test/main.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/tests/dnstap/src/dnstap-test/main.go b/tests/dnstap/src/dnstap-test/main.go
index e7f62e10..6ef3e1eb 100644
--- a/tests/dnstap/src/dnstap-test/main.go
+++ b/tests/dnstap/src/dnstap-test/main.go
@@ -33,21 +33,26 @@ func qnameFromFrame(b []byte) (string, error) {
dt := &dnstap.Dnstap{}
var name string
if err := proto.Unmarshal(b, dt); err != nil {
- log.Fatalf("dnstap proto.Unmarshal() failed: %s\n", err)
return name, err
}
m := dt.Message
if *m.Type != dnstap.Message_RESOLVER_RESPONSE {
- return name, fmt.Errorf("Incorrect message type")
+ return name, fmt.Errorf("incorrect message type")
}
- if m.QueryZone != nil {
- sb, _, err := dns.UnpackDomainName(m.QueryZone, 0)
- if err != nil {
- return name, err
- }
- name = fmt.Sprintf("%s", sb)
+ if m.ResponseMessage == nil {
+ return name, fmt.Errorf("no message payload")
+ }
+ if err := dns.IsMsg(m.ResponseMessage); err != nil {
+ return name, err
+ }
+ var msg dns.Msg
+ if err := msg.Unpack(m.ResponseMessage); err != nil {
+ return name, err
+ }
+ if len(msg.Question) < 1 {
+ return name, fmt.Errorf("question empty")
}
- return name, nil
+ return msg.Question[0].Name, nil
}
func listenOn() (net.Addr, *os.File, error) {