remove NewClient from the code

This commit is contained in:
Miek Gieben 2012-05-26 10:28:32 +02:00
parent 458a74b8ce
commit 9c4c5f5369
6 changed files with 14 additions and 28 deletions

View File

@ -111,7 +111,7 @@ func HandleQueryFunc(pattern string, handler func(RequestWriter, *Msg)) {
// dns.HandleQuery(".", myhandler)
// dns.ListenAndQuery(nil)
// m := new(dns.Msg)
// c := dns.NewClient()
// c := new(dns.Client)
// m.SetQuestion("miek.nl.", TypeMX)
// c.Do(m, "127.0.0.1:53")
// // ...
@ -183,20 +183,6 @@ type Client struct {
// LocalAddr string // Local address to use
}
// NewClient creates a new client, with Net set to "udp" and Attempts to 1.
// The Timeouts are set to 2 * 1e9 and the query channels (for async usage)
// are set to the global defaults (QueryReqeust and QueryReply)
func NewClient() *Client {
c := new(Client)
c.Net = "udp"
c.Attempts = 1
c.Request = QueryRequest
c.Reply = QueryReply
c.ReadTimeout = 2 * 1e9
c.WriteTimeout = 2 * 1e9
return c
}
type Query struct {
Request chan *Request // read DNS request from this channel
Handler QueryHandler // handler to invoke, dns.DefaultQueryMux if nil
@ -311,7 +297,7 @@ func (c *Client) exchangeBuffer(inbuf []byte, a string, outbuf []byte) (n int, w
// Exchange performs an synchronous query. It sends the message m to the address
// contained in a and waits for an reply. Basic use pattern with a *Client:
//
// c := dns.NewClient()
// c := new(dns.Client)
// in, err := c.Exchange(message, "127.0.0.1:53")
//
// See Client.ExchangeRtt(...) to get the round trip time.
@ -323,7 +309,7 @@ func (c *Client) Exchange(m *Msg, a string) (r *Msg, err error) {
// ExchangeRtt performs an synchronous query. It sends the message m to the address
// contained in a and waits for an reply. Basic use pattern with a *Client:
//
// c := dns.NewClient()
// c := new(dns.Client)
// in, rtt, addr, err := c.ExchangeRtt(message, "127.0.0.1:53")
//
// The 'addr' return value is superfluous in this case, but it is here to retain symmetry

View File

@ -9,7 +9,7 @@ func TestClientSync(t *testing.T) {
m := new(Msg)
m.SetQuestion("miek.nl.", TypeSOA)
c := NewClient()
c := new(Client)
r, _ := c.Exchange(m, "85.223.71.124:53")
if r != nil && r.Rcode != RcodeSuccess {
@ -32,7 +32,7 @@ func TestClientASync(t *testing.T) {
m := new(Msg)
m.SetQuestion("miek.nl.", TypeSOA)
c := NewClient()
c := new(Client)
c.Do(m, "85.223.71.124:53")
forever:
@ -57,7 +57,7 @@ func TestClientEDNS0(t *testing.T) {
//edns.Option = make([]Option, 1)
//edns.SetNsid("") // Empty to request it
c := NewClient()
c := new(Client)
r, _ := c.Exchange(m, "85.223.71.124:53")
if r != nil && r.Rcode != RcodeSuccess {
@ -72,7 +72,7 @@ func TestClientTsigAXFR(t *testing.T) {
m.SetAxfr("miek.nl.")
m.SetTsig("axfr.", HmacMD5, 300, time.Now().Unix())
c := NewClient()
c := new(Client)
c.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="}
c.Net = "tcp"
@ -100,7 +100,7 @@ func TestClientAXFRMultipleMessages(t *testing.T) {
m := new(Msg)
m.SetAxfr("dnsex.nl.")
c := NewClient()
c := new(Client)
c.Net = "tcp"
// timeout?

2
dns.go
View File

@ -56,7 +56,7 @@
// Basic use pattern for synchronous querying the DNS at a
// server configured on 127.0.0.1 and port 53:
//
// c := dns.NewClient()
// c := new(Client)
// in, err := c.Exchange(m1, "127.0.0.1:53")
//
// An asynchronous query is also possible, setting up is more elaborate then

View File

@ -6,7 +6,7 @@ import (
)
func sendit(u *Msg) (r *Msg, e error) {
c := NewClient()
c := new(Client)
r, e = c.Exchange(u, "127.0.0.1:53")
return r, e
}

View File

@ -34,7 +34,7 @@ func BenchmarkServing(b *testing.B) {
ListenAndServe("127.0.0.1:8053", "udp", nil)
}()
c := NewClient()
c := new(Client)
m := new(Msg)
m.SetQuestion("miek.nl", TypeSOA)

View File

@ -6,8 +6,8 @@
// Basic use pattern when querying with a TSIG name "axfr." and the base64
// secret "so6ZGir4GPAqINNh9U5c3A==":
//
// m := dns.new(Msg)
// c := dns.NewClient()
// m := new(dns.Msg)
// c := new(dns.Client)
// c.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="}
// m.SetQuestion("miek.nl.", dns.TypeMX)
// m.SetTsig("axfr.", dns.HmacMD5, 300, time.Now().Unix())
@ -19,7 +19,7 @@
// miek.nl. with TSIG key named "axfr." and secret "so6ZGir4GPAqINNh9U5c3A=="
// and using the server 85.223.71.124
//
// c := dns.NewClient()
// c := new(dns.Client)
// c.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="}
// m := new(dns.Msg)
// m.SetAxfr("miek.nl.")