Add dname

This commit is contained in:
Miek Gieben 2012-02-11 22:40:49 +01:00
parent 7dd412eb99
commit f15274bfdb
1 changed files with 21 additions and 3 deletions

View File

@ -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