Parsing fix for lines starting with class or TTL
name. IN SOA a6.nstld.com. hostmaster.nic.name .... IN 7200 NS j6.nstld.com. 7200 IN NS k6.nstld.com. Wasn't handled properly
This commit is contained in:
parent
fd6bdd4bba
commit
0c0b97f72b
|
@ -347,9 +347,9 @@ func TestZoneParsing(t *testing.T) {
|
||||||
|
|
||||||
// name. 3600 IN SOA a6.nstld.com. hostmaster.nic.name. 203362132 300 300 1209600 300
|
// name. 3600 IN SOA a6.nstld.com. hostmaster.nic.name. 203362132 300 300 1209600 300
|
||||||
// name. 10800 IN NS g6.nstld.com.
|
// name. 10800 IN NS g6.nstld.com.
|
||||||
// name. 10800 IN NS h6.nstld.com.
|
// name. 7200 IN NS h6.nstld.com.
|
||||||
// name. 10800 IN NS j6.nstld.com.
|
// name. 3600 IN NS j6.nstld.com.
|
||||||
// name. 10800 IN NS k6.nstld.com.
|
// name. 3600 IN NS k6.nstld.com.
|
||||||
// name. 10800 IN NS l6.nstld.com.
|
// name. 10800 IN NS l6.nstld.com.
|
||||||
// name. 10800 IN NS a6.nstld.com.
|
// name. 10800 IN NS a6.nstld.com.
|
||||||
// name. 10800 IN NS c6.nstld.com.
|
// name. 10800 IN NS c6.nstld.com.
|
||||||
|
@ -376,10 +376,10 @@ name IN SOA a6.nstld.com. hostmaster.nic.name. (
|
||||||
300 ; minimum (5 minutes)
|
300 ; minimum (5 minutes)
|
||||||
)
|
)
|
||||||
$TTL 10800 ; 3 hours
|
$TTL 10800 ; 3 hours
|
||||||
NS g6.nstld.com.
|
IN NS g6.nstld.com.
|
||||||
NS h6.nstld.com.
|
7200 NS h6.nstld.com.
|
||||||
NS j6.nstld.com.
|
3600 IN NS j6.nstld.com.
|
||||||
NS k6.nstld.com.
|
IN 3600 NS k6.nstld.com.
|
||||||
NS l6.nstld.com.
|
NS l6.nstld.com.
|
||||||
NS a6.nstld.com.
|
NS a6.nstld.com.
|
||||||
NS c6.nstld.com.
|
NS c6.nstld.com.
|
||||||
|
|
27
zscan.go
27
zscan.go
|
@ -199,8 +199,7 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
|
||||||
st = _EXPECT_DIRORIGIN_BL
|
st = _EXPECT_DIRORIGIN_BL
|
||||||
case _DIRINCLUDE:
|
case _DIRINCLUDE:
|
||||||
st = _EXPECT_DIRINCLUDE_BL
|
st = _EXPECT_DIRINCLUDE_BL
|
||||||
case _RRTYPE:
|
case _RRTYPE: // Everthing has been omitted, this is the first thing on the line
|
||||||
// Everthing has been omitted
|
|
||||||
h.Name = prevName
|
h.Name = prevName
|
||||||
h.Rrtype, ok = Str_rr[strings.ToUpper(l.token)]
|
h.Rrtype, ok = Str_rr[strings.ToUpper(l.token)]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -210,9 +209,29 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
st = _EXPECT_RDATA
|
st = _EXPECT_RDATA
|
||||||
|
case _CLASS: // First thing on the line is the class
|
||||||
|
h.Name = prevName
|
||||||
|
h.Class, ok = Str_class[strings.ToUpper(l.token)]
|
||||||
|
if !ok {
|
||||||
|
if h.Class, ok = classToInt(l.token); !ok {
|
||||||
|
t <- Token{Error: &ParseError{f, "unknown class", l}}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
st = _EXPECT_ANY_NOCLASS_BL
|
||||||
case _BLANK:
|
case _BLANK:
|
||||||
// Discard, can happen when there is nothing on the
|
// Discard, can happen when there is nothing on the
|
||||||
// line except the RR type
|
// line except the RR type
|
||||||
|
case _STRING: // First thing on the is the ttl
|
||||||
|
if ttl, ok := stringToTtl(l, f); !ok {
|
||||||
|
t <- Token{Error: &ParseError{f, "not a TTL", l}}
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
h.Ttl = ttl
|
||||||
|
defttl = ttl
|
||||||
|
}
|
||||||
|
st = _EXPECT_ANY_NOTTL_BL
|
||||||
|
|
||||||
default:
|
default:
|
||||||
t <- Token{Error: &ParseError{f, "syntax error at beginning", l}}
|
t <- Token{Error: &ParseError{f, "syntax error at beginning", l}}
|
||||||
return
|
return
|
||||||
|
@ -485,8 +504,7 @@ func zlexer(s *scan, c chan lex) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if stri == 0 {
|
if stri == 0 {
|
||||||
//l.value = _BLANK
|
// Space directly as the beginnin, handled in the grammar
|
||||||
//l.token = " "
|
|
||||||
} else if owner {
|
} else if owner {
|
||||||
// If we have a string and its the first, make it an owner
|
// If we have a string and its the first, make it an owner
|
||||||
l.value = _OWNER
|
l.value = _OWNER
|
||||||
|
@ -573,6 +591,7 @@ func zlexer(s *scan, c chan lex) {
|
||||||
stri = 0
|
stri = 0
|
||||||
// If not in a brace this ends the comment AND the RR
|
// If not in a brace this ends the comment AND the RR
|
||||||
if brace == 0 {
|
if brace == 0 {
|
||||||
|
owner = true
|
||||||
owner = true
|
owner = true
|
||||||
l.value = _NEWLINE
|
l.value = _NEWLINE
|
||||||
l.token = "\n"
|
l.token = "\n"
|
||||||
|
|
Loading…
Reference in New Issue