diff --git a/main.go b/main.go index a403e93..25c4084 100644 --- a/main.go +++ b/main.go @@ -81,10 +81,6 @@ const ( profilingPath = "/.pprof" ) -var dnsCache = &dnscache.Resolver{ - Timeout: 5 * time.Second, -} - func init() { // Create a new instance of the logger. You can have any number of instances. log2 = logrus.New() @@ -647,10 +643,11 @@ type roundTripperWrapper struct { } func (rtw *roundTripperWrapper) renew() { - dnsCache.Refresh() tr := &http.Transport{ - Proxy: http.ProxyFromEnvironment, - DialContext: dialContextWithDNSCache(dnsCache, newProxyDialContext(10*time.Second)), + Proxy: http.ProxyFromEnvironment, + DialContext: dialContextWithDNSCache(&dnscache.Resolver{ + Timeout: 5 * time.Second, + }, newProxyDialContext(10*time.Second)), MaxIdleConnsPerHost: 1024, WriteBufferSize: 32 << 10, // 32KiB moving up from 4KiB default ReadBufferSize: 32 << 10, // 32KiB moving up from 4KiB default @@ -929,15 +926,6 @@ func sidekickMain(ctx *cli.Context) { globalHostBalance = "least" } - go func() { - t := time.NewTicker(ctx.GlobalDuration("dns-ttl")) - defer t.Stop() - - for range t.C { - dnsCache.Refresh() - } - }() - if !strings.HasPrefix(healthCheckPath, slashSeparator) { healthCheckPath = slashSeparator + healthCheckPath }