Remove WKS support
Support for WKS was incomplete, i.e. len() method was incorrect. Remove support for the record and handle it as an unknown one. Fixes #361
This commit is contained in:
parent
907a4aef57
commit
799de7044d
|
@ -334,9 +334,8 @@ func TestNoRdataPack(t *testing.T) {
|
||||||
func TestNoRdataUnpack(t *testing.T) {
|
func TestNoRdataUnpack(t *testing.T) {
|
||||||
data := make([]byte, 1024)
|
data := make([]byte, 1024)
|
||||||
for typ, fn := range TypeToRR {
|
for typ, fn := range TypeToRR {
|
||||||
if typ == TypeSOA || typ == TypeTSIG || typ == TypeWKS {
|
if typ == TypeSOA || typ == TypeTSIG {
|
||||||
// SOA, TSIG will not be seen (like this) in dyn. updates?
|
// SOA, TSIG will not be seen (like this) in dyn. updates?
|
||||||
// WKS is an bug, but...deprecated record.
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
r := fn()
|
r := fn()
|
||||||
|
|
|
@ -69,15 +69,6 @@ func Field(r RR, i int) string {
|
||||||
s += " " + Type(d.Index(i).Uint()).String()
|
s += " " + Type(d.Index(i).Uint()).String()
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
case `dns:"wks"`:
|
|
||||||
if d.Len() == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
s := strconv.Itoa(int(d.Index(0).Uint()))
|
|
||||||
for i := 0; i < d.Len(); i++ {
|
|
||||||
s += " " + strconv.Itoa(int(d.Index(i).Uint()))
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
default:
|
default:
|
||||||
// if it does not have a tag its a string slice
|
// if it does not have a tag its a string slice
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
58
msg.go
58
msg.go
|
@ -663,26 +663,6 @@ func packStructValue(val reflect.Value, msg []byte, off int, compression map[str
|
||||||
msg[off] = byte(fv.Index(j).Uint())
|
msg[off] = byte(fv.Index(j).Uint())
|
||||||
off++
|
off++
|
||||||
}
|
}
|
||||||
case `dns:"wks"`:
|
|
||||||
// TODO(miek): this is wrong should be lenrd
|
|
||||||
if off == lenmsg {
|
|
||||||
break // dyn. updates
|
|
||||||
}
|
|
||||||
if val.Field(i).Len() == 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
off1 := off
|
|
||||||
for j := 0; j < val.Field(i).Len(); j++ {
|
|
||||||
serv := int(fv.Index(j).Uint())
|
|
||||||
if off+serv/8+1 > len(msg) {
|
|
||||||
return len(msg), &Error{err: "overflow packing wks"}
|
|
||||||
}
|
|
||||||
msg[off+serv/8] |= byte(1 << (7 - uint(serv%8)))
|
|
||||||
if off+serv/8+1 > off1 {
|
|
||||||
off1 = off + serv/8 + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
off = off1
|
|
||||||
case `dns:"nsec"`: // NSEC/NSEC3
|
case `dns:"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 {
|
||||||
|
@ -1050,44 +1030,6 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, err er
|
||||||
msg[off+5], msg[off+6], msg[off+7], msg[off+8], msg[off+9], msg[off+10],
|
msg[off+5], msg[off+6], msg[off+7], msg[off+8], msg[off+9], msg[off+10],
|
||||||
msg[off+11], msg[off+12], msg[off+13], msg[off+14], msg[off+15]}))
|
msg[off+11], msg[off+12], msg[off+13], msg[off+14], msg[off+15]}))
|
||||||
off += net.IPv6len
|
off += net.IPv6len
|
||||||
case `dns:"wks"`:
|
|
||||||
// Rest of the record is the bitmap
|
|
||||||
var serv []uint16
|
|
||||||
j := 0
|
|
||||||
for off < lenmsg {
|
|
||||||
if off+1 > lenmsg {
|
|
||||||
return lenmsg, &Error{err: "overflow unpacking wks"}
|
|
||||||
}
|
|
||||||
b := msg[off]
|
|
||||||
// Check the bits one by one, and set the type
|
|
||||||
if b&0x80 == 0x80 {
|
|
||||||
serv = append(serv, uint16(j*8+0))
|
|
||||||
}
|
|
||||||
if b&0x40 == 0x40 {
|
|
||||||
serv = append(serv, uint16(j*8+1))
|
|
||||||
}
|
|
||||||
if b&0x20 == 0x20 {
|
|
||||||
serv = append(serv, uint16(j*8+2))
|
|
||||||
}
|
|
||||||
if b&0x10 == 0x10 {
|
|
||||||
serv = append(serv, uint16(j*8+3))
|
|
||||||
}
|
|
||||||
if b&0x8 == 0x8 {
|
|
||||||
serv = append(serv, uint16(j*8+4))
|
|
||||||
}
|
|
||||||
if b&0x4 == 0x4 {
|
|
||||||
serv = append(serv, uint16(j*8+5))
|
|
||||||
}
|
|
||||||
if b&0x2 == 0x2 {
|
|
||||||
serv = append(serv, uint16(j*8+6))
|
|
||||||
}
|
|
||||||
if b&0x1 == 0x1 {
|
|
||||||
serv = append(serv, uint16(j*8+7))
|
|
||||||
}
|
|
||||||
j++
|
|
||||||
off++
|
|
||||||
}
|
|
||||||
fv.Set(reflect.ValueOf(serv))
|
|
||||||
case `dns:"nsec"`: // NSEC/NSEC3
|
case `dns:"nsec"`: // NSEC/NSEC3
|
||||||
if off == len(msg) {
|
if off == len(msg) {
|
||||||
break
|
break
|
||||||
|
|
|
@ -25,7 +25,6 @@ import (
|
||||||
// * OPT RR - EDNS0 parsing - needs to some looking at
|
// * OPT RR - EDNS0 parsing - needs to some looking at
|
||||||
// * HIP - uses "hex", but is actually size-hex - might drop size-hex?
|
// * HIP - uses "hex", but is actually size-hex - might drop size-hex?
|
||||||
// * Z
|
// * Z
|
||||||
// * WKS - uint16 slice
|
|
||||||
// * NINFO
|
// * NINFO
|
||||||
// * PrivateRR
|
// * PrivateRR
|
||||||
|
|
||||||
|
@ -73,7 +72,7 @@ func main() {
|
||||||
if st, _ := getTypeStruct(o.Type(), scope); st == nil {
|
if st, _ := getTypeStruct(o.Type(), scope); st == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if name == "PrivateRR" {
|
if name == "PrivateRR" || name == "WKS" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
59
scan_rr.go
59
scan_rr.go
|
@ -1443,64 +1443,6 @@ func setEUI64(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
return rr, nil, ""
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func setWKS(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
|
||||||
rr := new(WKS)
|
|
||||||
rr.Hdr = h
|
|
||||||
|
|
||||||
l := <-c
|
|
||||||
if l.length == 0 {
|
|
||||||
return rr, nil, l.comment
|
|
||||||
}
|
|
||||||
rr.Address = net.ParseIP(l.token)
|
|
||||||
if rr.Address == nil || l.err {
|
|
||||||
return nil, &ParseError{f, "bad WKS Address", l}, ""
|
|
||||||
}
|
|
||||||
|
|
||||||
<-c // zBlank
|
|
||||||
l = <-c
|
|
||||||
proto := "tcp"
|
|
||||||
i, e := strconv.Atoi(l.token)
|
|
||||||
if e != nil || l.err {
|
|
||||||
return nil, &ParseError{f, "bad WKS Protocol", l}, ""
|
|
||||||
}
|
|
||||||
rr.Protocol = uint8(i)
|
|
||||||
switch rr.Protocol {
|
|
||||||
case 17:
|
|
||||||
proto = "udp"
|
|
||||||
case 6:
|
|
||||||
proto = "tcp"
|
|
||||||
default:
|
|
||||||
return nil, &ParseError{f, "bad WKS Protocol", l}, ""
|
|
||||||
}
|
|
||||||
|
|
||||||
<-c
|
|
||||||
l = <-c
|
|
||||||
rr.BitMap = make([]uint16, 0)
|
|
||||||
var (
|
|
||||||
k int
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
for l.value != zNewline && l.value != zEOF {
|
|
||||||
switch l.value {
|
|
||||||
case zBlank:
|
|
||||||
// Ok
|
|
||||||
case zString:
|
|
||||||
if k, err = net.LookupPort(proto, l.token); err != nil {
|
|
||||||
i, e := strconv.Atoi(l.token) // If a number use that
|
|
||||||
if e != nil {
|
|
||||||
return nil, &ParseError{f, "bad WKS BitMap", l}, ""
|
|
||||||
}
|
|
||||||
rr.BitMap = append(rr.BitMap, uint16(i))
|
|
||||||
}
|
|
||||||
rr.BitMap = append(rr.BitMap, uint16(k))
|
|
||||||
default:
|
|
||||||
return nil, &ParseError{f, "bad WKS BitMap", l}, ""
|
|
||||||
}
|
|
||||||
l = <-c
|
|
||||||
}
|
|
||||||
return rr, nil, l.comment
|
|
||||||
}
|
|
||||||
|
|
||||||
func setSSHFP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
func setSSHFP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
rr := new(SSHFP)
|
rr := new(SSHFP)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
@ -2265,6 +2207,5 @@ var typeToparserFunc = map[uint16]parserFunc{
|
||||||
TypeUID: {setUID, false},
|
TypeUID: {setUID, false},
|
||||||
TypeUINFO: {setUINFO, true},
|
TypeUINFO: {setUINFO, true},
|
||||||
TypeURI: {setURI, true},
|
TypeURI: {setURI, true},
|
||||||
TypeWKS: {setWKS, true},
|
|
||||||
TypeX25: {setX25, false},
|
TypeX25: {setX25, false},
|
||||||
}
|
}
|
||||||
|
|
26
types.go
26
types.go
|
@ -35,7 +35,6 @@ const (
|
||||||
TypeMG uint16 = 8
|
TypeMG uint16 = 8
|
||||||
TypeMR uint16 = 9
|
TypeMR uint16 = 9
|
||||||
TypeNULL uint16 = 10
|
TypeNULL uint16 = 10
|
||||||
TypeWKS uint16 = 11
|
|
||||||
TypePTR uint16 = 12
|
TypePTR uint16 = 12
|
||||||
TypeHINFO uint16 = 13
|
TypeHINFO uint16 = 13
|
||||||
TypeMINFO uint16 = 14
|
TypeMINFO uint16 = 14
|
||||||
|
@ -1128,31 +1127,6 @@ type NINFO struct {
|
||||||
|
|
||||||
func (rr *NINFO) String() string { return rr.Hdr.String() + sprintTxt(rr.ZSData) }
|
func (rr *NINFO) String() string { return rr.Hdr.String() + sprintTxt(rr.ZSData) }
|
||||||
|
|
||||||
type WKS struct {
|
|
||||||
Hdr RR_Header
|
|
||||||
Address net.IP `dns:"a"`
|
|
||||||
Protocol uint8
|
|
||||||
BitMap []uint16 `dns:"wks"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rr *WKS) len() int {
|
|
||||||
// TODO: this is missing something...
|
|
||||||
return rr.Hdr.len() + net.IPv4len + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rr *WKS) String() (s string) {
|
|
||||||
s = rr.Hdr.String()
|
|
||||||
if rr.Address != nil {
|
|
||||||
s += rr.Address.String()
|
|
||||||
}
|
|
||||||
// TODO(miek): missing protocol here, see /etc/protocols
|
|
||||||
for i := 0; i < len(rr.BitMap); i++ {
|
|
||||||
// should lookup the port
|
|
||||||
s += " " + strconv.Itoa(int(rr.BitMap[i]))
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
type NID struct {
|
type NID struct {
|
||||||
Hdr RR_Header
|
Hdr RR_Header
|
||||||
Preference uint16
|
Preference uint16
|
||||||
|
|
|
@ -23,7 +23,6 @@ var skipLen = map[string]struct{}{
|
||||||
"NSEC": {},
|
"NSEC": {},
|
||||||
"NSEC3": {},
|
"NSEC3": {},
|
||||||
"OPT": {},
|
"OPT": {},
|
||||||
"WKS": {},
|
|
||||||
"IPSECKEY": {},
|
"IPSECKEY": {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +104,7 @@ func main() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
name := strings.TrimPrefix(o.Name(), "Type")
|
name := strings.TrimPrefix(o.Name(), "Type")
|
||||||
if name == "PrivateRR" {
|
if name == "PrivateRR" || name == "WKS" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
numberedTypes = append(numberedTypes, name)
|
numberedTypes = append(numberedTypes, name)
|
||||||
|
@ -121,7 +120,7 @@ func main() {
|
||||||
if st, _ := getTypeStruct(o.Type(), scope); st == nil {
|
if st, _ := getTypeStruct(o.Type(), scope); st == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if name == "PrivateRR" {
|
if name == "PrivateRR" || name == "WKS" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
46
zmsg.go
46
zmsg.go
|
@ -1221,24 +1221,6 @@ func (rr *URI) pack(msg []byte, off int, compression map[string]int, compress bo
|
||||||
return off, nil
|
return off, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rr *WKS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
|
|
||||||
off, err := rr.Hdr.pack(msg, off, compression, compress)
|
|
||||||
if err != nil {
|
|
||||||
return off, err
|
|
||||||
}
|
|
||||||
headerEnd := off
|
|
||||||
off, err = packDataA(rr.Address, msg, off)
|
|
||||||
if err != nil {
|
|
||||||
return off, err
|
|
||||||
}
|
|
||||||
off, err = packUint8(rr.Protocol, msg, off)
|
|
||||||
if err != nil {
|
|
||||||
return off, err
|
|
||||||
}
|
|
||||||
rr.Header().Rdlength = uint16(off - headerEnd)
|
|
||||||
return off, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rr *X25) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
|
func (rr *X25) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
|
||||||
off, err := rr.Hdr.pack(msg, off, compression, compress)
|
off, err := rr.Hdr.pack(msg, off, compression, compress)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -3040,34 +3022,6 @@ func unpackURI(h RR_Header, msg []byte, off int) (RR, int, error) {
|
||||||
return rr, off, err
|
return rr, off, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func unpackWKS(h RR_Header, msg []byte, off int) (RR, int, error) {
|
|
||||||
if noRdata(h) {
|
|
||||||
return nil, off, nil
|
|
||||||
}
|
|
||||||
var err error
|
|
||||||
rdStart := off
|
|
||||||
_ = rdStart
|
|
||||||
|
|
||||||
rr := new(WKS)
|
|
||||||
rr.Hdr = h
|
|
||||||
|
|
||||||
rr.Address, off, err = unpackDataA(msg, off)
|
|
||||||
if err != nil {
|
|
||||||
return rr, off, err
|
|
||||||
}
|
|
||||||
if off == len(msg) {
|
|
||||||
return rr, off, nil
|
|
||||||
}
|
|
||||||
rr.Protocol, off, err = unpackUint8(msg, off)
|
|
||||||
if err != nil {
|
|
||||||
return rr, off, err
|
|
||||||
}
|
|
||||||
if off == len(msg) {
|
|
||||||
return rr, off, nil
|
|
||||||
}
|
|
||||||
return rr, off, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func unpackX25(h RR_Header, msg []byte, off int) (RR, int, error) {
|
func unpackX25(h RR_Header, msg []byte, off int) (RR, int, error) {
|
||||||
if noRdata(h) {
|
if noRdata(h) {
|
||||||
return nil, off, nil
|
return nil, off, nil
|
||||||
|
|
|
@ -76,7 +76,6 @@ var TypeToRR = map[uint16]func() RR{
|
||||||
TypeUID: func() RR { return new(UID) },
|
TypeUID: func() RR { return new(UID) },
|
||||||
TypeUINFO: func() RR { return new(UINFO) },
|
TypeUINFO: func() RR { return new(UINFO) },
|
||||||
TypeURI: func() RR { return new(URI) },
|
TypeURI: func() RR { return new(URI) },
|
||||||
TypeWKS: func() RR { return new(WKS) },
|
|
||||||
TypeX25: func() RR { return new(X25) },
|
TypeX25: func() RR { return new(X25) },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +157,6 @@ var TypeToString = map[uint16]string{
|
||||||
TypeUINFO: "UINFO",
|
TypeUINFO: "UINFO",
|
||||||
TypeUNSPEC: "UNSPEC",
|
TypeUNSPEC: "UNSPEC",
|
||||||
TypeURI: "URI",
|
TypeURI: "URI",
|
||||||
TypeWKS: "WKS",
|
|
||||||
TypeX25: "X25",
|
TypeX25: "X25",
|
||||||
TypeNSAPPTR: "NSAP-PTR",
|
TypeNSAPPTR: "NSAP-PTR",
|
||||||
}
|
}
|
||||||
|
@ -231,7 +229,6 @@ func (rr *TXT) Header() *RR_Header { return &rr.Hdr }
|
||||||
func (rr *UID) Header() *RR_Header { return &rr.Hdr }
|
func (rr *UID) Header() *RR_Header { return &rr.Hdr }
|
||||||
func (rr *UINFO) Header() *RR_Header { return &rr.Hdr }
|
func (rr *UINFO) Header() *RR_Header { return &rr.Hdr }
|
||||||
func (rr *URI) Header() *RR_Header { return &rr.Hdr }
|
func (rr *URI) Header() *RR_Header { return &rr.Hdr }
|
||||||
func (rr *WKS) Header() *RR_Header { return &rr.Hdr }
|
|
||||||
func (rr *X25) Header() *RR_Header { return &rr.Hdr }
|
func (rr *X25) Header() *RR_Header { return &rr.Hdr }
|
||||||
|
|
||||||
// len() functions
|
// len() functions
|
||||||
|
@ -832,11 +829,6 @@ func (rr *UINFO) copy() RR {
|
||||||
func (rr *URI) copy() RR {
|
func (rr *URI) copy() RR {
|
||||||
return &URI{*rr.Hdr.copyHeader(), rr.Priority, rr.Weight, rr.Target}
|
return &URI{*rr.Hdr.copyHeader(), rr.Priority, rr.Weight, rr.Target}
|
||||||
}
|
}
|
||||||
func (rr *WKS) copy() RR {
|
|
||||||
BitMap := make([]uint16, len(rr.BitMap))
|
|
||||||
copy(BitMap, rr.BitMap)
|
|
||||||
return &WKS{*rr.Hdr.copyHeader(), copyIP(rr.Address), rr.Protocol, BitMap}
|
|
||||||
}
|
|
||||||
func (rr *X25) copy() RR {
|
func (rr *X25) copy() RR {
|
||||||
return &X25{*rr.Hdr.copyHeader(), rr.PSDNAddress}
|
return &X25{*rr.Hdr.copyHeader(), rr.PSDNAddress}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue