-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmsg.go
executable file
·50 lines (43 loc) · 1.62 KB
/
msg.go
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package yesdns
import (
"github.com/miekg/dns"
"fmt"
)
func dnsMsgToString(msg *dns.Msg) string {
return fmt.Sprintf("dns.Msg{opcode=%s recursion_desired=%s class=%s type=%s name=%s}",
msg.Opcode, msg.RecursionDesired, msg.Question[0].Qclass, msg.Question[0].Qtype, msg.Question[0].Name)
}
// Internal representation of messages for REST API and database.
type DnsHeader struct {
// Id uint16 `json:"id"`
// Response bool `json:"response"`
// Opcode int `json:"opcode"`
// RecursionDesired bool `json:"recursion_desired"`
Authoritative bool `json:"authoritative"`
Truncated bool `json:"truncated"`
RecursionAvailable bool `json:"recursion_available"`
Zero bool `json:"zero"`
AuthenticatedData bool `json:"authenticated_data"`
CheckingDisabled bool `json:"checking_disabled"`
Rcode int `json:"rcode"`
}
type DnsRR struct {
Name string `json:"name"`
Type uint16 `json:"type"`
Class uint16 `json:"class"`
Ttl uint32 `json:"ttl"`
Rdata interface{} `json:"rdata"`
}
type DnsQuestion struct {
Qname string `json:"qname"`
Qtype uint16 `json:"qtype"`
Qclass uint16 `json:"qclass"`
}
type DnsMessage struct {
Resolvers []string `json:"resolvers"`
MsgHdr DnsHeader `json:"header"`
Question []DnsQuestion `json:"question"`
Answer []DnsRR `json:"answer"`
Ns []DnsRR `json:"ns"`
Extra []DnsRR `json:"extra"`
}