Allow TYPExxxx syntax in NSECx records

This commit is contained in:
Miek Gieben 2012-02-28 20:20:07 +01:00
parent c32c13ba25
commit 5fec355528
2 changed files with 18 additions and 10 deletions

View File

@ -189,9 +189,10 @@ func TestParseDirectiveMisc(t *testing.T) {
// Another one hear, geared to NSECx
func TestParseNSEC(t *testing.T) {
nsectests := map[string]string{
"nl. IN NSEC3PARAM 1 0 5 30923C44C6CBBB8F": "nl.\t3600\tIN\tNSEC3PARAM\t1 0 5 30923C44C6CBBB8F",
"nl. IN NSEC3PARAM 1 0 5 30923C44C6CBBB8F": "nl.\t3600\tIN\tNSEC3PARAM\t1 0 5 30923C44C6CBBB8F",
"p2209hipbpnm681knjnu0m1febshlv4e.nl. IN NSEC3 1 1 5 30923C44C6CBBB8F P90DG1KE8QEAN0B01613LHQDG0SOJ0TA NS SOA TXT RRSIG DNSKEY NSEC3PARAM": "p2209hipbpnm681knjnu0m1febshlv4e.nl.\t3600\tIN\tNSEC3\t1 1 5 30923C44C6CBBB8F P90DG1KE8QEAN0B01613LHQDG0SOJ0TA NS SOA TXT RRSIG DNSKEY NSEC3PARAM",
"localhost.dnssex.nl. IN NSEC www.dnssex.nl. A RRSIG NSEC": "localhost.dnssex.nl.\t3600\tIN\tNSEC\twww.dnssex.nl. A RRSIG NSEC",
"localhost.dnssex.nl. IN NSEC www.dnssex.nl. A RRSIG NSEC": "localhost.dnssex.nl.\t3600\tIN\tNSEC\twww.dnssex.nl. A RRSIG NSEC",
"localhost.dnssex.nl. IN NSEC www.dnssex.nl. A RRSIG NSEC TYPE65534": "localhost.dnssex.nl.\t3600\tIN\tNSEC\twww.dnssex.nl. A RRSIG NSEC TYPE65534",
}
for i, o := range nsectests {
rr, e := NewRR(i)

View File

@ -606,17 +606,19 @@ func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
}
rr.TypeBitMap = make([]uint16, 0)
var k uint16
l = <-c
for l.value != _NEWLINE && l.value != _EOF {
switch l.value {
case _BLANK:
// Ok
case _STRING:
if k, ok := Str_rr[strings.ToUpper(l.token)]; !ok {
return nil, &ParseError{f, "bad NSEC TypeBitMap", l}
} else {
rr.TypeBitMap = append(rr.TypeBitMap, k)
if k, ok = Str_rr[strings.ToUpper(l.token)]; !ok {
if k, ok = typeToInt(l.token); !ok {
return nil, &ParseError{f, "bad NSEC TypeBitMap", l}
}
}
rr.TypeBitMap = append(rr.TypeBitMap, k)
default:
return nil, &ParseError{f, "bad NSEC TypeBitMap", l}
}
@ -663,17 +665,22 @@ func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr.NextDomain = l.token
rr.TypeBitMap = make([]uint16, 0)
var (
k uint16
ok bool
)
l = <-c
for l.value != _NEWLINE && l.value != _EOF {
switch l.value {
case _BLANK:
// Ok
case _STRING:
if k, ok := Str_rr[strings.ToUpper(l.token)]; !ok {
return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}
} else {
rr.TypeBitMap = append(rr.TypeBitMap, k)
if k, ok = Str_rr[strings.ToUpper(l.token)]; !ok {
if k, ok = typeToInt(l.token); ! ok {
return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}
}
}
rr.TypeBitMap = append(rr.TypeBitMap, k)
default:
return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}
}