add URI record

This commit is contained in:
Miek Gieben 2012-02-18 21:49:02 +01:00
parent a618f8edec
commit da7e2c298f
2 changed files with 63 additions and 13 deletions

View File

@ -55,29 +55,30 @@ All of them:
* 2181 - RRset definition * 2181 - RRset definition
* 2537 - RSAMD5 DNS keys * 2537 - RSAMD5 DNS keys
* 2065 - DNSSEC (updated in later RFCs) * 2065 - DNSSEC (updated in later RFCs)
* 2671 - EDNS * 2671 - EDNS record
* 2782 - SRV * 2782 - SRV record
* 2845 - TSIG * 2845 - TSIG record
* 2915 - NAPTR * 2915 - NAPTR record
* 3110 - RSASHA1 DNS keys * 3110 - RSASHA1 DNS keys
* 3225 - DO bit (DNSSEC OK) * 3225 - DO bit (DNSSEC OK)
* 340{1,2,3} - NAPTR * 340{1,2,3} - NAPTR record
* 3445 - Limiting the scope of (DNS)KEY * 3445 - Limiting the scope of (DNS)KEY
* 3597 - Unkown RRs * 3597 - Unkown RRs
* 403{3,4,5} - DNSSEC + validation functions * 403{3,4,5} - DNSSEC + validation functions
* 4255 - SSHFP * 4255 - SSHFP record
* 4408 - SPF * 4408 - SPF record
* 4509 - SHA256 Hash in DS * 4509 - SHA256 Hash in DS
* 4592 - Wildcards in the DNS * 4592 - Wildcards in the DNS
* 4635 - HMAC SHA TSIG * 4635 - HMAC SHA TSIG
* 4701 - DHCID * 4701 - DHCID
* 4892 - id.server * 4892 - id.server
* 5001 - NSID * 5001 - NSID
* 5155 - NSEC3 * 5155 - NSEC3 record
* 5205 - HIP * 5205 - HIP record
* 5933 - GOST * 5933 - GOST
* 5936 - AXFR * 5936 - AXFR
* xxxx - ECDSA * xxxx - ECDSA
* xxxx - URI record
## Loosely based upon: ## Loosely based upon:

View File

@ -6,8 +6,6 @@ import (
"strings" "strings"
) )
// TODO: TKEY, RR_URI, DHCID
// Parse the rdata of each rrtype. // Parse the rdata of each rrtype.
// All data from the channel c is either _STRING or _BLANK. // All data from the channel c is either _STRING or _BLANK.
// After the rdata there may come 1 _BLANK and then a _NEWLINE // After the rdata there may come 1 _BLANK and then a _NEWLINE
@ -1025,6 +1023,57 @@ func setTXT(h RR_Header, c chan lex, f string) (RR, *ParseError) {
return rr, nil return rr, nil
} }
func setURI(h RR_Header, c chan lex, f string) (RR, *ParseError) {
rr := new(RR_URI)
rr.Hdr = h
l := <-c
if i, e := strconv.Atoi(l.token); e != nil {
return nil, &ParseError{f, "bad URI Priority", l}
} else {
rr.Priority = uint16(i)
}
<-c // _BLANK
l = <-c
if i, e := strconv.Atoi(l.token); e != nil {
return nil, &ParseError{f, "bad URI Weight", l}
} else {
rr.Weight = uint16(i)
}
// _BLANK?
// Get the remaining data until we see a NEWLINE
quote := false
l = <-c
var s string
switch l.value == _QUOTE {
case true:
for l.value != _NEWLINE && l.value != _EOF {
switch l.value {
case _STRING:
s += l.token
case _BLANK:
if quote {
// _BLANK can only be seen in between txt parts.
return nil, &ParseError{f, "bad URI Target", l}
}
case _QUOTE:
quote = !quote
default:
return nil, &ParseError{f, "bad URI Target", l}
}
l = <-c
}
if quote {
return nil, &ParseError{f, "bad URI Target", l}
}
case false: // Unquoted
return nil, &ParseError{f, "bad URI Target", l}
}
rr.Target = s
return rr, nil
}
func setIPSECKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError) { func setIPSECKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
rr := new(RR_IPSECKEY) rr := new(RR_IPSECKEY)
rr.Hdr = h rr.Hdr = h
@ -1070,11 +1119,11 @@ func setIPSECKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError) {
} }
func setDHCID(h RR_Header, c chan lex, f string) (RR, *ParseError) { func setDHCID(h RR_Header, c chan lex, f string) (RR, *ParseError) {
// awesome record to parse! // awesome record to parse!
rr := new(RR_DHCID) rr := new(RR_DHCID)
rr.Hdr = h rr.Hdr = h
l := <-c // _STRING l := <-c // _STRING
var s string var s string
for l.value != _NEWLINE && l.value != _EOF { for l.value != _NEWLINE && l.value != _EOF {
switch l.value { switch l.value {