-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathptr.go
More file actions
38 lines (32 loc) · 898 Bytes
/
ptr.go
File metadata and controls
38 lines (32 loc) · 898 Bytes
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
package dns
import (
"bytes"
"errors"
)
// Ptr implements interface RData
type Ptr struct {
Name string
bytes string
}
// Parse implements Ptr parsing for interface RData
func (n *Ptr) Parse(buf *bytes.Buffer, ptr int, domains *Domains) error {
name, err := ParseName(buf, ptr, domains)
if err != nil {
return errors.New("unable to parse Ptr: " + err.Error())
}
n.Name = name
return nil
}
// Build implements Ptr building for interface RData
func (n *Ptr) Build(buf *bytes.Buffer, domains *Domains) error {
domains.SetBuild(buf.Len(), n.Name)
buf.WriteString(n.bytes)
return nil
}
// PreBuild implements Ptr pre building for interface RData
func (n *Ptr) PreBuild(_ *Record, domains *Domains) (int, error) {
n.bytes = BuildName(n.Name, domains)
return len(n.bytes), nil
}
// TransformName satisfies the interface
func (*Ptr) TransformName(name string) string { return name }