From 7dd412eb9984ce16875ce52619c33b689050e16f Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 11 Feb 2012 22:38:17 +0100 Subject: [PATCH] Add CERT --- zscan_rr.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/zscan_rr.go b/zscan_rr.go index 1ed7eb06..3aac6332 100644 --- a/zscan_rr.go +++ b/zscan_rr.go @@ -329,6 +329,49 @@ func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { return rr, nil } +func setCERT(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { + rr := new(RR_CERT) + rr.Hdr = h + + l := <-c + if i, e := strconv.Atoi(l.token); e != nil { + return nil, &ParseError{f, "bad CERT Type", l} + } else { + rr.Type = uint16(i) + } + <-c // _BLANK + l = <-c // _STRING + if i, e := strconv.Atoi(l.token); e != nil { + return nil, &ParseError{f, "bad NAPTR KeyTag", l} + } else { + rr.KeyTag = uint16(i) + } + <-c // _BLANK + l = <-c // _STRING + if i, e := strconv.Atoi(l.token); e != nil { + return nil, &ParseError{f, "bad NAPTR Algorithm", l} + } else { + rr.Algorithm = uint8(i) + } + // Get the remaining data until we see a NEWLINE + l = <-c + s := "" + for l.value != _NEWLINE && l.value != _EOF { + switch l.value { + case _STRING: + s += l.token + case _BLANK: + // Ok + default: + return nil, &ParseError{f, "bad NAPTR Certificate", l} + } + l = <-c + } + rr.Certificate = s + + return rr, nil +} + func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { rr := new(RR_RRSIG) rr.Hdr = h