Update test and gofmt

This commit is contained in:
Miek Gieben 2014-11-09 16:09:49 +00:00
parent 7619917e11
commit d33af8db79
5 changed files with 21 additions and 18 deletions

22
msg.go
View File

@ -564,20 +564,20 @@ func unpackTxtString(msg []byte, offset int) (string, int, error) {
s = append(s, `\n`...) s = append(s, `\n`...)
default: default:
if b < 32 || b > 127 { // unprintable if b < 32 || b > 127 { // unprintable
var buf [3]byte var buf [3]byte
bufs := strconv.AppendInt(buf[:0], int64(b), 10) bufs := strconv.AppendInt(buf[:0], int64(b), 10)
s = append(s, '\\') s = append(s, '\\')
for i := 0; i < 3-len(bufs); i++ { for i := 0; i < 3-len(bufs); i++ {
s = append(s, '0') s = append(s, '0')
}
for _, r := range bufs {
s = append(s, r)
}
} else {
s = append(s, b)
} }
for _, r := range bufs {
s = append(s, r)
}
} else {
s = append(s, b)
} }
} }
}
offset += 1 + l offset += 1 + l
return string(s), offset, nil return string(s), offset, nil
} }

View File

@ -68,7 +68,7 @@ func TestServing(t *testing.T) {
m := new(Msg) m := new(Msg)
m.SetQuestion("miek.nl.", TypeTXT) m.SetQuestion("miek.nl.", TypeTXT)
r, _, err := c.Exchange(m, addrstr) r, _, err := c.Exchange(m, addrstr)
if err != nil { if err != nil || len(r.Extra) == 0 {
t.Log("failed to exchange miek.nl", err) t.Log("failed to exchange miek.nl", err)
t.Fatal() t.Fatal()
} }

View File

@ -830,7 +830,7 @@ func (rr *LOC) String() string {
// SIG is identical to RRSIG and nowadays only used for SIG(0), RFC2931. // SIG is identical to RRSIG and nowadays only used for SIG(0), RFC2931.
type SIG struct { type SIG struct {
RRSIG RRSIG
} }
type RRSIG struct { type RRSIG struct {
@ -1031,11 +1031,11 @@ func (rr *IPSECKEY) len() int {
} }
type KEY struct { type KEY struct {
DNSKEY DNSKEY
} }
type CDNSKEY struct { type CDNSKEY struct {
DNSKEY DNSKEY
} }
type DNSKEY struct { type DNSKEY struct {

View File

@ -23,11 +23,14 @@ func TestDynamicUpdateParsing(t *testing.T) {
func TestDynamicUpdateUnpack(t *testing.T) { func TestDynamicUpdateUnpack(t *testing.T) {
// From https://github.com/miekg/dns/issues/150#issuecomment-62296803 // From https://github.com/miekg/dns/issues/150#issuecomment-62296803
// It should be an update message for the zone "example.",
// deleting the A RRset "example." and then adding an A record at "example.".
// class ANY, TYPE A
buf := []byte{171, 68, 40, 0, 0, 1, 0, 0, 0, 2, 0, 0, 7, 101, 120, 97, 109, 112, 108, 101, 0, 0, 6, 0, 1, 192, 12, 0, 1, 0, 255, 0, 0, 0, 0, 0, 0, 192, 12, 0, 1, 0, 1, 0, 0, 0, 0, 0, 4, 127, 0, 0, 1} buf := []byte{171, 68, 40, 0, 0, 1, 0, 0, 0, 2, 0, 0, 7, 101, 120, 97, 109, 112, 108, 101, 0, 0, 6, 0, 1, 192, 12, 0, 1, 0, 255, 0, 0, 0, 0, 0, 0, 192, 12, 0, 1, 0, 1, 0, 0, 0, 0, 0, 4, 127, 0, 0, 1}
msg := new(Msg) msg := new(Msg)
err := msg.Unpack(buf) err := msg.Unpack(buf)
if err != nil { if err != nil {
t.Log("failed to unpack: " + err.Error()) t.Log("failed to unpack: " + err.Error() + "\n" + msg.String()))
// t.Fail() t.Fail()
} }
} }

View File

@ -1653,7 +1653,7 @@ func setDSs(h RR_Header, c chan lex, o, f, typ string) (RR, *ParseError, string)
} else { } else {
rr.DigestType = uint8(i) rr.DigestType = uint8(i)
} }
s, e, c1 := endingToString(c, "bad " + typ + " Digest", f) s, e, c1 := endingToString(c, "bad "+typ+" Digest", f)
if e != nil { if e != nil {
return nil, e, c1 return nil, e, c1
} }