Skip to content

Commit

Permalink
More naming and some docs
Browse files Browse the repository at this point in the history
  • Loading branch information
miekg committed Sep 21, 2014
1 parent b90da23 commit 9c9f364
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (rd *APAIR) Unpack(buf []byte) (int, error) {
return len(buf), nil
}

func (rd *APAIR) PasteRdata(dest dns.PrivateRdata) error {
func (rd *APAIR) CopyRdata(dest dns.PrivateRdata) error {
cp := make([]byte, rd.RdataLen())
_, err := rd.Pack(cp)
if err != nil {
Expand Down
14 changes: 12 additions & 2 deletions privaterr.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
PRIVATE RR
RFC 6895 sets aside a range of type codes for private use. This range
is 65,280 - 65,534 (0xFF00 - 0xFFFE). When experimenting with new Resource Records these
can be used, before requesting an official type code from IANA.
*/
package dns

import (
Expand All @@ -11,13 +19,15 @@ import (
type PrivateRdata interface {
// String returns the text presentaton of the Rdata of the Private RR.
String() string
// ParseTextSlice parses the Rdata of the private RR.
ParseTextSlice([]string) error
// Pack is used when packing a private RR into a buffer.
Pack([]byte) (int, error)
// Unpack is used when unpacking a private RR from a buffer.
// TODO(miek): diff. signature than Pack, see edns0.go for instance.
Unpack([]byte) (int, error)
PasteRdata(PrivateRdata) error
// CopyRdata copies the Rdata.
CopyRdata(PrivateRdata) error
// RdataLen returns the length in octets of the Rdata.
RdataLen() int
}
Expand Down Expand Up @@ -55,7 +65,7 @@ func (r *PrivateRR) copy() RR {
newh := r.Hdr.copyHeader()
rr.Hdr = *newh

err := r.Data.PasteRdata(rr.Data)
err := r.Data.CopyRdata(rr.Data)
if err != nil {
panic("dns: got value that could not be used to copy Private rdata")
}
Expand Down
4 changes: 2 additions & 2 deletions privaterr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (rd *ISBN) Unpack(buf []byte) (int, error) {
return len(buf), nil
}

func (rd *ISBN) PasteRdata(dest dns.PrivateRdata) error {
func (rd *ISBN) CopyRdata(dest dns.PrivateRdata) error {
isbn, ok := dest.(*ISBN)
if !ok {
return dns.ErrRdata
Expand Down Expand Up @@ -127,7 +127,7 @@ func (rd *VERSION) Unpack(buf []byte) (int, error) {
return len(buf), nil
}

func (rd *VERSION) PasteRdata(dest dns.PrivateRdata) error {
func (rd *VERSION) CopyRdata(dest dns.PrivateRdata) error {
isbn, ok := dest.(*VERSION)
if !ok {
return dns.ErrRdata
Expand Down

0 comments on commit 9c9f364

Please sign in to comment.