Get started for the LOC record
This commit is contained in:
parent
8ff38fb8c1
commit
c2e99e8b41
33
zscan.go
33
zscan.go
|
@ -148,15 +148,15 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
|
||||||
if origin == "" {
|
if origin == "" {
|
||||||
origin = "."
|
origin = "."
|
||||||
}
|
}
|
||||||
if !IsFqdn(origin) {
|
if !IsFqdn(origin) {
|
||||||
t <- Token{Error: &ParseError{f, "bad initial origin name", lex{}}}
|
t <- Token{Error: &ParseError{f, "bad initial origin name", lex{}}}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if _, _, ok := IsDomainName(origin); !ok {
|
if _, _, ok := IsDomainName(origin); !ok {
|
||||||
t <- Token{Error: &ParseError{f, "bad initial origin name", lex{}}}
|
t <- Token{Error: &ParseError{f, "bad initial origin name", lex{}}}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
st := _EXPECT_OWNER_DIR // initial state
|
st := _EXPECT_OWNER_DIR // initial state
|
||||||
var h RR_Header
|
var h RR_Header
|
||||||
var ok bool
|
var ok bool
|
||||||
var defttl uint32 = DefaultTtl
|
var defttl uint32 = DefaultTtl
|
||||||
|
@ -321,7 +321,7 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
|
||||||
st = _EXPECT_ANY_NOCLASS_BL
|
st = _EXPECT_ANY_NOCLASS_BL
|
||||||
case _STRING: // TTL is this case
|
case _STRING: // TTL is this case
|
||||||
if ttl, ok := stringToTtl(l, f); !ok {
|
if ttl, ok := stringToTtl(l, f); !ok {
|
||||||
t <- Token{Error: &ParseError{f, "not a TTL", l}}
|
t <- Token{Error: &ParseError{f, "not a TTL", l}}
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
h.Ttl = ttl
|
h.Ttl = ttl
|
||||||
|
@ -369,7 +369,7 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
|
||||||
switch l.value {
|
switch l.value {
|
||||||
case _STRING: // TTL
|
case _STRING: // TTL
|
||||||
if ttl, ok := stringToTtl(l, f); !ok {
|
if ttl, ok := stringToTtl(l, f); !ok {
|
||||||
t <- Token{Error: &ParseError{f, "not a TTL", l}}
|
t <- Token{Error: &ParseError{f, "not a TTL", l}}
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
h.Ttl = ttl
|
h.Ttl = ttl
|
||||||
|
@ -752,3 +752,22 @@ func appendOrigin(name, origin string) string {
|
||||||
}
|
}
|
||||||
return name + "." + origin
|
return name + "." + origin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func slurpRemainder(c chan lex, f string) *ParseError {
|
||||||
|
l := <-c
|
||||||
|
switch l.value {
|
||||||
|
case _BLANK:
|
||||||
|
l = <-c
|
||||||
|
if l.value != _NEWLINE && l.value != _EOF {
|
||||||
|
return &ParseError{f, "garbage after rdata", l}
|
||||||
|
}
|
||||||
|
// Ok
|
||||||
|
case _NEWLINE:
|
||||||
|
// Ok
|
||||||
|
case _EOF:
|
||||||
|
// Ok
|
||||||
|
default:
|
||||||
|
return &ParseError{f, "garbage after rdata", l}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
35
zscan_rr.go
35
zscan_rr.go
|
@ -6,14 +6,13 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: SPF, TKEY, RR_URI, DHCID, TLSA
|
// TODO: TKEY, RR_URI, DHCID
|
||||||
|
|
||||||
// Parse the rdata of each rrtype.
|
// Parse the rdata of each rrtype.
|
||||||
// All data from the channel c is either _STRING or _BLANK.
|
// All data from the channel c is either _STRING or _BLANK.
|
||||||
// After the rdata there may come 1 _BLANK and then a _NEWLINE
|
// After the rdata there may come 1 _BLANK and then a _NEWLINE
|
||||||
// or immediately a _NEWLINE. If this is not the case we flag
|
// or immediately a _NEWLINE. If this is not the case we flag
|
||||||
// an *ParseError: garbage after rdata.
|
// an *ParseError: garbage after rdata.
|
||||||
|
|
||||||
func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
var r RR
|
var r RR
|
||||||
e := new(ParseError)
|
e := new(ParseError)
|
||||||
|
@ -51,6 +50,9 @@ func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
case TypeNAPTR:
|
case TypeNAPTR:
|
||||||
r, e = setNAPTR(h, c, o, f)
|
r, e = setNAPTR(h, c, o, f)
|
||||||
goto Slurp
|
goto Slurp
|
||||||
|
case TypeLOC:
|
||||||
|
r, e = setLOC(h, c, f)
|
||||||
|
goto Slurp
|
||||||
// These types have a variable ending either chunks of txt or chunks/base64 or hex.
|
// These types have a variable ending either chunks of txt or chunks/base64 or hex.
|
||||||
// They need to search for the end of the RR themselves, hence they look for the ending
|
// They need to search for the end of the RR themselves, hence they look for the ending
|
||||||
// newline. Thus there is no need to slurp the remainder, because there is none.
|
// newline. Thus there is no need to slurp the remainder, because there is none.
|
||||||
|
@ -88,25 +90,6 @@ Slurp:
|
||||||
return r, e
|
return r, e
|
||||||
}
|
}
|
||||||
|
|
||||||
func slurpRemainder(c chan lex, f string) *ParseError {
|
|
||||||
l := <-c
|
|
||||||
switch l.value {
|
|
||||||
case _BLANK:
|
|
||||||
l = <-c
|
|
||||||
if l.value != _NEWLINE && l.value != _EOF {
|
|
||||||
return &ParseError{f, "garbage after rdata", l}
|
|
||||||
}
|
|
||||||
// Ok
|
|
||||||
case _NEWLINE:
|
|
||||||
// Ok
|
|
||||||
case _EOF:
|
|
||||||
// Ok
|
|
||||||
default:
|
|
||||||
return &ParseError{f, "garbage after rdata", l}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func setA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
rr := new(RR_A)
|
rr := new(RR_A)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
@ -949,3 +932,13 @@ func setIPSECKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
rr.PublicKey = s
|
rr.PublicKey = s
|
||||||
return rr, nil
|
return rr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setLOC(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
|
rr := new(RR_LOC)
|
||||||
|
rr.Hdr = h
|
||||||
|
// TODO
|
||||||
|
|
||||||
|
|
||||||
|
rr.Version = 0
|
||||||
|
return rr, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue