mirror of
https://github.com/miekg/dns.git
synced 2025-10-11 09:51:01 +02:00
Fix Tsig parsing
This commit is contained in:
parent
7e51041a24
commit
1ece21a05e
19
msg.go
19
msg.go
@ -598,6 +598,25 @@ func unpackStructValue(val *reflect.StructValue, msg []byte, off int) (off1 int,
|
|||||||
fmt.Fprintf(os.Stderr, "dns: failure unpacking domain-name")
|
fmt.Fprintf(os.Stderr, "dns: failure unpacking domain-name")
|
||||||
return len(msg), false
|
return len(msg), false
|
||||||
}
|
}
|
||||||
|
case "fixed-size":
|
||||||
|
// We should already know how many bytes we can expect
|
||||||
|
// TODO(mg) pack variant
|
||||||
|
println(val.Type().Name())
|
||||||
|
println(f.Name) // MAC Otherdata, then get back the
|
||||||
|
//f := val.Type().(*reflect.StructType).Field(i)
|
||||||
|
//FieldByName(MACSize), Othersize to get the stuff we need
|
||||||
|
var size int
|
||||||
|
// consumed += len(val.FieldByName("SignerName").(*reflect.StringValue).Get()) + 1
|
||||||
|
switch val.Type().Name() {
|
||||||
|
case "RR_TSIG":
|
||||||
|
// tsig has MACSize
|
||||||
|
size = 16 // TODO(mg) other hashes
|
||||||
|
}
|
||||||
|
if off+size > len(msg) {
|
||||||
|
fmt.Fprintf(os.Stderr, "dns: failure unpacking fixed-size string")
|
||||||
|
return len(msg), false
|
||||||
|
}
|
||||||
|
s = string(msg[off : off+size])
|
||||||
case "":
|
case "":
|
||||||
if off >= len(msg) || off+1+int(msg[off]) > len(msg) {
|
if off >= len(msg) || off+1+int(msg[off]) > len(msg) {
|
||||||
fmt.Fprintf(os.Stderr, "dns: failure unpacking string")
|
fmt.Fprintf(os.Stderr, "dns: failure unpacking string")
|
||||||
|
5
tsig.go
5
tsig.go
@ -22,11 +22,11 @@ type RR_TSIG struct {
|
|||||||
TimeSigned uint64
|
TimeSigned uint64
|
||||||
Fudge uint16
|
Fudge uint16
|
||||||
MACSize uint16
|
MACSize uint16
|
||||||
MAC string
|
MAC string "fixed-size"
|
||||||
OrigId uint16
|
OrigId uint16
|
||||||
Error uint16
|
Error uint16
|
||||||
OtherLen uint16
|
OtherLen uint16
|
||||||
OtherData string
|
OtherData string "fixed-size"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rr *RR_TSIG) Header() *RR_Header {
|
func (rr *RR_TSIG) Header() *RR_Header {
|
||||||
@ -35,6 +35,7 @@ func (rr *RR_TSIG) Header() *RR_Header {
|
|||||||
|
|
||||||
func (rr *RR_TSIG) String() string {
|
func (rr *RR_TSIG) String() string {
|
||||||
// It has no official presentation format
|
// It has no official presentation format
|
||||||
|
println("mac len: ", rr.MACSize)
|
||||||
return rr.Hdr.String() +
|
return rr.Hdr.String() +
|
||||||
" " + rr.Algorithm +
|
" " + rr.Algorithm +
|
||||||
" " + tsigTimeToDate(rr.TimeSigned) +
|
" " + tsigTimeToDate(rr.TimeSigned) +
|
||||||
|
Loading…
x
Reference in New Issue
Block a user