diff --git a/control/controlclient/direct.go b/control/controlclient/direct.go index b1d991ce6..072b43447 100644 --- a/control/controlclient/direct.go +++ b/control/controlclient/direct.go @@ -333,6 +333,9 @@ func (c *Direct) Close() error { } } c.noiseClient = nil + if tr, ok := c.httpc.Transport.(*http.Transport); ok { + tr.CloseIdleConnections() + } return nil } diff --git a/net/dnsfallback/dnsfallback.go b/net/dnsfallback/dnsfallback.go index 8322d3887..4c5d5fa2f 100644 --- a/net/dnsfallback/dnsfallback.go +++ b/net/dnsfallback/dnsfallback.go @@ -281,6 +281,7 @@ type nameIP struct { func bootstrapDNSMap(ctx context.Context, serverName string, serverIP netip.Addr, queryName string, logf logger.Logf, ht *health.Tracker, netMon *netmon.Monitor) (dnsMap, error) { dialer := netns.NewDialer(logf, netMon) tr := http.DefaultTransport.(*http.Transport).Clone() + tr.DisableKeepAlives = true // This transport is meant to be used once. tr.Proxy = tshttpproxy.ProxyFromEnvironment tr.DialContext = func(ctx context.Context, netw, addr string) (net.Conn, error) { return dialer.DialContext(ctx, "tcp", net.JoinHostPort(serverIP.String(), "443")) diff --git a/net/tsdial/tsdial.go b/net/tsdial/tsdial.go index f0c4b1042..3606dd67f 100644 --- a/net/tsdial/tsdial.go +++ b/net/tsdial/tsdial.go @@ -166,6 +166,7 @@ func (d *Dialer) Close() error { c.Close() } d.activeSysConns = nil + d.PeerAPITransport().CloseIdleConnections() return nil }