blob: 569c0cd4a101a832fcccce624649aa0daed2c256 (
plain)
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
|
package dns
import (
"fmt"
"net/netip"
)
type AAAA struct {
Addr netip.Addr
}
func (a *AAAA) Type() uint16 {
return TypeAAAA
}
func (a *AAAA) Pack(p *packer) error {
b := a.Addr.As16()
p.buf = append(p.buf, b[:]...)
return nil
}
func (a *AAAA) Unpack(u *unpacker, length uint16) error {
if length != 16 {
return fmt.Errorf("dns: AAAA rdata length %d != 16", length)
}
if u.off+16 > len(u.buf) {
return fmt.Errorf("dns: short AAAA rdata")
}
a.Addr = netip.AddrFrom16([16]byte(u.buf[u.off : u.off+16]))
u.off += 16
return nil
}
func (a *AAAA) String() string { return a.Addr.String() }
|