merge conflict

This commit is contained in:
Miek Gieben 2015-07-28 21:45:20 +01:00
commit 2839b93f6b
4 changed files with 42 additions and 32 deletions

View File

@ -125,7 +125,7 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
* 6975 - Algorithm Understanding in DNSSEC
* 7043 - EUI48/EUI64 records
* 7314 - DNS (EDNS) EXPIRE Option
* xxxx - URI record (draft)
* 7553 - URI record
* xxxx - EDNS0 DNS Update Lease (draft)
## Loosely based upon
@ -138,7 +138,7 @@ Example programs can be found in the `github.com/miekg/exdns` repository.
## TODO
* privatekey.Precompute() when signing?
* Last remaining RRs: APL, ATMA, A6 and NXT and IPSECKEY;
* Missing in parsing: ISDN, UNSPEC, ATMA;
* NSEC(3) cover/match/closest enclose;
* Replies with TC bit are not parsed to the end;
* Last remaining RRs: APL, ATMA, A6 and NXT.
* Missing in parsing: ISDN, UNSPEC, ATMA.
* NSEC(3) cover/match/closest enclose.
* Replies with TC bit are not parsed to the end.

View File

@ -1506,3 +1506,22 @@ func TestPackCAA(t *testing.T) {
t.Fatalf("invalid flag for unpacked answer")
}
}
func TestParseURI(t *testing.T) {
lt := map[string]string{
"_http._tcp. IN URI 10 1 \"http://www.example.com/path\"": "_http._tcp.\t3600\tIN\tURI\t10 1 \"http://www.example.com/path\"",
"_http._tcp. IN URI 10 1 \"\"": "_http._tcp.\t3600\tIN\tURI\t10 1 \"\"",
}
for i, o := range lt {
rr, err := NewRR(i)
if err != nil {
t.Error("failed to parse RR: ", err)
continue
}
if rr.String() != o {
t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String())
} else {
t.Logf("RR is OK: `%s'", rr.String())
}
}
}

View File

@ -503,7 +503,7 @@ func sprintName(s string) string {
return string(dst)
}
func sprintCAAValue(s string) string {
func sprintTxtOctet(s string) string {
src := []byte(s)
dst := make([]byte, 0, len(src))
dst = append(dst, '"')
@ -1329,27 +1329,15 @@ type URI struct {
Hdr RR_Header
Priority uint16
Weight uint16
Target []string `dns:"txt"`
Target string `dns:"octet"`
}
func (rr *URI) Header() *RR_Header { return &rr.Hdr }
func (rr *URI) copy() RR {
cp := make([]string, len(rr.Target), cap(rr.Target))
copy(cp, rr.Target)
return &URI{*rr.Hdr.copyHeader(), rr.Weight, rr.Priority, cp}
}
func (rr *URI) copy() RR { return &URI{*rr.Hdr.copyHeader(), rr.Weight, rr.Priority, rr.Target} }
func (rr *URI) len() int { return rr.Hdr.len() + 4 + len(rr.Target) }
func (rr *URI) String() string {
return rr.Hdr.String() + strconv.Itoa(int(rr.Priority)) +
" " + strconv.Itoa(int(rr.Weight)) + sprintTxt(rr.Target)
}
func (rr *URI) len() int {
l := rr.Hdr.len() + 4
for _, t := range rr.Target {
l += len(t) + 1
}
return l
" " + strconv.Itoa(int(rr.Weight)) + " " + sprintTxtOctet(rr.Target)
}
type DHCID struct {
@ -1571,7 +1559,7 @@ func (rr *CAA) Header() *RR_Header { return &rr.Hdr }
func (rr *CAA) copy() RR { return &CAA{*rr.Hdr.copyHeader(), rr.Flag, rr.Tag, rr.Value} }
func (rr *CAA) len() int { return rr.Hdr.len() + 2 + len(rr.Tag) + len(rr.Value) }
func (rr *CAA) String() string {
return rr.Hdr.String() + strconv.Itoa(int(rr.Flag)) + " " + rr.Tag + " " + sprintCAAValue(rr.Value)
return rr.Hdr.String() + strconv.Itoa(int(rr.Flag)) + " " + rr.Tag + " " + sprintTxtOctet(rr.Value)
}
type UID struct {

View File

@ -1876,9 +1876,10 @@ func setURI(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
rr.Hdr = h
l := <-c
if l.length == 0 {
return rr, nil, l.comment
if l.length == 0 { // Dynamic updates.
return rr, nil, ""
}
i, e := strconv.Atoi(l.token)
if e != nil {
return nil, &ParseError{f, "bad URI Priority", l}, ""
@ -1893,11 +1894,14 @@ func setURI(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
rr.Weight = uint16(i)
<-c // zBlank
s, e, c1 := endingToTxtSlice(c, "bad URI Target", f)
if e != nil {
return nil, e.(*ParseError), ""
s, err, c1 := endingToTxtSlice(c, "bad URI Target", f)
if err != nil {
return nil, err, ""
}
rr.Target = s
if len(s) > 1 {
return nil, &ParseError{f, "bad URI Target", l}, ""
}
rr.Target = s[0]
return rr, nil, c1
}
@ -2183,7 +2187,7 @@ func setCAA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
}
rr.Flag = uint8(i)
<-c // zBlank
<-c // zBlank
l = <-c // zString
if l.value != zString {
return nil, &ParseError{f, "bad CAA Tag", l}, ""
@ -2197,9 +2201,8 @@ func setCAA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) {
}
if len(s) > 1 {
return nil, &ParseError{f, "bad CAA Value", l}, ""
} else {
rr.Value = s[0]
}
rr.Value = s[0]
return rr, nil, c1
}