control/controlclient: fix the Noise HTTP/2 timeout config

We want to close the connection after a minute of inactivity,
not heartbeat once a minute to keep it alive forever.

Updates #3488

Change-Id: I4b5275e8d1f2528e13de2d54808773c70537db91
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
pull/4100/head
Brad Fitzpatrick 2 years ago committed by Brad Fitzpatrick
parent 740e3c006c
commit 21069124db

@ -74,14 +74,23 @@ func newNoiseClient(priKey key.MachinePrivate, serverPubKey key.MachinePublic, s
serverHost: host, serverHost: host,
} }
// Create a new http.Client which dials out using nc.Dial. // Create the HTTP/2 Transport using a net/http.Transport
np.Client = &http.Client{ // (which only does HTTP/1) because it's the only way to
Transport: &http2.Transport{ // configure certain properties on the http2.Transport. But we
ReadIdleTimeout: time.Minute, // never actually use the net/http.Transport for any HTTP/1
DialTLS: np.dial, // requests.
}, h2Transport, err := http2.ConfigureTransports(&http.Transport{
IdleConnTimeout: time.Minute,
})
if err != nil {
return nil, err
} }
// Let the HTTP/2 Transport think it's dialing out using TLS,
// but it's actually our Noise dialer:
h2Transport.DialTLS = np.dial
np.Client = &http.Client{Transport: h2Transport}
return np, nil return np, nil
} }

Loading…
Cancel
Save