start fixing for unknown rrs parsing/printing
This commit is contained in:
parent
1a78b40a56
commit
5dbfc48a5e
|
@ -12,7 +12,6 @@ things that need to be fixed.
|
|||
settings just like that -- need to look at them.
|
||||
-edns NSID is another
|
||||
* Add tsig check in 'q'?
|
||||
* More RRs to add. Parsing of strings within the rdata
|
||||
* Unknown RR parsing
|
||||
* \DDD in zonefiles
|
||||
|
||||
|
|
|
@ -62,3 +62,6 @@ zzzzz.miek.nl. 345600 IN TXT "Last record"
|
|||
zzzzz.miek.nl. 345600 IN RRSIG TXT 8 3 345600 20110823011301 20110724011301 12051 miek.nl. mhPyq3w7I1nE08MpgJE/hZDY8DRJp1A7fJOS9hJ1zBVd4GWa/V7OXtbs 1hxLS81yUefp86bRHIjdubzoN5mTG1aZLt/fDNJ7Ou3zt/ql65iwVb+U +prIDVizuNdsDS7K2De5vfoZzGsmmGtEI7ILA/We0TtEJMF6QnINJMbP NF0=
|
||||
zzzzz.miek.nl. 86400 IN NSEC miek.nl. TXT RRSIG NSEC
|
||||
zzzzz.miek.nl. 86400 IN RRSIG NSEC 8 3 86400 20110823011301 20110724011301 12051 miek.nl. lyRljEQFOmajcdo6bBI67DsTlQTGU3ag9vlE07u7ynqt9aYBXyE9mkas AK4V0oI32YGb2pOSB6RbbdHwUmSt+cYhOA49tl2t0Qoi3pH21dicJiup dZuyjfqUEqJlQoEhNXGtP/pRvWjNA4pQeOsOAoWq/BDcWCSQB9mh2LvU OH4=
|
||||
a.example. CLASS32 TYPE731 \# 6 abcd (
|
||||
ef 01 23 45 )
|
||||
b.example. HS TYPE62347 \# 0
|
||||
|
|
7
types.go
7
types.go
|
@ -142,7 +142,12 @@ func (q *Question) String() (s string) {
|
|||
} else {
|
||||
s = ";" + q.Name + "\t"
|
||||
}
|
||||
s = s + Class_str[q.Qclass] + "\t"
|
||||
if _, ok := Class_str[q.Qclass]; ok {
|
||||
s += Class_str[q.Qclass] + "\t"
|
||||
} else {
|
||||
s += "CLASS" + strconv.Itoa(int(q.Qtype))
|
||||
}
|
||||
|
||||
if _, ok := Rr_str[q.Qtype]; ok {
|
||||
s += " " + Rr_str[q.Qtype]
|
||||
} else {
|
||||
|
|
102
zscan.go
102
zscan.go
|
@ -197,9 +197,9 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
|||
t <- Token{Error: &ParseError{f, "Expecting $INCLUDE value, not this...", l}}
|
||||
return
|
||||
}
|
||||
if e:=slurpRemainder(c, f) ; e != nil {
|
||||
t <- Token{Error: e}
|
||||
}
|
||||
if e := slurpRemainder(c, f); e != nil {
|
||||
t <- Token{Error: e}
|
||||
}
|
||||
// Start with the new file
|
||||
r1, e1 := os.Open(l.token)
|
||||
if e1 != nil {
|
||||
|
@ -223,9 +223,9 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
|||
t <- Token{Error: &ParseError{f, "Expecting $TTL value, not this...", l}}
|
||||
return
|
||||
}
|
||||
if e:=slurpRemainder(c, f) ; e != nil {
|
||||
t <- Token{Error: e}
|
||||
}
|
||||
if e := slurpRemainder(c, f); e != nil {
|
||||
t <- Token{Error: e}
|
||||
}
|
||||
if ttl, ok := stringToTtl(l, f, t); !ok {
|
||||
return
|
||||
} else {
|
||||
|
@ -243,9 +243,9 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
|||
t <- Token{Error: &ParseError{f, "Expecting $ORIGIN value, not this...", l}}
|
||||
return
|
||||
}
|
||||
if e:=slurpRemainder(c, f) ; e != nil {
|
||||
t <- Token{Error: e}
|
||||
}
|
||||
if e := slurpRemainder(c, f); e != nil {
|
||||
t <- Token{Error: e}
|
||||
}
|
||||
if !IsFqdn(l.token) {
|
||||
origin = l.token + "." + origin // Append old origin if the new one isn't a fqdn
|
||||
} else {
|
||||
|
@ -261,13 +261,21 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
|||
case _EXPECT_ANY:
|
||||
switch l.value {
|
||||
case _RRTYPE:
|
||||
h.Rrtype, _ = Str_rr[strings.ToUpper(l.token)]
|
||||
h.Rrtype, ok = Str_rr[strings.ToUpper(l.token)]
|
||||
if !ok {
|
||||
if h.Rrtype, ok = typeToInt(l.token); !ok {
|
||||
t <- Token{Error: &ParseError{f, "Unknown RR type", l}}
|
||||
return
|
||||
}
|
||||
}
|
||||
st = _EXPECT_RDATA
|
||||
case _CLASS:
|
||||
h.Class, ok = Str_class[strings.ToUpper(l.token)]
|
||||
if !ok {
|
||||
t <- Token{Error: &ParseError{f, "Unknown class", l}}
|
||||
return
|
||||
if h.Class, ok = classToInt(l.token); !ok {
|
||||
t <- Token{Error: &ParseError{f, "Unknown class", l}}
|
||||
return
|
||||
}
|
||||
}
|
||||
st = _EXPECT_ANY_NOCLASS_BL
|
||||
case _STRING: // TTL is this case
|
||||
|
@ -275,7 +283,7 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
|||
return
|
||||
} else {
|
||||
h.Ttl = ttl
|
||||
defttl = ttl
|
||||
defttl = ttl
|
||||
}
|
||||
st = _EXPECT_ANY_NOTTL_BL
|
||||
default:
|
||||
|
@ -299,12 +307,20 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
|||
case _CLASS:
|
||||
h.Class, ok = Str_class[strings.ToUpper(l.token)]
|
||||
if !ok {
|
||||
t <- Token{Error: &ParseError{f, "Unknown class", l}}
|
||||
return
|
||||
if h.Class, ok = classToInt(l.token); !ok {
|
||||
t <- Token{Error: &ParseError{f, "Unknown class", l}}
|
||||
return
|
||||
}
|
||||
}
|
||||
st = _EXPECT_RRTYPE_BL
|
||||
case _RRTYPE:
|
||||
h.Rrtype, _ = Str_rr[strings.ToUpper(l.token)]
|
||||
h.Rrtype, ok = Str_rr[strings.ToUpper(l.token)]
|
||||
if !ok {
|
||||
if h.Rrtype, ok = typeToInt(l.token); !ok {
|
||||
t <- Token{Error: &ParseError{f, "Unknown rr type", l}}
|
||||
return
|
||||
}
|
||||
}
|
||||
st = _EXPECT_RDATA
|
||||
}
|
||||
case _EXPECT_ANY_NOCLASS:
|
||||
|
@ -314,11 +330,17 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
|||
return
|
||||
} else {
|
||||
h.Ttl = ttl
|
||||
defttl = ttl
|
||||
defttl = ttl
|
||||
}
|
||||
st = _EXPECT_RRTYPE_BL
|
||||
case _RRTYPE:
|
||||
h.Rrtype, _ = Str_rr[strings.ToUpper(l.token)]
|
||||
h.Rrtype, ok = Str_rr[strings.ToUpper(l.token)]
|
||||
if !ok {
|
||||
if h.Rrtype, ok = typeToInt(l.token); !ok {
|
||||
t <- Token{Error: &ParseError{f, "Unknown rr type", l}}
|
||||
return
|
||||
}
|
||||
}
|
||||
st = _EXPECT_RDATA
|
||||
default:
|
||||
t <- Token{Error: &ParseError{f, "Expecting RR type or TTL, not this...", l}}
|
||||
|
@ -335,7 +357,13 @@ func parseZone(r io.Reader, f string, t chan Token, include int) {
|
|||
t <- Token{Error: &ParseError{f, "Unknown RR type", l}}
|
||||
return
|
||||
}
|
||||
h.Rrtype, _ = Str_rr[strings.ToUpper(l.token)]
|
||||
h.Rrtype, ok = Str_rr[strings.ToUpper(l.token)]
|
||||
if !ok {
|
||||
if h.Rrtype, ok = typeToInt(l.token); !ok {
|
||||
t <- Token{Error: &ParseError{f, "Unknown rr type", l}}
|
||||
return
|
||||
}
|
||||
}
|
||||
st = _EXPECT_RDATA
|
||||
case _EXPECT_RDATA:
|
||||
// I could save my token here...? l
|
||||
|
@ -438,12 +466,20 @@ func zlexer(s scanner.Scanner, c chan lex) {
|
|||
if _, ok := Str_rr[strings.ToUpper(l.token)]; ok {
|
||||
l.value = _RRTYPE
|
||||
rrtype = true
|
||||
}
|
||||
} else {
|
||||
if strings.HasPrefix(strings.ToUpper(l.token), "TYPE") {
|
||||
l.value = _RRTYPE
|
||||
rrtype = true
|
||||
}
|
||||
}
|
||||
if _, ok := Str_class[strings.ToUpper(l.token)]; ok {
|
||||
l.value = _CLASS
|
||||
} else {
|
||||
if strings.HasPrefix(strings.ToUpper(l.token), "CLASS") {
|
||||
l.value = _CLASS
|
||||
}
|
||||
}
|
||||
}
|
||||
// Space ALSO?
|
||||
c <- l
|
||||
}
|
||||
stri = 0
|
||||
|
@ -553,11 +589,11 @@ func zlexer(s scanner.Scanner, c chan lex) {
|
|||
escape = false
|
||||
break
|
||||
}
|
||||
space = false
|
||||
space = false
|
||||
// send previous gathered text and the quote
|
||||
if stri != 0 {
|
||||
//komt best vaak langs
|
||||
//println("DEBUG: SENDING PREV TEXT", string(str[:stri]))
|
||||
//komt best vaak langs
|
||||
//println("DEBUG: SENDING PREV TEXT", string(str[:stri]))
|
||||
l.value = _STRING
|
||||
l.token = string(str[:stri])
|
||||
c <- l
|
||||
|
@ -624,6 +660,24 @@ func zlexer(s scanner.Scanner, c chan lex) {
|
|||
}
|
||||
}
|
||||
|
||||
// Extract the class number from CLASSxx
|
||||
func classToInt(token string) (uint16, bool) {
|
||||
class, ok := strconv.Atoi(token[5:])
|
||||
if ok != nil {
|
||||
return 0, false
|
||||
}
|
||||
return uint16(class), true
|
||||
}
|
||||
|
||||
// Extract the rr number from TYPExxx
|
||||
func typeToInt(token string) (uint16, bool) {
|
||||
typ, ok := strconv.Atoi(token[4:])
|
||||
if ok != nil {
|
||||
return 0, false
|
||||
}
|
||||
return uint16(typ), true
|
||||
}
|
||||
|
||||
func stringToTtl(l lex, f string, t chan Token) (uint32, bool) {
|
||||
if ttl, ok := strconv.Atoi(l.token); ok != nil {
|
||||
t <- Token{Error: &ParseError{f, "Not a TTL", l}}
|
||||
|
|
Loading…
Reference in New Issue