Add HIP parsing for zone files
This commit is contained in:
parent
9180a06d7c
commit
441eaa6e17
63
zscan_rr.go
63
zscan_rr.go
|
@ -50,10 +50,10 @@ 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:
|
case TypeLOC:
|
||||||
//r, e = setLOC(h, c, f)
|
//r, e = setLOC(h, c, f)
|
||||||
// TODO
|
// TODO
|
||||||
goto Slurp
|
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.
|
||||||
|
@ -69,14 +69,16 @@ func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
return setNSEC3PARAM(h, c, f)
|
return setNSEC3PARAM(h, c, f)
|
||||||
case TypeDS:
|
case TypeDS:
|
||||||
return setDS(h, c, f)
|
return setDS(h, c, f)
|
||||||
case TypeTLSA:
|
case TypeTLSA:
|
||||||
return setTLSA(h, c, f)
|
return setTLSA(h, c, f)
|
||||||
case TypeTXT:
|
case TypeTXT:
|
||||||
return setTXT(h, c, f)
|
return setTXT(h, c, f)
|
||||||
|
case TypeHIP:
|
||||||
|
return setHIP(h, c, o, f)
|
||||||
case TypeSPF:
|
case TypeSPF:
|
||||||
return setSPF(h, c, f)
|
return setSPF(h, c, f)
|
||||||
case TypeIPSECKEY:
|
case TypeIPSECKEY:
|
||||||
return setIPSECKEY(h, c, o, f)
|
return setIPSECKEY(h, c, o, f)
|
||||||
default:
|
default:
|
||||||
// RFC3957 RR (Unknown RR handling)
|
// RFC3957 RR (Unknown RR handling)
|
||||||
return setRFC3597(h, c, f)
|
return setRFC3597(h, c, f)
|
||||||
|
@ -387,6 +389,51 @@ func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
return rr, nil
|
return rr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
||||||
|
rr := new(RR_HIP)
|
||||||
|
rr.Hdr = h
|
||||||
|
|
||||||
|
// HitLength is represented
|
||||||
|
l := <-c
|
||||||
|
if i, e := strconv.Atoi(l.token); e != nil {
|
||||||
|
return nil, &ParseError{f, "bad HIP PublicKeyAlgorithm", l}
|
||||||
|
} else {
|
||||||
|
rr.PublicKeyAlgorithm = uint8(i)
|
||||||
|
}
|
||||||
|
<-c // _BLANK
|
||||||
|
l = <-c // _STRING
|
||||||
|
rr.Hit = l.token // Can this have spaces? TODO
|
||||||
|
|
||||||
|
<-c // _BLANK
|
||||||
|
l = <-c // _STRING
|
||||||
|
rr.PublicKey = l.token // This cannot contain spaces
|
||||||
|
|
||||||
|
// RendezvousServers (if any)
|
||||||
|
l = <-c
|
||||||
|
xs := make([]string, 0)
|
||||||
|
for l.value != _NEWLINE && l.value != _EOF {
|
||||||
|
switch l.value {
|
||||||
|
case _STRING:
|
||||||
|
_, ld, ok := IsDomainName(l.token)
|
||||||
|
if !ok {
|
||||||
|
return nil, &ParseError{f, "bad HIP RendezvousServers", l}
|
||||||
|
}
|
||||||
|
if l.token[ld-1] != '.' {
|
||||||
|
l.token = appendOrigin(l.token, o)
|
||||||
|
}
|
||||||
|
xs = append(xs, l.token)
|
||||||
|
case _BLANK:
|
||||||
|
// Ok
|
||||||
|
default:
|
||||||
|
return nil, &ParseError{f, "bad HIP RendezvousServers", l}
|
||||||
|
}
|
||||||
|
l = <-c
|
||||||
|
}
|
||||||
|
rr.RendezvousServers = xs
|
||||||
|
|
||||||
|
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) {
|
||||||
rr := new(RR_CERT)
|
rr := new(RR_CERT)
|
||||||
rr.Hdr = h
|
rr.Hdr = h
|
||||||
|
|
Loading…
Reference in New Issue