zmsg: return empty rr with header (#380)

When there is no rdata, return the newly created RR with the header
embedded in it. If we only return the header, we changed the
API for Go DNS.
This commit is contained in:
Miek Gieben 2016-06-14 17:21:01 +01:00 committed by GitHub
parent e6b37d00af
commit 5d001d0209
2 changed files with 204 additions and 271 deletions

View File

@ -176,16 +176,16 @@ return off, err
st, _ := getTypeStruct(o.Type(), scope)
fmt.Fprintf(b, "func unpack%s(h RR_Header, msg []byte, off int) (RR, int, error) {\n", name)
fmt.Fprintf(b, "rr := new(%s)\n", name)
fmt.Fprint(b, "rr.Hdr = h\n")
fmt.Fprint(b, `if noRdata(h) {
return &h, off, nil
return rr, off, nil
}
var err error
rdStart := off
_ = rdStart
`)
fmt.Fprintf(b, "rr := new(%s)\n", name)
fmt.Fprintln(b, "rr.Hdr = h\n")
for i := 1; i < st.NumFields(); i++ {
o := func(s string) {
fmt.Fprintf(b, s, st.Field(i).Name())

469
zmsg.go

File diff suppressed because it is too large Load Diff