Merge commit '951af98'

This commit is contained in:
Miek Gieben 2013-01-22 16:42:17 +01:00
commit b1f71604b9
2 changed files with 14 additions and 1 deletions

View File

@ -72,6 +72,15 @@ func handleReflect(w dns.ResponseWriter, r *dns.Msg) {
v4 = a.To4() != nil
}
if o := r.IsEdns0(); o != nil {
for _, s := range o.Options {
switch e = s.(type) {
case *dns.EDNS0_SUBNET:
println("SUBNET")
}
}
}
if v4 {
rr = new(dns.A)
rr.(*dns.A).Hdr = dns.RR_Header{Name: dom, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 0}

6
msg.go
View File

@ -712,6 +712,7 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, err er
fv.Set(reflect.ValueOf(txt))
case `dns:"opt"`: // edns0
rdlength := int(val.FieldByName("Hdr").FieldByName("Rdlength").Uint())
endrr := off + rdlength
if rdlength == 0 {
// This is an EDNS0 (OPT Record) with no rdata
// We can safely return here.
@ -744,8 +745,11 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, err er
e.unpack(msg[off1 : off1+int(optlen)])
edns = append(edns, e)
off = off1 + int(optlen)
default:
// do nothing?
off = off1 + int(optlen)
}
if off < rdlength {
if off < endrr {
goto Option
}
fv.Set(reflect.ValueOf(edns))