From f15274bfdbfa306a0f78c99c29e7124ecfa7e3ea Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 11 Feb 2012 22:40:49 +0100 Subject: [PATCH] Add dname --- zscan_rr.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/zscan_rr.go b/zscan_rr.go index 3aac6332..c1647046 100644 --- a/zscan_rr.go +++ b/zscan_rr.go @@ -35,6 +35,9 @@ func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { case TypeCNAME: r, e = setCNAME(h, c, o, f) goto Slurp + case TypeDNAME: + r, e = setDNAME(h, c, o, f) + goto Slurp case TypeSOA: r, e = setSOA(h, c, o, f) goto Slurp @@ -44,9 +47,6 @@ func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { case TypeSRV: r, e = setSRV(h, c, o, f) goto Slurp - case TypeNAPTR: - r, e = setNAPTR(h, c, o, f) - goto Slurp // 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 // newline. Thus there is no need to slurp the remainder, because there is none. @@ -60,6 +60,8 @@ func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { return setNSEC3(h, c, o, f) case TypeDS: return setDS(h, c, f) + case TypeNAPTR: + return setNAPTR(h, c, o, f) case TypeTXT: return setTXT(h, c, f) default: @@ -197,6 +199,22 @@ func setCNAME(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { return rr, nil } +func setDNAME(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { + rr := new(RR_DNAME) + rr.Hdr = h + + l := <-c + rr.Target = l.token + _, ld, ok := IsDomainName(l.token) + if !ok { + return nil, &ParseError{f, "bad CNAME Target", l} + } + if rr.Target[ld-1] != '.' { + rr.Target += o + } + return rr, nil +} + func setSOA(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { rr := new(RR_SOA) rr.Hdr = h