-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
64 lines (58 loc) · 1.09 KB
/
types.go
File metadata and controls
64 lines (58 loc) · 1.09 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// dns types and constants
package main
// header flag masks
const (
qr_mask = 1 << 15
opcode_mask = 0x7800
aa_mask = 1 << 10
rcode_mask = 0x000f
)
// rr types
const (
type_a = 1
type_ns = 2
type_soa = 6
type_cname = 5
type_mx = 15
type_aaaa = 28
type_txt = 16
class_in = 1
)
// resource record struct
type rr struct {
Name string
Type_ uint16
Class uint16
TTL uint32
Rdata []byte // for a: 4 bytes, for others: whatever
// For SOA only (optional, for convenience)
SOA *soaRdata // nil unless Type_ == type_soa
// For MX only (optional, for convenience)
Preference uint16
Exchange string
}
// SOA RDATA struct (for convenience)
type soaRdata struct {
MName string // primary NS
RName string // responsible party (mailbox, with . for @)
Serial uint32
Refresh uint32
Retry uint32
Expire uint32
Minimum uint32
}
// dns header struct
type dns_header struct {
Id uint16
Flags uint16
Qdcount uint16
Ancount uint16
Nscount uint16
Arcount uint16
}
// dns question struct
type dns_question struct {
Name string
Type_ uint16
Class uint16
}