Fix TXT packing and unpacking

This commit is contained in:
Miek Gieben 2012-02-13 16:12:26 +01:00
parent 2c44133163
commit c30821fece
3 changed files with 13 additions and 6 deletions

View File

@ -9,7 +9,7 @@ EXAMPLES=mx \
q \
ex:
for i in $(EXAMPLES); do go build dns/ex/$$i; done
for i in $(EXAMPLES); do echo $$i; go build dns/ex/$$i; done
clean:
rm -f $(EXAMPLES)

10
msg.go
View File

@ -651,15 +651,17 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
return lenmsg, false
}
txt = append(txt, string(msg[off+1:off+l]))
off += l
println("ADDING", string(msg[off+1:off+l]))
off += l+1
if off < rdlength {
// More
goto Txts
}
fv.Set(reflect.ValueOf(txt))
case "opt": // EDNS
println("SETING", len(txt))
case "opt": // edns0
if off+2 > lenmsg {
// This is an ENDNS0 (OPT Record) with no rdata
// This is an EDNS0 (OPT Record) with no rdata
// We can savely return here.
break
}
@ -703,7 +705,7 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
}
if off+2 > lenmsg {
println("dns: overflow unpacking NSEC 22")
println("dns: overflow unpacking NSEC")
return lenmsg, false
}
nsec := make([]uint16, 0)

View File

@ -380,6 +380,7 @@ func (rr *RR_TXT) Header() *RR_Header {
func (rr *RR_TXT) String() string {
s := rr.Hdr.String()
for i, s1 := range rr.Txt {
println("HALLO")
if i > 0 {
s += " " + "\"" + s1 + "\""
} else {
@ -390,7 +391,11 @@ func (rr *RR_TXT) String() string {
}
func (rr *RR_TXT) Len() int {
return rr.Hdr.Len() + len(rr.Txt)
l := rr.Hdr.Len()
for _, t := range rr.Txt {
l += len(t)
}
return l
}
type RR_SRV struct {