Make (some) commments normative in zonefiles
This commit is contained in:
parent
525465db6d
commit
7b7eaaa4b0
|
@ -706,16 +706,23 @@ func TestILNP(t *testing.T) {
|
||||||
|
|
||||||
func TestComment(t *testing.T) {
|
func TestComment(t *testing.T) {
|
||||||
zone := `
|
zone := `
|
||||||
foo. IN A 10.0.0.1 ; this is a comment1
|
foo. IN A 10.0.0.1 ; this is comment1
|
||||||
foo. IN A (
|
foo. IN A (
|
||||||
10.0.0.2 ; this is a comment2
|
10.0.0.2 ; this is comment2
|
||||||
)
|
)
|
||||||
; this is a comment3
|
; this is comment3
|
||||||
foo. IN A 10.0.0.3
|
foo. IN A 10.0.0.3
|
||||||
|
foo. IN A ( 10.0.0.4 ); this is comment4
|
||||||
|
|
||||||
|
foo. IN A 10.0.0.5
|
||||||
|
; this is comment5
|
||||||
|
|
||||||
|
foo. IN A 10.0.0.6
|
||||||
`
|
`
|
||||||
|
// TODO(mg): Need to figure out what to test here
|
||||||
for x := range ParseZone(strings.NewReader(zone), ".", "") {
|
for x := range ParseZone(strings.NewReader(zone), ".", "") {
|
||||||
if x.Error == nil {
|
if x.Error == nil {
|
||||||
fmt.Printf("%s\n", x.RR.String())
|
t.Logf("%s:%s\n", x.RR.String(), x.Comment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
26
zscan.go
26
zscan.go
|
@ -94,8 +94,9 @@ type lex struct {
|
||||||
|
|
||||||
// Tokens are returned when a zone file is parsed.
|
// Tokens are returned when a zone file is parsed.
|
||||||
type Token struct {
|
type Token struct {
|
||||||
RR // the scanned resource record when error is not nil
|
RR // the scanned resource record when error is not nil
|
||||||
Error *ParseError // when an error occured, this has the error specifics
|
Error *ParseError // when an error occured, this has the error specifics
|
||||||
|
Comment string // A potential comment positioned after the RR
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRR reads the RR contained in the string s. Only the first RR is returned.
|
// NewRR reads the RR contained in the string s. Only the first RR is returned.
|
||||||
|
@ -119,7 +120,7 @@ func ReadRR(q io.Reader, filename string) (RR, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseZone reads a RFC 1035 style one from r. It returns Tokens on the
|
// ParseZone reads a RFC 1035 style one from r. It returns Tokens on the
|
||||||
// returned channel, which consist out the parsed RR or an error.
|
// returned channel, which consist out the parsed RR, a potential comment or an error.
|
||||||
// If there is an error the RR is nil. The string file is only used
|
// If there is an error the RR is nil. The string file is only used
|
||||||
// in error reporting. The string origin is used as the initial origin, as
|
// in error reporting. The string origin is used as the initial origin, as
|
||||||
// if the file would start with: $ORIGIN origin .
|
// if the file would start with: $ORIGIN origin .
|
||||||
|
@ -133,7 +134,14 @@ func ReadRR(q io.Reader, filename string) (RR, error) {
|
||||||
// if x.Error != nil {
|
// if x.Error != nil {
|
||||||
// // Do something with x.RR
|
// // Do something with x.RR
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// Comments specified after an RR are returned too:
|
||||||
|
//
|
||||||
|
// foo. IN A 10.0.0.1 ; this is a comment
|
||||||
|
//
|
||||||
|
// The text "; this is comment" is returned in Token.comment . Comments inside,
|
||||||
|
// before or after the RR are discarded.
|
||||||
func ParseZone(r io.Reader, origin, file string) chan Token {
|
func ParseZone(r io.Reader, origin, file string) chan Token {
|
||||||
return parseZoneHelper(r, origin, file, 10000)
|
return parseZoneHelper(r, origin, file, 10000)
|
||||||
}
|
}
|
||||||
|
@ -443,7 +451,7 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
|
||||||
h.Rrtype = l.torc
|
h.Rrtype = l.torc
|
||||||
st = _EXPECT_RDATA
|
st = _EXPECT_RDATA
|
||||||
case _EXPECT_RDATA:
|
case _EXPECT_RDATA:
|
||||||
r, e := setRR(h, c, origin, f)
|
r, e, c1 := setRR(h, c, origin, f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
// If e.lex is nil than we have encounter a unknown RR type
|
// If e.lex is nil than we have encounter a unknown RR type
|
||||||
// in that case we substitute our current lex token
|
// in that case we substitute our current lex token
|
||||||
|
@ -453,7 +461,7 @@ func parseZone(r io.Reader, origin, f string, t chan Token, include int) {
|
||||||
t <- Token{Error: e}
|
t <- Token{Error: e}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t <- Token{RR: r}
|
t <- Token{RR: r, Comment: c1}
|
||||||
st = _EXPECT_OWNER_DIR
|
st = _EXPECT_OWNER_DIR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -631,6 +639,7 @@ func zlexer(s *scan, c chan lex) {
|
||||||
l.comment = string(com[:comi])
|
l.comment = string(com[:comi])
|
||||||
debug.Printf("[3 %+v %+v]", l.token, l.comment)
|
debug.Printf("[3 %+v %+v]", l.token, l.comment)
|
||||||
c <- l
|
c <- l
|
||||||
|
l.comment = ""
|
||||||
comi = 0
|
comi = 0
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -882,18 +891,21 @@ func locCheckEast(token string, longitude uint32) (uint32, bool) {
|
||||||
// "Eat" the rest of the "line". Return potential comments
|
// "Eat" the rest of the "line". Return potential comments
|
||||||
func slurpRemainder(c chan lex, f string) (*ParseError, string) {
|
func slurpRemainder(c chan lex, f string) (*ParseError, string) {
|
||||||
l := <-c
|
l := <-c
|
||||||
|
com := ""
|
||||||
switch l.value {
|
switch l.value {
|
||||||
case _BLANK:
|
case _BLANK:
|
||||||
l = <-c
|
l = <-c
|
||||||
|
com = l.comment
|
||||||
if l.value != _NEWLINE && l.value != _EOF {
|
if l.value != _NEWLINE && l.value != _EOF {
|
||||||
return &ParseError{f, "garbage after rdata", l}, ""
|
return &ParseError{f, "garbage after rdata", l}, ""
|
||||||
}
|
}
|
||||||
case _NEWLINE:
|
case _NEWLINE:
|
||||||
|
com = l.comment
|
||||||
case _EOF:
|
case _EOF:
|
||||||
default:
|
default:
|
||||||
return &ParseError{f, "garbage after rdata", l}, ""
|
return &ParseError{f, "garbage after rdata", l}, ""
|
||||||
}
|
}
|
||||||
return nil, l.comment
|
return nil, com
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse a 64 bit-like ipv6 address: "0014:4fff:ff20:ee64"
|
// Parse a 64 bit-like ipv6 address: "0014:4fff:ff20:ee64"
|
||||||
|
|
267
zscan_rr.go
267
zscan_rr.go
|
@ -148,10 +148,11 @@ Slurp:
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e, ""
|
return nil, e, ""
|
||||||
}
|
}
|
||||||
if se, com := slurpRemainder(c, f); se != nil {
|
se, com := slurpRemainder(c, f)
|
||||||
return nil, se, com
|
if se != nil {
|
||||||
|
return nil, se, ""
|
||||||
}
|
}
|
||||||
return r, e, ""
|
return r, e, com
|
||||||
}
|
}
|
||||||
|
|
||||||
// A remainder of the rdata with embedded spaces, return the parsed string (sans the spaces)
|
// A remainder of the rdata with embedded spaces, return the parsed string (sans the spaces)
|
||||||
|
@ -978,14 +979,14 @@ Altitude:
|
||||||
return rr, nil
|
return rr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
rr := new(HIP)
|
rr := new(HIP)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
// HitLength is not represented
|
// HitLength is not represented
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad HIP PublicKeyAlgorithm", l}
|
return nil, &ParseError{f, "bad HIP PublicKeyAlgorithm", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.PublicKeyAlgorithm = uint8(i)
|
rr.PublicKeyAlgorithm = uint8(i)
|
||||||
}
|
}
|
||||||
|
@ -1011,7 +1012,7 @@ func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
}
|
}
|
||||||
_, ld, ok := IsDomainName(l.token)
|
_, ld, ok := IsDomainName(l.token)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ParseError{f, "bad HIP RendezvousServers", l}
|
return nil, &ParseError{f, "bad HIP RendezvousServers", l}, ""
|
||||||
}
|
}
|
||||||
if l.token[ld-1] != '.' {
|
if l.token[ld-1] != '.' {
|
||||||
l.token = appendOrigin(l.token, o)
|
l.token = appendOrigin(l.token, o)
|
||||||
|
@ -1020,94 +1021,94 @@ func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
case _BLANK:
|
case _BLANK:
|
||||||
// Ok
|
// Ok
|
||||||
default:
|
default:
|
||||||
return nil, &ParseError{f, "bad HIP RendezvousServers", l}
|
return nil, &ParseError{f, "bad HIP RendezvousServers", l}, ""
|
||||||
}
|
}
|
||||||
l = <-c
|
l = <-c
|
||||||
}
|
}
|
||||||
rr.RendezvousServers = xs
|
rr.RendezvousServers = xs
|
||||||
return rr, nil
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func setCERT(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
func setCERT(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
rr := new(CERT)
|
rr := new(CERT)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad CERT Type", l}
|
return nil, &ParseError{f, "bad CERT Type", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Type = uint16(i)
|
rr.Type = uint16(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c // _STRING
|
l = <-c // _STRING
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad NAPTR KeyTag", l}
|
return nil, &ParseError{f, "bad NAPTR KeyTag", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c // _STRING
|
l = <-c // _STRING
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad NAPTR Algorithm", l}
|
return nil, &ParseError{f, "bad NAPTR Algorithm", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = uint8(i)
|
rr.Algorithm = uint8(i)
|
||||||
}
|
}
|
||||||
s, e := endingToString(c, "bad NAPTR Certificate", f)
|
s, e,c1 := endingToString(c, "bad NAPTR Certificate", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.Certificate = s
|
rr.Certificate = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
rr := new(RRSIG)
|
rr := new(RRSIG)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
l := <-c
|
l := <-c
|
||||||
if t, ok := StringToType[strings.ToUpper(l.token)]; !ok {
|
if t, ok := StringToType[strings.ToUpper(l.token)]; !ok {
|
||||||
return nil, &ParseError{f, "bad RRSIG Typecovered", l}
|
return nil, &ParseError{f, "bad RRSIG Typecovered", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.TypeCovered = t
|
rr.TypeCovered = t
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := strconv.Atoi(l.token); err != nil {
|
if i, err := strconv.Atoi(l.token); err != nil {
|
||||||
return nil, &ParseError{f, "bad RRSIG Algorithm", l}
|
return nil, &ParseError{f, "bad RRSIG Algorithm", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = uint8(i)
|
rr.Algorithm = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := strconv.Atoi(l.token); err != nil {
|
if i, err := strconv.Atoi(l.token); err != nil {
|
||||||
return nil, &ParseError{f, "bad RRSIG Labels", l}
|
return nil, &ParseError{f, "bad RRSIG Labels", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Labels = uint8(i)
|
rr.Labels = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := strconv.Atoi(l.token); err != nil {
|
if i, err := strconv.Atoi(l.token); err != nil {
|
||||||
return nil, &ParseError{f, "bad RRSIG OrigTtl", l}
|
return nil, &ParseError{f, "bad RRSIG OrigTtl", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.OrigTtl = uint32(i)
|
rr.OrigTtl = uint32(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := StringToTime(l.token); err != nil {
|
if i, err := StringToTime(l.token); err != nil {
|
||||||
return nil, &ParseError{f, "bad RRSIG Expiration", l}
|
return nil, &ParseError{f, "bad RRSIG Expiration", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Expiration = i
|
rr.Expiration = i
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := StringToTime(l.token); err != nil {
|
if i, err := StringToTime(l.token); err != nil {
|
||||||
return nil, &ParseError{f, "bad RRSIG Inception", l}
|
return nil, &ParseError{f, "bad RRSIG Inception", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Inception = i
|
rr.Inception = i
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := strconv.Atoi(l.token); err != nil {
|
if i, err := strconv.Atoi(l.token); err != nil {
|
||||||
return nil, &ParseError{f, "bad RRSIG KeyTag", l}
|
return nil, &ParseError{f, "bad RRSIG KeyTag", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
}
|
}
|
||||||
|
@ -1119,21 +1120,21 @@ func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
} else {
|
} else {
|
||||||
_, ld, ok := IsDomainName(l.token)
|
_, ld, ok := IsDomainName(l.token)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ParseError{f, "bad RRSIG SignerName", l}
|
return nil, &ParseError{f, "bad RRSIG SignerName", l}, ""
|
||||||
}
|
}
|
||||||
if rr.SignerName[ld-1] != '.' {
|
if rr.SignerName[ld-1] != '.' {
|
||||||
rr.SignerName = appendOrigin(rr.SignerName, o)
|
rr.SignerName = appendOrigin(rr.SignerName, o)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s, e := endingToString(c, "bad RRSIG Signature", f)
|
s, e, c1 := endingToString(c, "bad RRSIG Signature", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e,c1
|
||||||
}
|
}
|
||||||
rr.Signature = s
|
rr.Signature = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
rr := new(NSEC)
|
rr := new(NSEC)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
|
@ -1144,7 +1145,7 @@ func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
} else {
|
} else {
|
||||||
_, ld, ok := IsDomainName(l.token)
|
_, ld, ok := IsDomainName(l.token)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, &ParseError{f, "bad NSEC NextDomain", l}
|
return nil, &ParseError{f, "bad NSEC NextDomain", l}, ""
|
||||||
}
|
}
|
||||||
if rr.NextDomain[ld-1] != '.' {
|
if rr.NextDomain[ld-1] != '.' {
|
||||||
rr.NextDomain = appendOrigin(rr.NextDomain, o)
|
rr.NextDomain = appendOrigin(rr.NextDomain, o)
|
||||||
|
@ -1164,46 +1165,46 @@ func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
case _STRING:
|
case _STRING:
|
||||||
if k, ok = StringToType[strings.ToUpper(l.token)]; !ok {
|
if k, ok = StringToType[strings.ToUpper(l.token)]; !ok {
|
||||||
if k, ok = typeToInt(l.token); !ok {
|
if k, ok = typeToInt(l.token); !ok {
|
||||||
return nil, &ParseError{f, "bad NSEC TypeBitMap", l}
|
return nil, &ParseError{f, "bad NSEC TypeBitMap", l}, ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rr.TypeBitMap = append(rr.TypeBitMap, k)
|
rr.TypeBitMap = append(rr.TypeBitMap, k)
|
||||||
default:
|
default:
|
||||||
return nil, &ParseError{f, "bad NSEC TypeBitMap", l}
|
return nil, &ParseError{f, "bad NSEC TypeBitMap", l}, ""
|
||||||
}
|
}
|
||||||
l = <-c
|
l = <-c
|
||||||
}
|
}
|
||||||
return rr, nil
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
rr := new(NSEC3)
|
rr := new(NSEC3)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad NSEC3 Hash", l}
|
return nil, &ParseError{f, "bad NSEC3 Hash", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Hash = uint8(i)
|
rr.Hash = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad NSEC3 Flags", l}
|
return nil, &ParseError{f, "bad NSEC3 Flags", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Flags = uint8(i)
|
rr.Flags = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad NSEC3 Iterations", l}
|
return nil, &ParseError{f, "bad NSEC3 Iterations", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Iterations = uint16(i)
|
rr.Iterations = uint16(i)
|
||||||
}
|
}
|
||||||
<-c
|
<-c
|
||||||
l = <-c
|
l = <-c
|
||||||
if len(l.token) == 0 {
|
if len(l.token) == 0 {
|
||||||
return nil, &ParseError{f, "bad NSEC3 Salt", l}
|
return nil, &ParseError{f, "bad NSEC3 Salt", l}, ""
|
||||||
}
|
}
|
||||||
rr.SaltLength = uint8(len(l.token)) / 2
|
rr.SaltLength = uint8(len(l.token)) / 2
|
||||||
rr.Salt = l.token
|
rr.Salt = l.token
|
||||||
|
@ -1226,39 +1227,39 @@ func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
case _STRING:
|
case _STRING:
|
||||||
if k, ok = StringToType[strings.ToUpper(l.token)]; !ok {
|
if k, ok = StringToType[strings.ToUpper(l.token)]; !ok {
|
||||||
if k, ok = typeToInt(l.token); !ok {
|
if k, ok = typeToInt(l.token); !ok {
|
||||||
return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}
|
return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}, ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rr.TypeBitMap = append(rr.TypeBitMap, k)
|
rr.TypeBitMap = append(rr.TypeBitMap, k)
|
||||||
default:
|
default:
|
||||||
return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}
|
return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}, ""
|
||||||
}
|
}
|
||||||
l = <-c
|
l = <-c
|
||||||
}
|
}
|
||||||
return rr, nil
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func setNSEC3PARAM(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setNSEC3PARAM(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(NSEC3PARAM)
|
rr := new(NSEC3PARAM)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad NSEC3PARAM Hash", l}
|
return nil, &ParseError{f, "bad NSEC3PARAM Hash", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Hash = uint8(i)
|
rr.Hash = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad NSEC3PARAM Flags", l}
|
return nil, &ParseError{f, "bad NSEC3PARAM Flags", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Flags = uint8(i)
|
rr.Flags = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad NSEC3PARAM Iterations", l}
|
return nil, &ParseError{f, "bad NSEC3PARAM Iterations", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Iterations = uint16(i)
|
rr.Iterations = uint16(i)
|
||||||
}
|
}
|
||||||
|
@ -1266,24 +1267,24 @@ func setNSEC3PARAM(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
l = <-c
|
l = <-c
|
||||||
rr.SaltLength = uint8(len(l.token))
|
rr.SaltLength = uint8(len(l.token))
|
||||||
rr.Salt = l.token
|
rr.Salt = l.token
|
||||||
return rr, nil
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func setWKS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setWKS(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(WKS)
|
rr := new(WKS)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
rr.Address = net.ParseIP(l.token)
|
rr.Address = net.ParseIP(l.token)
|
||||||
if rr.Address == nil {
|
if rr.Address == nil {
|
||||||
return nil, &ParseError{f, "bad WKS Adress", l}
|
return nil, &ParseError{f, "bad WKS Adress", l}, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
proto := "tcp"
|
proto := "tcp"
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad WKS Protocol", l}
|
return nil, &ParseError{f, "bad WKS Protocol", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Protocol = uint8(i)
|
rr.Protocol = uint8(i)
|
||||||
switch rr.Protocol {
|
switch rr.Protocol {
|
||||||
|
@ -1292,7 +1293,7 @@ func setWKS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
case 6:
|
case 6:
|
||||||
proto = "tcp"
|
proto = "tcp"
|
||||||
default:
|
default:
|
||||||
return nil, &ParseError{f, "bad WKS Protocol", l}
|
return nil, &ParseError{f, "bad WKS Protocol", l}, ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1312,16 +1313,16 @@ func setWKS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
if i, e := strconv.Atoi(l.token); e != nil { // If a number use that
|
if i, e := strconv.Atoi(l.token); e != nil { // If a number use that
|
||||||
rr.BitMap = append(rr.BitMap, uint16(i))
|
rr.BitMap = append(rr.BitMap, uint16(i))
|
||||||
} else {
|
} else {
|
||||||
return nil, &ParseError{f, "bad WKS BitMap", l}
|
return nil, &ParseError{f, "bad WKS BitMap", l}, ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rr.BitMap = append(rr.BitMap, uint16(k))
|
rr.BitMap = append(rr.BitMap, uint16(k))
|
||||||
default:
|
default:
|
||||||
return nil, &ParseError{f, "bad WKS BitMap", l}
|
return nil, &ParseError{f, "bad WKS BitMap", l}, ""
|
||||||
}
|
}
|
||||||
l = <-c
|
l = <-c
|
||||||
}
|
}
|
||||||
return rr, nil
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func setSSHFP(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setSSHFP(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
|
@ -1347,76 +1348,76 @@ func setSSHFP(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
return rr, nil
|
return rr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDNSKEY(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setDNSKEY(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(DNSKEY)
|
rr := new(DNSKEY)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad DNSKEY Flags", l}
|
return nil, &ParseError{f, "bad DNSKEY Flags", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Flags = uint16(i)
|
rr.Flags = uint16(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c // _STRING
|
l = <-c // _STRING
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad DNSKEY Protocol", l}
|
return nil, &ParseError{f, "bad DNSKEY Protocol", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Protocol = uint8(i)
|
rr.Protocol = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c // _STRING
|
l = <-c // _STRING
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad DNSKEY Algorithm", l}
|
return nil, &ParseError{f, "bad DNSKEY Algorithm", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = uint8(i)
|
rr.Algorithm = uint8(i)
|
||||||
}
|
}
|
||||||
s, e := endingToString(c, "bad DNSKEY PublicKey", f)
|
s, e, c1 := endingToString(c, "bad DNSKEY PublicKey", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.PublicKey = s
|
rr.PublicKey = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setRKEY(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setRKEY(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(RKEY)
|
rr := new(RKEY)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad RKEY Flags", l}
|
return nil, &ParseError{f, "bad RKEY Flags", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Flags = uint16(i)
|
rr.Flags = uint16(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c // _STRING
|
l = <-c // _STRING
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad RKEY Protocol", l}
|
return nil, &ParseError{f, "bad RKEY Protocol", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Protocol = uint8(i)
|
rr.Protocol = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c // _STRING
|
l = <-c // _STRING
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad RKEY Algorithm", l}
|
return nil, &ParseError{f, "bad RKEY Algorithm", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = uint8(i)
|
rr.Algorithm = uint8(i)
|
||||||
}
|
}
|
||||||
s, e := endingToString(c, "bad RKEY PublicKey", f)
|
s, e, c1 := endingToString(c, "bad RKEY PublicKey", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.PublicKey = s
|
rr.PublicKey = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setDS(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(DS)
|
rr := new(DS)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad DS KeyTag", l}
|
return nil, &ParseError{f, "bad DS KeyTag", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
}
|
}
|
||||||
|
@ -1424,7 +1425,7 @@ func setDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
|
if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
|
||||||
return nil, &ParseError{f, "bad DS Algorithm", l}
|
return nil, &ParseError{f, "bad DS Algorithm", l},""
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = i
|
rr.Algorithm = i
|
||||||
}
|
}
|
||||||
|
@ -1434,24 +1435,24 @@ func setDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad DS DigestType", l}
|
return nil, &ParseError{f, "bad DS DigestType", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.DigestType = uint8(i)
|
rr.DigestType = uint8(i)
|
||||||
}
|
}
|
||||||
s, e := endingToString(c, "bad DS Digest", f)
|
s, e, c1 := endingToString(c, "bad DS Digest", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.Digest = s
|
rr.Digest = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setCDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setCDS(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(CDS)
|
rr := new(CDS)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad CDS KeyTag", l}
|
return nil, &ParseError{f, "bad CDS KeyTag", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
}
|
}
|
||||||
|
@ -1459,7 +1460,7 @@ func setCDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
|
if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
|
||||||
return nil, &ParseError{f, "bad CDS Algorithm", l}
|
return nil, &ParseError{f, "bad CDS Algorithm", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = i
|
rr.Algorithm = i
|
||||||
}
|
}
|
||||||
|
@ -1469,24 +1470,24 @@ func setCDS(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad CDS DigestType", l}
|
return nil, &ParseError{f, "bad CDS DigestType", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.DigestType = uint8(i)
|
rr.DigestType = uint8(i)
|
||||||
}
|
}
|
||||||
s, e := endingToString(c, "bad CDS Digest", f)
|
s, e, c1 := endingToString(c, "bad CDS Digest", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.Digest = s
|
rr.Digest = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDLV(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setDLV(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(DLV)
|
rr := new(DLV)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad DLV KeyTag", l}
|
return nil, &ParseError{f, "bad DLV KeyTag", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
}
|
}
|
||||||
|
@ -1494,7 +1495,7 @@ func setDLV(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
|
if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
|
||||||
return nil, &ParseError{f, "bad DLV Algorithm", l}
|
return nil, &ParseError{f, "bad DLV Algorithm", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = i
|
rr.Algorithm = i
|
||||||
}
|
}
|
||||||
|
@ -1504,24 +1505,24 @@ func setDLV(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad DLV DigestType", l}
|
return nil, &ParseError{f, "bad DLV DigestType", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.DigestType = uint8(i)
|
rr.DigestType = uint8(i)
|
||||||
}
|
}
|
||||||
s, e := endingToString(c, "bad DLV Digest", f)
|
s, e, c1 := endingToString(c, "bad DLV Digest", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.Digest = s
|
rr.Digest = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setTA(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(TA)
|
rr := new(TA)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad TA KeyTag", l}
|
return nil, &ParseError{f, "bad TA KeyTag", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
}
|
}
|
||||||
|
@ -1529,7 +1530,7 @@ func setTA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
|
if i, ok := StringToAlgorithm[strings.ToUpper(l.token)]; !ok {
|
||||||
return nil, &ParseError{f, "bad TA Algorithm", l}
|
return nil, &ParseError{f, "bad TA Algorithm", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = i
|
rr.Algorithm = i
|
||||||
}
|
}
|
||||||
|
@ -1539,126 +1540,126 @@ func setTA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad TA DigestType", l}
|
return nil, &ParseError{f, "bad TA DigestType", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.DigestType = uint8(i)
|
rr.DigestType = uint8(i)
|
||||||
}
|
}
|
||||||
s, e := endingToString(c, "bad TA Digest", f)
|
s, e, c1 := endingToString(c, "bad TA Digest", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.Digest = s
|
rr.Digest = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTLSA(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setTLSA(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(TLSA)
|
rr := new(TLSA)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad TLSA Usage", l}
|
return nil, &ParseError{f, "bad TLSA Usage", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Usage = uint8(i)
|
rr.Usage = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad TLSA Selector", l}
|
return nil, &ParseError{f, "bad TLSA Selector", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Selector = uint8(i)
|
rr.Selector = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad TLSA MatchingType", l}
|
return nil, &ParseError{f, "bad TLSA MatchingType", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.MatchingType = uint8(i)
|
rr.MatchingType = uint8(i)
|
||||||
}
|
}
|
||||||
s, e := endingToString(c, "bad TLSA Certificate", f)
|
s, e, c1 := endingToString(c, "bad TLSA Certificate", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.Certificate = s
|
rr.Certificate = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setRFC3597(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setRFC3597(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(RFC3597)
|
rr := new(RFC3597)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
l := <-c
|
l := <-c
|
||||||
if l.token != "\\#" {
|
if l.token != "\\#" {
|
||||||
return nil, &ParseError{f, "unkown RR type", l}
|
return nil, &ParseError{f, "unkown RR type", l}, ""
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
rdlength, e := strconv.Atoi(l.token)
|
rdlength, e := strconv.Atoi(l.token)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, &ParseError{f, "bad RFC3597 Rdata", l}
|
return nil, &ParseError{f, "bad RFC3597 Rdata", l}, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
s, e1 := endingToString(c, "bad RFC3597 Rdata", f)
|
s, e1, c1 := endingToString(c, "bad RFC3597 Rdata", f)
|
||||||
if e1 != nil {
|
if e1 != nil {
|
||||||
return nil, e1
|
return nil, e1, c1
|
||||||
}
|
}
|
||||||
if rdlength*2 != len(s) {
|
if rdlength*2 != len(s) {
|
||||||
return nil, &ParseError{f, "bad RFC3597 Rdata", l}
|
return nil, &ParseError{f, "bad RFC3597 Rdata", l}, ""
|
||||||
}
|
}
|
||||||
rr.Rdata = s
|
rr.Rdata = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setSPF(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setSPF(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(SPF)
|
rr := new(SPF)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
s, e := endingToTxtSlice(c, "bad SPF Txt", f)
|
s, e := endingToTxtSlice(c, "bad SPF Txt", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, ""
|
||||||
}
|
}
|
||||||
rr.Txt = s
|
rr.Txt = s
|
||||||
return rr, nil
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTXT(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setTXT(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(TXT)
|
rr := new(TXT)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
// No _BLANK reading here, because this is all rdata is TXT
|
// No _BLANK reading here, because this is all rdata is TXT
|
||||||
s, e := endingToTxtSlice(c, "bad TXT Txt", f)
|
s, e := endingToTxtSlice(c, "bad TXT Txt", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, ""
|
||||||
}
|
}
|
||||||
rr.Txt = s
|
rr.Txt = s
|
||||||
return rr, nil
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// identical to setTXT
|
// identical to setTXT
|
||||||
func setNINFO(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setNINFO(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(NINFO)
|
rr := new(NINFO)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
s, e := endingToTxtSlice(c, "bad NINFO ZSData", f)
|
s, e := endingToTxtSlice(c, "bad NINFO ZSData", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, ""
|
||||||
}
|
}
|
||||||
rr.ZSData = s
|
rr.ZSData = s
|
||||||
return rr, nil
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func setURI(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setURI(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
rr := new(URI)
|
rr := new(URI)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad URI Priority", l}
|
return nil, &ParseError{f, "bad URI Priority", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Priority = uint16(i)
|
rr.Priority = uint16(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad URI Weight", l}
|
return nil, &ParseError{f, "bad URI Weight", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Weight = uint16(i)
|
rr.Weight = uint16(i)
|
||||||
}
|
}
|
||||||
|
@ -1666,58 +1667,58 @@ func setURI(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
s, e := endingToTxtSlice(c, "bad URI Target", f)
|
s, e := endingToTxtSlice(c, "bad URI Target", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, ""
|
||||||
}
|
}
|
||||||
rr.Target = s
|
rr.Target = s
|
||||||
return rr, nil
|
return rr, nil, ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func setIPSECKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
func setIPSECKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
|
||||||
rr := new(IPSECKEY)
|
rr := new(IPSECKEY)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad IPSECKEY Precedence", l}
|
return nil, &ParseError{f, "bad IPSECKEY Precedence", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Precedence = uint8(i)
|
rr.Precedence = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad IPSECKEY GatewayType", l}
|
return nil, &ParseError{f, "bad IPSECKEY GatewayType", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.GatewayType = uint8(i)
|
rr.GatewayType = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e := strconv.Atoi(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{f, "bad IPSECKEY Algorithm", l}
|
return nil, &ParseError{f, "bad IPSECKEY Algorithm", l}, ""
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = uint8(i)
|
rr.Algorithm = uint8(i)
|
||||||
}
|
}
|
||||||
<-c
|
<-c
|
||||||
l = <-c
|
l = <-c
|
||||||
rr.Gateway = l.token
|
rr.Gateway = l.token
|
||||||
s, e := endingToString(c, "bad IPSECKEY PublicKey", f)
|
s, e, c1 := endingToString(c, "bad IPSECKEY PublicKey", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.PublicKey = s
|
rr.PublicKey = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDHCID(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setDHCID(h RR_Header, c chan lex, f string) (RR, *ParseError, string) {
|
||||||
// awesome record to parse!
|
// awesome record to parse!
|
||||||
rr := new(DHCID)
|
rr := new(DHCID)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
s, e := endingToString(c, "bad DHCID Digest", f)
|
s, e, c1 := endingToString(c, "bad DHCID Digest", f)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return nil, e
|
return nil, e, c1
|
||||||
}
|
}
|
||||||
rr.Digest = s
|
rr.Digest = s
|
||||||
return rr, nil
|
return rr, nil, c1
|
||||||
}
|
}
|
||||||
|
|
||||||
func setNID(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
func setNID(h RR_Header, c chan lex, f string) (RR, *ParseError) {
|
||||||
|
|
Loading…
Reference in New Issue