From c4f6df47e5537882d182b0339ac94b1becdcfb01 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 8 Mar 2022 09:33:02 -0800 Subject: [PATCH] control/controlclient: fix Noise HTTP/2 regression from earlier commit Fix regression from 21069124db caught by tests in another repo. The HTTP/2 Transport that was being returned had a ConnPool that never dialed. Updates #3488 Change-Id: I3184d6393813448ae143d37ece14eb732334c05f Signed-off-by: Brad Fitzpatrick --- control/controlclient/noise.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/control/controlclient/noise.go b/control/controlclient/noise.go index dd65dea1d..8fb828f15 100644 --- a/control/controlclient/noise.go +++ b/control/controlclient/noise.go @@ -90,6 +90,15 @@ func newNoiseClient(priKey key.MachinePrivate, serverPubKey key.MachinePublic, s // but it's actually our Noise dialer: h2Transport.DialTLS = np.dial + // ConfigureTransports assumes it's being used to wire up an HTTP/1 + // and HTTP/2 Transport together, so its returned http2.Transport + // has a ConnPool already initialized that's configured to not dial + // (assuming it's only called from the HTTP/1 Transport). But we + // want it to dial, so nil it out before use. On first use it has + // a sync.Once that lazily initializes the ConnPool to its default + // one that dials. + h2Transport.ConnPool = nil + np.Client = &http.Client{Transport: h2Transport} return np, nil }