New zonefile parsing. Now it compiles
This commit is contained in:
parent
eda63f2a29
commit
7f5ed33fbd
75
zscan_rr.go
75
zscan_rr.go
|
@ -2,6 +2,8 @@ package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// All data from c is either _STRING or _BLANK
|
// All data from c is either _STRING or _BLANK
|
||||||
|
@ -87,11 +89,11 @@ func setMX(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
i, e := strconv.Atoui(l.token)
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
if e != nil {
|
|
||||||
return nil, &ParseError{"bad MX", l}
|
return nil, &ParseError{"bad MX", l}
|
||||||
}
|
} else {
|
||||||
rr.Pref = uint16(i)
|
rr.Pref = uint16(i)
|
||||||
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c // _STRING
|
l = <-c // _STRING
|
||||||
rr.Mx = l.token
|
rr.Mx = l.token
|
||||||
|
@ -118,10 +120,6 @@ func setSOA(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
var (
|
|
||||||
i uint
|
|
||||||
err os.Error
|
|
||||||
)
|
|
||||||
rr.Ns = l.token
|
rr.Ns = l.token
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
if ! IsDomainName(l.token) {
|
if ! IsDomainName(l.token) {
|
||||||
|
@ -131,13 +129,17 @@ func setSOA(h RR_Header, c chan Lex) (RR, error) {
|
||||||
l = <-c
|
l = <-c
|
||||||
rr.Mbox = l.token
|
rr.Mbox = l.token
|
||||||
if ! IsDomainName(l.token) {
|
if ! IsDomainName(l.token) {
|
||||||
return nil, &ParseError{Error: "bad SOA", name: rdf[1], line: l}
|
return nil, &ParseError{"bad SOA", l}
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
|
|
||||||
|
var (
|
||||||
|
j int
|
||||||
|
e error
|
||||||
|
)
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
l = <-c
|
l = <-c
|
||||||
if j, e = strconv.Atoui(s); e != nil {
|
if j, e = strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{"bad SOA", l}
|
return nil, &ParseError{"bad SOA", l}
|
||||||
}
|
}
|
||||||
switch i {
|
switch i {
|
||||||
|
@ -156,28 +158,28 @@ func setRRSIG(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr := new(RR_RRSIG)
|
rr := new(RR_RRSIG)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
l := <-c
|
l := <-c
|
||||||
if t, ok := str_rr[strings.ToUpper(l.token]; !ok {
|
if t, ok := Str_rr[strings.ToUpper(l.token)]; !ok {
|
||||||
return nil, &ParseError{"bad RRSIG", l}
|
return nil, &ParseError{"bad RRSIG", l}
|
||||||
} else {
|
} else {
|
||||||
rr.TypeCovered = t
|
rr.TypeCovered = t
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := strconv.Atoui(l.token); err != nil {
|
if i, err := strconv.Atoi(l.token); err != nil {
|
||||||
return nil, &ParseError{"bad RRSIG", l}
|
return nil, &ParseError{"bad RRSIG", l}
|
||||||
} else {
|
} else {
|
||||||
rr.Algorithm = uint8(i)
|
rr.Algorithm = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := strconv.Atoui(l.token); err != nil {
|
if i, err := strconv.Atoi(l.token); err != nil {
|
||||||
return nil, &ParseError{"bad RRSIG", l}
|
return nil, &ParseError{"bad RRSIG", l}
|
||||||
} else {
|
} else {
|
||||||
rr.Labels = uint8(i)
|
rr.Labels = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := strconv.Atoui(l.token); err != nil {
|
if i, err := strconv.Atoi(l.token); err != nil {
|
||||||
return nil, &ParseError{"bad RRSIG", l}
|
return nil, &ParseError{"bad RRSIG", l}
|
||||||
} else {
|
} else {
|
||||||
rr.OrigTtl = uint32(i)
|
rr.OrigTtl = uint32(i)
|
||||||
|
@ -198,7 +200,7 @@ func setRRSIG(h RR_Header, c chan Lex) (RR, error) {
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, err := strconv.Atoui(l.token); err != nil {
|
if i, err := strconv.Atoi(l.token); err != nil {
|
||||||
return nil, &ParseError{"bad RRSIG", l}
|
return nil, &ParseError{"bad RRSIG", l}
|
||||||
} else {
|
} else {
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
|
@ -242,17 +244,20 @@ func setNSEC(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr.TypeBitMap = make([]uint16, 0)
|
rr.TypeBitMap = make([]uint16, 0)
|
||||||
l = <-c
|
l = <-c
|
||||||
for l.value != _NEWLINE {
|
for l.value != _NEWLINE {
|
||||||
|
switch l.value {
|
||||||
case _BLANK:
|
case _BLANK:
|
||||||
// Ok
|
// Ok
|
||||||
case _STRING:
|
case _STRING:
|
||||||
if k, ok := str_rr[strings.ToUpper(l.token)]; !ok {
|
if k, ok := Str_rr[strings.ToUpper(l.token)]; !ok {
|
||||||
return nil, &ParseError{"bad NSEC", l}
|
return nil, &ParseError{"bad NSEC", l}
|
||||||
} else {
|
} else {
|
||||||
append(rr.TypeBitMap, k)
|
rr.TypeBitMap = append(rr.TypeBitMap, k)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil, &ParseError{"bad NSEC", l}
|
return nil, &ParseError{"bad NSEC", l}
|
||||||
}
|
}
|
||||||
|
l = <-c
|
||||||
|
}
|
||||||
return rr, nil
|
return rr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,21 +266,21 @@ func setNSEC3(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
||||||
l := <-c
|
l := <-c
|
||||||
if i, e = strconv.Atoui(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{"bad NSEC3", l}
|
return nil, &ParseError{"bad NSEC3", l}
|
||||||
} else {
|
} else {
|
||||||
rr.Hash = uint8(i)
|
rr.Hash = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e = strconv.Atoui(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{"bad NSEC3", l}
|
return nil, &ParseError{"bad NSEC3", l}
|
||||||
} else {
|
} else {
|
||||||
rr.Flags = uint8(i)
|
rr.Flags = uint8(i)
|
||||||
}
|
}
|
||||||
<-c // _BLANK
|
<-c // _BLANK
|
||||||
l = <-c
|
l = <-c
|
||||||
if i, e = strconv.Atoui(l.token); e != nil {
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
return nil, &ParseError{"bad NSEC3", l}
|
return nil, &ParseError{"bad NSEC3", l}
|
||||||
} else {
|
} else {
|
||||||
rr.Iterations = uint16(i)
|
rr.Iterations = uint16(i)
|
||||||
|
@ -293,17 +298,20 @@ func setNSEC3(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr.TypeBitMap = make([]uint16, 0)
|
rr.TypeBitMap = make([]uint16, 0)
|
||||||
l = <-c
|
l = <-c
|
||||||
for l.value != _NEWLINE {
|
for l.value != _NEWLINE {
|
||||||
|
switch l.value {
|
||||||
case _BLANK:
|
case _BLANK:
|
||||||
// Ok
|
// Ok
|
||||||
case _STRING:
|
case _STRING:
|
||||||
if k, ok := str_rr[strings.ToUpper(l.token)]; !ok {
|
if k, ok := Str_rr[strings.ToUpper(l.token)]; !ok {
|
||||||
return nil, &ParseError{"bad NSEC3", l}
|
return nil, &ParseError{"bad NSEC3", l}
|
||||||
} else {
|
} else {
|
||||||
append(rr.TypeBitMap, k)
|
rr.TypeBitMap = append(rr.TypeBitMap, k)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil, &ParseError{"bad NSEC3", l}
|
return nil, &ParseError{"bad NSEC3", l}
|
||||||
}
|
}
|
||||||
|
l = <-c
|
||||||
|
}
|
||||||
return rr, nil
|
return rr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,17 +376,17 @@ func setDS(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr := new(RR_DS)
|
rr := new(RR_DS)
|
||||||
rr.Hdr = hdr
|
rr.Hdr = hdr
|
||||||
rr.Hdr.Rrtype = TypeDS
|
rr.Hdr.Rrtype = TypeDS
|
||||||
if i, e = strconv.Atoui(rdf[0]); e != nil {
|
if i, e = strconv.Atoi(rdf[0]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DS", name: rdf[0], line: l}
|
zp.Err <- &ParseError{Error: "bad DS", name: rdf[0], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
if i, e = strconv.Atoui(rdf[1]); e != nil {
|
if i, e = strconv.Atoi(rdf[1]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DS", name: rdf[1], line: l}
|
zp.Err <- &ParseError{Error: "bad DS", name: rdf[1], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rr.Algorithm = uint8(i)
|
rr.Algorithm = uint8(i)
|
||||||
if i, e = strconv.Atoui(rdf[2]); e != nil {
|
if i, e = strconv.Atoi(rdf[2]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DS", name: rdf[2], line: l}
|
zp.Err <- &ParseError{Error: "bad DS", name: rdf[2], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -399,17 +407,17 @@ func setCNAME(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr := new(RR_DLV)
|
rr := new(RR_DLV)
|
||||||
rr.Hdr = hdr
|
rr.Hdr = hdr
|
||||||
rr.Hdr.Rrtype = TypeDLV
|
rr.Hdr.Rrtype = TypeDLV
|
||||||
if i, e = strconv.Atoui(rdf[0]); e != nil {
|
if i, e = strconv.Atoi(rdf[0]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DS", name: rdf[0], line: l}
|
zp.Err <- &ParseError{Error: "bad DS", name: rdf[0], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
if i, e = strconv.Atoui(rdf[1]); e != nil {
|
if i, e = strconv.Atoi(rdf[1]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DS", name: rdf[1], line: l}
|
zp.Err <- &ParseError{Error: "bad DS", name: rdf[1], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rr.Algorithm = uint8(i)
|
rr.Algorithm = uint8(i)
|
||||||
if i, e = strconv.Atoui(rdf[2]); e != nil {
|
if i, e = strconv.Atoi(rdf[2]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DS", name: rdf[2], line: l}
|
zp.Err <- &ParseError{Error: "bad DS", name: rdf[2], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -430,17 +438,17 @@ func setCNAME(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr := new(RR_TA)
|
rr := new(RR_TA)
|
||||||
rr.Hdr = hdr
|
rr.Hdr = hdr
|
||||||
rr.Hdr.Rrtype = TypeTA
|
rr.Hdr.Rrtype = TypeTA
|
||||||
if i, e = strconv.Atoui(rdf[0]); e != nil {
|
if i, e = strconv.Atoi(rdf[0]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DS", name: rdf[0], line: l}
|
zp.Err <- &ParseError{Error: "bad DS", name: rdf[0], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rr.KeyTag = uint16(i)
|
rr.KeyTag = uint16(i)
|
||||||
if i, e = strconv.Atoui(rdf[1]); e != nil {
|
if i, e = strconv.Atoi(rdf[1]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DS", name: rdf[1], line: l}
|
zp.Err <- &ParseError{Error: "bad DS", name: rdf[1], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rr.Algorithm = uint8(i)
|
rr.Algorithm = uint8(i)
|
||||||
if i, e = strconv.Atoui(rdf[2]); e != nil {
|
if i, e = strconv.Atoi(rdf[2]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DS", name: rdf[2], line: l}
|
zp.Err <- &ParseError{Error: "bad DS", name: rdf[2], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -462,17 +470,17 @@ func setCNAME(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr.Hdr = hdr
|
rr.Hdr = hdr
|
||||||
rr.Hdr.Rrtype = TypeDNSKEY
|
rr.Hdr.Rrtype = TypeDNSKEY
|
||||||
|
|
||||||
if i, e = strconv.Atoui(rdf[0]); e != nil {
|
if i, e = strconv.Atoi(rdf[0]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DNSKEY", name: rdf[0], line: l}
|
zp.Err <- &ParseError{Error: "bad DNSKEY", name: rdf[0], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rr.Flags = uint16(i)
|
rr.Flags = uint16(i)
|
||||||
if i, e = strconv.Atoui(rdf[1]); e != nil {
|
if i, e = strconv.Atoi(rdf[1]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DNSKEY", name: rdf[1], line: l}
|
zp.Err <- &ParseError{Error: "bad DNSKEY", name: rdf[1], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
rr.Protocol = uint8(i)
|
rr.Protocol = uint8(i)
|
||||||
if i, e = strconv.Atoui(rdf[2]); e != nil {
|
if i, e = strconv.Atoi(rdf[2]); e != nil {
|
||||||
zp.Err <- &ParseError{Error: "bad DNSKEY", name: rdf[2], line: l}
|
zp.Err <- &ParseError{Error: "bad DNSKEY", name: rdf[2], line: l}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -506,3 +514,4 @@ func setSSHFP(h RR_Header, c chan Lex) (RR, error) {
|
||||||
rr.FingerPrint = rdf[2]
|
rr.FingerPrint = rdf[2]
|
||||||
zp.RR <- rr
|
zp.RR <- rr
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in New Issue