mirror of
https://github.com/miekg/dns.git
synced 2025-10-13 02:41:01 +02:00
documentation
This commit is contained in:
parent
7b1f981acb
commit
4f588a5d15
36
msg.go
36
msg.go
@ -55,7 +55,7 @@ var (
|
|||||||
ErrDenialCe error = &Error{Err: "no matching closest encloser found"}
|
ErrDenialCe error = &Error{Err: "no matching closest encloser found"}
|
||||||
ErrDenialNc error = &Error{Err: "no covering NSEC3 found for next closer"}
|
ErrDenialNc error = &Error{Err: "no covering NSEC3 found for next closer"}
|
||||||
ErrDenialSo error = &Error{Err: "no covering NSEC3 found for source of synthesis"}
|
ErrDenialSo error = &Error{Err: "no covering NSEC3 found for source of synthesis"}
|
||||||
ErrDenialBit error = &Error{Err: "type not denied in NSEC3 bitmap"}
|
ErrDenialBit error = &Error{Err: "type not denied in NSEC3 bitmap"}
|
||||||
)
|
)
|
||||||
|
|
||||||
// A manually-unpacked version of (id, bits).
|
// A manually-unpacked version of (id, bits).
|
||||||
@ -77,11 +77,11 @@ type MsgHdr struct {
|
|||||||
// The layout of a DNS message.
|
// The layout of a DNS message.
|
||||||
type Msg struct {
|
type Msg struct {
|
||||||
MsgHdr
|
MsgHdr
|
||||||
Compress bool // If true, the message will be compressed when converted to wire format.
|
Compress bool // If true, the message will be compressed when converted to wire format.
|
||||||
Question []Question
|
Question []Question // Holds the RR(s) of the question section.
|
||||||
Answer []RR
|
Answer []RR // Holds the RR(s) of the answer section.
|
||||||
Ns []RR
|
Ns []RR // Holds the RR(s) of the authority section.
|
||||||
Extra []RR
|
Extra []RR // Holds the RR(s) of the additional section.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map of strings for each RR wire type.
|
// Map of strings for each RR wire type.
|
||||||
@ -420,10 +420,10 @@ func packStructValue(val reflect.Value, msg []byte, off int, compression map[str
|
|||||||
}
|
}
|
||||||
case "NSEC": // NSEC/NSEC3
|
case "NSEC": // NSEC/NSEC3
|
||||||
// This is the uint16 type bitmap
|
// This is the uint16 type bitmap
|
||||||
if val.Field(i).Len() == 0 {
|
if val.Field(i).Len() == 0 {
|
||||||
// Do absolutely nothing
|
// Do absolutely nothing
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
lastwindow := uint16(0)
|
lastwindow := uint16(0)
|
||||||
length := uint16(0)
|
length := uint16(0)
|
||||||
@ -444,10 +444,10 @@ func packStructValue(val reflect.Value, msg []byte, off int, compression map[str
|
|||||||
}
|
}
|
||||||
length = (t - window*256) / 8
|
length = (t - window*256) / 8
|
||||||
bit := t - (window * 256) - (length * 8)
|
bit := t - (window * 256) - (length * 8)
|
||||||
if off+2+int(length) > lenmsg {
|
if off+2+int(length) > lenmsg {
|
||||||
println("dns: overflow packing NSECx bitmap")
|
println("dns: overflow packing NSECx bitmap")
|
||||||
return lenmsg, false
|
return lenmsg, false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setting the window #
|
// Setting the window #
|
||||||
msg[off] = byte(window)
|
msg[off] = byte(window)
|
||||||
@ -612,12 +612,12 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
|
|||||||
lenmsg := len(msg)
|
lenmsg := len(msg)
|
||||||
switch fv := val.Field(i); fv.Kind() {
|
switch fv := val.Field(i); fv.Kind() {
|
||||||
default:
|
default:
|
||||||
println("dns: unknown case unpacking struct")
|
println("dns: unknown case unpacking struct")
|
||||||
return lenmsg, false
|
return lenmsg, false
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
switch val.Type().Field(i).Tag {
|
switch val.Type().Field(i).Tag {
|
||||||
default:
|
default:
|
||||||
println("dns: unknown tag unpacking struct")
|
println("dns: unknown tag unpacking struct")
|
||||||
return lenmsg, false
|
return lenmsg, false
|
||||||
case "A":
|
case "A":
|
||||||
if off+net.IPv4len > len(msg) {
|
if off+net.IPv4len > len(msg) {
|
||||||
@ -759,7 +759,7 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
|
|||||||
var s string
|
var s string
|
||||||
switch val.Type().Field(i).Tag {
|
switch val.Type().Field(i).Tag {
|
||||||
default:
|
default:
|
||||||
println("dns: unknown tag unpacking string")
|
println("dns: unknown tag unpacking string")
|
||||||
return lenmsg, false
|
return lenmsg, false
|
||||||
case "hex":
|
case "hex":
|
||||||
// Rest of the RR is hex encoded, network order an issue here?
|
// Rest of the RR is hex encoded, network order an issue here?
|
||||||
@ -778,7 +778,7 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
|
|||||||
consumed = 0 // return len(msg), false?
|
consumed = 0 // return len(msg), false?
|
||||||
}
|
}
|
||||||
if off+rdlength-consumed > lenmsg {
|
if off+rdlength-consumed > lenmsg {
|
||||||
println("dns: overflow when unpacking hex string")
|
println("dns: overflow when unpacking hex string")
|
||||||
return lenmsg, false
|
return lenmsg, false
|
||||||
}
|
}
|
||||||
s = hex.EncodeToString(msg[off : off+rdlength-consumed])
|
s = hex.EncodeToString(msg[off : off+rdlength-consumed])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user