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

View File

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

View File

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

View File

@ -9,8 +9,8 @@ const initialSize = 8
type QnameString []string type QnameString []string
func NewQnameString() *QnameString { func NewQnameString() *QnameString {
p := make(QnameString, 0) p := make(QnameString, 0)
return &p return &p
} }
func (p *QnameString) Insert(i int, x string) { 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. // RawSetId sets the message ID in buf.
func RawSetId(buf []byte, off int, id uint16) bool { func RawSetId(buf []byte, off int, id uint16) bool {
buf[off], buf[off+1] = packUint16(id) buf[off], buf[off+1] = packUint16(id)
return true return true
} }