Fix review comments

This commit is contained in:
Andrey Meshkov 2018-11-06 01:14:28 +03:00
parent 2e879896ff
commit cc40826299
3 changed files with 9 additions and 5 deletions

View File

@ -27,7 +27,7 @@ func NewDnsUpstream(endpoint string, proto string, tlsServerName string) (Upstre
var tlsConfig *tls.Config var tlsConfig *tls.Config
if tlsServerName != "" { if proto == "tcp-tls" {
tlsConfig = new(tls.Config) tlsConfig = new(tls.Config)
tlsConfig.ServerName = tlsServerName tlsConfig.ServerName = tlsServerName
} }
@ -101,6 +101,9 @@ func (u *DnsUpstream) exchange(proto string, query *dns.Msg) (r *dns.Msg, err er
conn.Close() // Not giving it back conn.Close() // Not giving it back
} }
u.transport.Yield(conn) if err == nil {
// Return it back to the connections cache if there were no errors
u.transport.Yield(conn)
}
return r, err return r, err
} }

View File

@ -72,8 +72,7 @@ func CreateResolver(bootstrap string) *net.Resolver {
PreferGo: true, PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) { Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
var d net.Dialer var d net.Dialer
conn, err := d.DialContext(ctx, network, bootstrap) return d.DialContext(ctx, network, bootstrap)
return conn, err
}, },
} }
} }

View File

@ -52,4 +52,6 @@ func (p *UpstreamPlugin) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *
} }
// Name implements interface for CoreDNS plugin // Name implements interface for CoreDNS plugin
func (p *UpstreamPlugin) Name() string { return "upstream" } func (p *UpstreamPlugin) Name() string {
return "upstream"
}