Skip to content

Commit

Permalink
Add NULL record
Browse files Browse the repository at this point in the history
Sorely missing from this library. Add it.

Signed-off-by: Miek Gieben <miek@miek.nl>
  • Loading branch information
miekg committed Dec 1, 2018
1 parent 091d66a commit 0df5fca
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1 deletion.
5 changes: 4 additions & 1 deletion msg_generate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions msg_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,22 @@ func packStringHex(s string, msg []byte, off int) (int, error) {
return off, nil
}

func unpackStringAny(msg []byte, off, end int) (string, int, error) {
if end > len(msg) {
return "", len(msg), &Error{err: "overflow unpacking anything"}
}
return string(msg[off:end]), end, nil
}

func packStringAny(s string, msg []byte, off int) (int, error) {
if off+len(s) > len(msg) {
return len(msg), &Error{err: "overflow packing anything"}
}
copy(msg[off:off+len(s)], s)
off += len(s)
return off, nil
}

func unpackStringTxt(msg []byte, off int) ([]string, int, error) {
txt, off, err := unpackTxt(msg, off)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,14 @@ type ANY struct {

func (rr *ANY) String() string { return rr.Hdr.String() }

// NULL RR. See RFC 1035.
type NULL struct {
Hdr RR_Header
Anything string `dns:"any"`
}

func (rr *NULL) String() string { return rr.Hdr.String() + rr.Anything }

// CNAME RR. See RFC 1034.
type CNAME struct {
Hdr RR_Header
Expand Down
9 changes: 9 additions & 0 deletions zduplicate.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions zmsg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions ztypes.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0df5fca

Please sign in to comment.