mirror of
https://github.com/miekg/dns.git
synced 2025-10-18 21:31:01 +02:00
impl. the recent changes from the reflect package
This commit is contained in:
parent
d6716f693d
commit
2a596f60b9
11
msg.go
11
msg.go
@ -588,12 +588,6 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
|
|||||||
}
|
}
|
||||||
case reflect.Struct:
|
case reflect.Struct:
|
||||||
off, ok = unpackStructValue(fv, msg, off)
|
off, ok = unpackStructValue(fv, msg, off)
|
||||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
|
||||||
switch fv.Type().Kind() {
|
|
||||||
default:
|
|
||||||
//fmt.Fprintf(os.Stderr, "dns: unknown packing type %v\n", f.Type)
|
|
||||||
return len(msg), false
|
|
||||||
|
|
||||||
case reflect.Uint8:
|
case reflect.Uint8:
|
||||||
if off+1 > len(msg) {
|
if off+1 > len(msg) {
|
||||||
//fmt.Fprintf(os.Stderr, "dns: overflow unpacking uint8")
|
//fmt.Fprintf(os.Stderr, "dns: overflow unpacking uint8")
|
||||||
@ -629,7 +623,6 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
|
|||||||
uint64(msg[off+4])<<8 | uint64(msg[off+5])
|
uint64(msg[off+4])<<8 | uint64(msg[off+5])
|
||||||
fv.SetUint(uint64(i))
|
fv.SetUint(uint64(i))
|
||||||
off += 6
|
off += 6
|
||||||
}
|
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
var s string
|
var s string
|
||||||
switch f.Tag {
|
switch f.Tag {
|
||||||
@ -834,7 +827,7 @@ func packRR(rr RR, msg []byte, off int) (off2 int, ok bool) {
|
|||||||
return len(msg), false
|
return len(msg), false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO make this quicker?
|
// TODO make this quicker
|
||||||
// pack a third time; redo header with correct data length
|
// pack a third time; redo header with correct data length
|
||||||
rr.Header().Rdlength = uint16(off2 - off1)
|
rr.Header().Rdlength = uint16(off2 - off1)
|
||||||
packStruct(rr.Header(), msg, off)
|
packStruct(rr.Header(), msg, off)
|
||||||
@ -852,7 +845,7 @@ func unpackRR(msg []byte, off int) (rr RR, off1 int, ok bool) {
|
|||||||
end := off + int(h.Rdlength)
|
end := off + int(h.Rdlength)
|
||||||
|
|
||||||
// make an rr of that type and re-unpack.
|
// make an rr of that type and re-unpack.
|
||||||
// again inefficient but doesn't need to be fast.
|
// again inefficient but doesn't need to be fast. TODO speed
|
||||||
mk, known := rr_mk[h.Rrtype]
|
mk, known := rr_mk[h.Rrtype]
|
||||||
if !known {
|
if !known {
|
||||||
rr = new(RR_RFC3597)
|
rr = new(RR_RFC3597)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user