gofmt (excluding _examples)

This commit is contained in:
Taral 2011-11-27 21:03:21 -08:00
parent 22a467e718
commit c1889c778d
6 changed files with 53 additions and 54 deletions

View File

@ -53,7 +53,7 @@ func TestClientEDNS0(t *testing.T) {
m := new(Msg)
m.SetQuestion("miek.nl", TypeDNSKEY)
m.SetEdns0(2048, true)
m.SetEdns0(2048, true)
//edns.Option = make([]Option, 1)
//edns.SetNsid("") // Empty to request it
@ -72,7 +72,7 @@ func TestClientTsigAXFR(t *testing.T) {
m.SetAxfr("miek.nl.")
m.SetTsig("axfr.", HmacMD5, 300, uint64(time.Seconds()))
TsigGenerate(m, "so6ZGir4GPAqINNh9U5c3A==", "", false)
TsigGenerate(m, "so6ZGir4GPAqINNh9U5c3A==", "", false)
secrets := make(map[string]string)
secrets["axfr."] = "so6ZGir4GPAqINNh9U5c3A=="
@ -86,10 +86,10 @@ func TestClientTsigAXFR(t *testing.T) {
}
for {
ex := <-c.ReplyChan
t.Log(ex.Reply.String())
if ex.Error == ErrXfrLast {
break
}
t.Log(ex.Reply.String())
if ex.Error == ErrXfrLast {
break
}
}
}
@ -106,9 +106,9 @@ func TestClientAXFRMultipleMessages(t *testing.T) {
}
for {
ex := <-c.ReplyChan
t.Log(ex.Reply.String())
if ex.Error == ErrXfrLast {
break
}
t.Log(ex.Reply.String())
if ex.Error == ErrXfrLast {
break
}
}
}

View File

@ -33,29 +33,29 @@ func (dns *Msg) SetNotify(z string) {
// SetRcode creates an error packet.
func (dns *Msg) SetRcode(request *Msg, rcode int) {
dns.MsgHdr.Rcode = rcode
dns.MsgHdr.Opcode = OpcodeQuery
dns.MsgHdr.Response = true
dns.MsgHdr.Authoritative = false
dns.MsgHdr.Id = request.MsgHdr.Id
dns.Question = make([]Question, 1)
dns.Question[0] = request.Question[0]
dns.MsgHdr.Rcode = rcode
dns.MsgHdr.Opcode = OpcodeQuery
dns.MsgHdr.Response = true
dns.MsgHdr.Authoritative = false
dns.MsgHdr.Id = request.MsgHdr.Id
dns.Question = make([]Question, 1)
dns.Question[0] = request.Question[0]
}
// SetRcodeFormatError creates a packet with FormError set.
func (dns *Msg) SetRcodeFormatError(request *Msg) {
dns.MsgHdr.Rcode = RcodeFormatError
dns.MsgHdr.Opcode = OpcodeQuery
dns.MsgHdr.Response = true
dns.MsgHdr.Authoritative = false
dns.MsgHdr.Id = request.MsgHdr.Id
dns.MsgHdr.Rcode = RcodeFormatError
dns.MsgHdr.Opcode = OpcodeQuery
dns.MsgHdr.Response = true
dns.MsgHdr.Authoritative = false
dns.MsgHdr.Id = request.MsgHdr.Id
}
// SetUpdate makes the message a dynamic update packet. It
// sets the ZONE section to: z, TypeSOA, classINET.
func (dns *Msg) SetUpdate(z string) {
dns.MsgHdr.Id = Id()
dns.MsgHdr.Opcode = OpcodeUpdate
dns.MsgHdr.Id = Id()
dns.MsgHdr.Opcode = OpcodeUpdate
dns.Question = make([]Question, 1)
dns.Question[0] = Question{z, TypeSOA, ClassINET}
}
@ -96,13 +96,13 @@ func (dns *Msg) SetTsig(z, algo string, fudge uint16, timesigned uint64) {
// SetEdns0 appends a EDNS0 OPT RR to the message.
// TSIG should always the last RR in a message.
func (dns *Msg) SetEdns0(udpsize uint16, do bool) {
e := new(RR_OPT)
e.Hdr.Name = "."
e.Hdr.Rrtype = TypeOPT
e.SetUDPSize(udpsize)
if do {
e.SetDo()
}
e := new(RR_OPT)
e.Hdr.Name = "."
e.Hdr.Rrtype = TypeOPT
e.SetUDPSize(udpsize)
if do {
e.SetDo()
}
dns.Extra = append(dns.Extra, e)
}
@ -111,17 +111,17 @@ func (dns *Msg) IsRcode(rcode int) (ok bool) {
if len(dns.Question) == 0 {
return false
}
ok = dns.MsgHdr.Rcode == rcode
return
ok = dns.MsgHdr.Rcode == rcode
return
}
// IsQuestion returns true if the packet is a question.
func (dns *Msg) IsQuestion() (ok bool) {
if len(dns.Question) == 0 {
return false
}
ok = dns.MsgHdr.Response == false
return
if len(dns.Question) == 0 {
return false
}
ok = dns.MsgHdr.Response == false
return
}
// IsRcodeFormatError checks if the message has FormErr set.
@ -129,8 +129,8 @@ func (dns *Msg) IsRcodeFormatError() (ok bool) {
if len(dns.Question) == 0 {
return false
}
ok = dns.MsgHdr.Rcode == RcodeFormatError
return
ok = dns.MsgHdr.Rcode == RcodeFormatError
return
}
// IsUpdate checks if the message is a dynamic update packet.
@ -188,12 +188,12 @@ func (dns *Msg) IsTsig() (ok bool) {
// IsEdns0 checks if the message has a Edns0 record, any EDNS0
// record in the additional section will do
func (dns *Msg) IsEdns0() (ok bool) {
for _, r := range dns.Extra {
if r.Header().Rrtype == TypeOPT {
return true
}
}
return
for _, r := range dns.Extra {
if r.Header().Rrtype == TypeOPT {
return true
}
}
return
}
// IsDomainName checks if s is a valid domainname.

View File

@ -96,7 +96,6 @@ func (rr *RR_OPT) SetUDPSize(size uint16) {
rr.Hdr.Class = size
}
/* from RFC 3225
+0 (MSB) +1 (LSB)
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

View File

@ -1,9 +1,9 @@
package dns
import (
// "os"
// "time"
// "bufio"
// "os"
// "time"
// "bufio"
"strings"
"testing"
"crypto/rsa"

View File

@ -9,8 +9,8 @@ const initialSize = 8
type QnameString []string
func NewQnameString() *QnameString {
p := make(QnameString, 0)
return &p
p := make(QnameString, 0)
return &p
}
func (p *QnameString) Insert(i int, x string) {

View File

@ -23,6 +23,6 @@ func (h *RR_Header) RawSetRdlength(buf []byte, off int) bool {
// RawSetId sets the message ID in buf.
func RawSetId(buf []byte, off int, id uint16) bool {
buf[off], buf[off+1] = packUint16(id)
return true
buf[off], buf[off+1] = packUint16(id)
return true
}