diff options
author | 2016-10-12 12:46:35 +0100 | |
---|---|---|
committer | 2016-10-12 12:46:35 +0100 | |
commit | aa7744dc86455c89a2c8396b5ada71134064822d (patch) | |
tree | 1d5fb4b959ce41c17afca0bda4da66328a023d64 /middleware/proxy | |
parent | 710c9b111f31b9d5f0b280739420b31c95adf14b (diff) | |
download | coredns-aa7744dc86455c89a2c8396b5ada71134064822d.tar.gz coredns-aa7744dc86455c89a2c8396b5ada71134064822d.tar.zst coredns-aa7744dc86455c89a2c8396b5ada71134064822d.zip |
cleanups: go vet/golint (#331)
Go vet and golint the new code once again.
Drop Name from NameTemplate - it's cleaner: nametemplate.Template.
Diffstat (limited to 'middleware/proxy')
-rw-r--r-- | middleware/proxy/client.go | 12 | ||||
-rw-r--r-- | middleware/proxy/lookup.go | 2 | ||||
-rw-r--r-- | middleware/proxy/proxy.go | 2 | ||||
-rw-r--r-- | middleware/proxy/setup.go | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/middleware/proxy/client.go b/middleware/proxy/client.go index ba2f439cc..0a35c93e4 100644 --- a/middleware/proxy/client.go +++ b/middleware/proxy/client.go @@ -10,19 +10,19 @@ import ( "github.com/miekg/dns" ) -type Client struct { +type client struct { Timeout time.Duration group *singleflight.Group } -func NewClient() *Client { - return &Client{Timeout: defaultTimeout, group: new(singleflight.Group)} +func newClient() *client { + return &client{Timeout: defaultTimeout, group: new(singleflight.Group)} } // ServeDNS does not satisfy middleware.Handler, instead it interacts with the upstream // and returns the respons or an error. -func (c *Client) ServeDNS(w dns.ResponseWriter, r *dns.Msg, u *UpstreamHost) (*dns.Msg, error) { +func (c *client) ServeDNS(w dns.ResponseWriter, r *dns.Msg, u *UpstreamHost) (*dns.Msg, error) { co, err := net.DialTimeout(request.Proto(w), u.Name, c.Timeout) if err != nil { return nil, err @@ -47,7 +47,7 @@ func (c *Client) ServeDNS(w dns.ResponseWriter, r *dns.Msg, u *UpstreamHost) (*d return reply, nil } -func (c *Client) Exchange(m *dns.Msg, co net.Conn) (*dns.Msg, time.Duration, error) { +func (c *client) Exchange(m *dns.Msg, co net.Conn) (*dns.Msg, time.Duration, error) { t := "nop" if t1, ok := dns.TypeToString[m.Question[0].Qtype]; ok { t = t1 @@ -76,7 +76,7 @@ func (c *Client) Exchange(m *dns.Msg, co net.Conn) (*dns.Msg, time.Duration, err // exchange does *not* return a pointer to dns.Msg because that leads to buffer reuse when // group.Do is used in Exchange. -func (c *Client) exchange(m *dns.Msg, co net.Conn) (dns.Msg, error) { +func (c *client) exchange(m *dns.Msg, co net.Conn) (dns.Msg, error) { opt := m.IsEdns0() udpsize := uint16(dns.MinMsgSize) diff --git a/middleware/proxy/lookup.go b/middleware/proxy/lookup.go index af39bc12b..549dfa0c7 100644 --- a/middleware/proxy/lookup.go +++ b/middleware/proxy/lookup.go @@ -13,7 +13,7 @@ import ( // New create a new proxy with the hosts in host and a Random policy. func New(hosts []string) Proxy { - p := Proxy{Next: nil, Client: NewClient()} + p := Proxy{Next: nil, Client: newClient()} upstream := &staticUpstream{ from: "", diff --git a/middleware/proxy/proxy.go b/middleware/proxy/proxy.go index 78383532a..a33024f12 100644 --- a/middleware/proxy/proxy.go +++ b/middleware/proxy/proxy.go @@ -17,7 +17,7 @@ var errUnreachable = errors.New("unreachable backend") // Proxy represents a middleware instance that can proxy requests to another DNS server. type Proxy struct { Next middleware.Handler - Client *Client + Client *client Upstreams []Upstream } diff --git a/middleware/proxy/setup.go b/middleware/proxy/setup.go index 5257d8bb0..26f01c11e 100644 --- a/middleware/proxy/setup.go +++ b/middleware/proxy/setup.go @@ -20,7 +20,7 @@ func setup(c *caddy.Controller) error { return middleware.Error("proxy", err) } dnsserver.GetConfig(c).AddMiddleware(func(next middleware.Handler) middleware.Handler { - return Proxy{Next: next, Client: NewClient(), Upstreams: upstreams} + return Proxy{Next: next, Client: newClient(), Upstreams: upstreams} }) return nil |