diff --git a/LICENSE b/LICENSE index 8dba56cc..c5d454d4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Extensions from the original work are copyright (c) 2010 Miek Gieben +Extensions from the original work are copyright (c) 2010, 2011 Miek Gieben As this is fork of the official Go code the same license applies: diff --git a/client_test.go b/client_test.go index 54ce675e..4df8605a 100644 --- a/client_test.go +++ b/client_test.go @@ -2,6 +2,7 @@ package dns import ( "testing" + "time" ) func TestClientSync(t *testing.T) { @@ -81,53 +82,23 @@ func TestResolverEdns(t *testing.T) { } */ -/* -func TestResolverTsig(t *testing.T) { - res := new(Resolver) - res.Servers = []string{"127.0.0.1"} - res.Timeout = 2 - res.Attempts = 1 - +func TestClientTsigAXFR(t *testing.T) { m := new(Msg) - m.MsgHdr.RecursionDesired = true //only set this bit - m.Question = make([]Question, 1) + m.SetAxfr("miek.nl") - // ask something - m.Question[0] = Question{"powerdns.nl", TypeDNSKEY, ClassINET} - m.Extra = make([]RR, 1) - m.Id = Id() + m.SetTsig("axfr", HmacMD5, 300, uint64(time.Seconds())) + secrets := make(map[string]string) + secrets["axfr"] = "so6ZGir4GPAqINNh9U5c3A==" + c := NewClient() + c.Net = "tcp" + c.TsigSecret = secrets - tsig := new(Tsig) - tsig.Name = "miek.nl." - tsig.Algorithm = HmacMD5 - tsig.Fudge = 300 - tsig.TimeSigned = uint64(time.Seconds()) - tsig.Secret = "ZGZqc2tmZAo=" - - in, _ := res.QueryTsig(m,tsig) - if in != nil { - if in.Rcode != RcodeSuccess { - t.Logf("%v\n", in) - t.Log("Failed to get an valid answer") - // t.Fail() - } - } + _, err := c.XfrReceive(m, "85.223.71.124:53") + /* + if err != nil { + t.Log("%s\n", err.String()) + t.Fail() + } + */ } - -func TestAXFR(t *testing.T) { - res := new(Resolver) - res.Servers = []string{"127.0.0.1"} - m := new(Msg) - m.Question = make([]Question, 1) - m.Question[0] = Question{"miek.nl", TypeAXFR, ClassINET} - - ch := make(chan Xfr) - go res.Xfr(m, ch) - for x := range ch { - var _ = x - // fmt.Printf("%v\n",dm.Dns) - } - // channel is closed by Axfr() -} -*/ diff --git a/defaults.go b/defaults.go index 2f19b87b..f30ec491 100644 --- a/defaults.go +++ b/defaults.go @@ -16,8 +16,8 @@ func (dns *Msg) SetReply(request *Msg) { // Create a question packet. func (dns *Msg) SetQuestion(z string, t uint16) { - dns.MsgHdr.Id = Id() - dns.MsgHdr.RecursionDesired = true + dns.MsgHdr.Id = Id() + dns.MsgHdr.RecursionDesired = true dns.Question = make([]Question, 1) dns.Question[0] = Question{z, t, ClassINET} } @@ -36,9 +36,9 @@ func (dns *Msg) IsUpdate() (ok bool) { if len(dns.Question) == 0 { return false } - ok = dns.MsgHdr.Opcode == OpcodeUpdate - ok = ok && dns.Question[0].Qtype == TypeSOA - return + ok = dns.MsgHdr.Opcode == OpcodeUpdate + ok = ok && dns.Question[0].Qtype == TypeSOA + return } // Is the message a valid notify packet? @@ -54,7 +54,7 @@ func (dns *Msg) IsNotify() (ok bool) { // Create a dns msg suitable for requesting an ixfr. func (dns *Msg) SetIxfr(z string, serial uint32) { - dns.MsgHdr.Id = Id() + dns.MsgHdr.Id = Id() dns.Question = make([]Question, 1) dns.Ns = make([]RR, 1) s := new(RR_SOA) @@ -67,7 +67,7 @@ func (dns *Msg) SetIxfr(z string, serial uint32) { // Create a dns msg suitable for requesting an axfr. func (dns *Msg) SetAxfr(z string) { - dns.MsgHdr.Id = Id() + dns.MsgHdr.Id = Id() dns.Question = make([]Question, 1) dns.Question[0] = Question{z, TypeAXFR, ClassINET} } @@ -96,17 +96,17 @@ func (dns *Msg) IsIxfr() (ok bool) { // Has a message a TSIG record as the last record? func (dns *Msg) IsTsig() (ok bool) { - if len(dns.Extra) > 0 { - return dns.Extra[0].Header().Rrtype == TypeTSIG - } - return + if len(dns.Extra) > 0 { + return dns.Extra[0].Header().Rrtype == TypeTSIG + } + return } func (dns *Msg) SetTsig(z, algo string, fudge uint16, timesigned uint64) { - t := new(RR_TSIG) - t.Hdr = RR_Header{z, TypeTSIG, ClassANY, 0, 0} - t.Algorithm = algo - t.Fudge = fudge - t.TimeSigned = timesigned - dns.Extra = append(dns.Extra, t) + t := new(RR_TSIG) + t.Hdr = RR_Header{z, TypeTSIG, ClassANY, 0, 0} + t.Algorithm = algo + t.Fudge = fudge + t.TimeSigned = timesigned + dns.Extra = append(dns.Extra, t) }