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