control/controlhttp: allow client and server to communicate over WebSockets

We can't do Noise-over-HTTP in Wasm/JS (because we don't have bidirectional
communication), but we should be able to do it over WebSockets. Reuses
derp WebSocket support that allows us to turn a WebSocket connection
into a net.Conn.

Updates #3157

Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:
Mihai Parparita
2022-06-02 16:20:42 -07:00
committed by Mihai Parparita
parent 80157f3f37
commit a9f32656f5
10 changed files with 132 additions and 30 deletions

View File

@@ -1097,12 +1097,6 @@ func loadServerPubKeys(ctx context.Context, httpc *http.Client, serverURL string
var out tailcfg.OverTLSPublicKeyResponse
jsonErr := json.Unmarshal(b, &out)
if jsonErr == nil {
if runtime.GOOS == "js" {
// As of 2022-05-20 it's not possible for js/wasm to make a bidi
// Noise connection to the control plane. Instead, for now, pretend
// like the server can't do Noise to force use of the old protocol.
out.PublicKey = key.MachinePublic{}
}
return &out, nil
}