Add HIP parsing for zone files
This commit is contained in:
parent
9180a06d7c
commit
441eaa6e17
47
zscan_rr.go
47
zscan_rr.go
|
@ -73,6 +73,8 @@ func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
|||
return setTLSA(h, c, f)
|
||||
case TypeTXT:
|
||||
return setTXT(h, c, f)
|
||||
case TypeHIP:
|
||||
return setHIP(h, c, o, f)
|
||||
case TypeSPF:
|
||||
return setSPF(h, c, f)
|
||||
case TypeIPSECKEY:
|
||||
|
@ -387,6 +389,51 @@ func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
|
|||
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) {
|
||||
rr := new(RR_CERT)
|
||||
rr.Hdr = h
|
||||
|
|
Loading…
Reference in New Issue