diff --git a/client.go b/client.go index d8bb7ce5..5c8eb6ad 100644 --- a/client.go +++ b/client.go @@ -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 diff --git a/client_test.go b/client_test.go index 4512a03c..d0dcbb90 100644 --- a/client_test.go +++ b/client_test.go @@ -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? diff --git a/dns.go b/dns.go index 51febbe1..fda190bd 100644 --- a/dns.go +++ b/dns.go @@ -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 diff --git a/dyn_test.go b/dyn_test.go index 54e29eb1..5b98ff61 100644 --- a/dyn_test.go +++ b/dyn_test.go @@ -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 } diff --git a/server_test.go b/server_test.go index 49d3476c..6fcd877c 100644 --- a/server_test.go +++ b/server_test.go @@ -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) diff --git a/tsig.go b/tsig.go index 078a124d..fad992ac 100644 --- a/tsig.go +++ b/tsig.go @@ -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.")