1 files changed,
15 insertions(+),
4 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-03-26 17:16:09 +0200
Change ID:
urnlmqkutoutkzrutkvsspvrnsrzrrqm
Parent:
bc17d48
M
dns-server/record.go
··· 8 8 "strings" 9 9 ) 10 10 11 +type QueryType uint16 12 + 13 +const ( 14 + AType QueryType = 1 15 + NSType QueryType = 2 16 + CNAMEType QueryType = 5 17 + MXType QueryType = 15 18 + AAAAType QueryType = 28 19 +) 20 + 11 21 type Record struct { 12 22 Name string 13 - Type uint16 23 + Type QueryType 14 24 Class uint16 15 25 TTL uint32 16 26 Data string ··· 22 32 return Record{}, err 23 33 } 24 34 25 - var rtype, class, rdlen uint16 35 + var rtype QueryType 36 + var class, rdlen uint16 26 37 var ttl uint32 27 38 _ = binary.Read(r, binary.BigEndian, &rtype) 28 39 _ = binary.Read(r, binary.BigEndian, &class) ··· 31 42 32 43 var data string 33 44 switch rtype { 34 - case 1: // A 45 + case AType: 35 46 var ip [4]byte 36 47 _, _ = r.Read(ip[:]) 37 48 data = fmt.Sprintf("%d.%d.%d.%d", ··· 55 66 func (r Record) Write(b *bytes.Buffer) (int, error) { 56 67 start := b.Len() 57 68 switch r.Type { 58 - case 1: // A 69 + case AType: 59 70 _ = writeName(b, r.Name) 60 71 _ = binary.Write(b, binary.BigEndian, r.Type) 61 72 _ = binary.Write(b, binary.BigEndian, r.Class)