mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-20 00:31:17 -08:00
Some HTTP proxies (as seen in ChatGPT Work's sandbox) intercept TLS and refuse DERP's "Upgrade: DERP" request but allow WebSocket upgrades, like browsers use. derphttp could already speak DERP over WebSockets, but only on js/wasm or with the ts_debug_websockets build tag and an envknob, and that path dials with its own http.Client, skipping the DERP node selection, proxy CONNECT, and TLS logic of the normal path. Add derphttp.HookUpgradeWebsocket. When it's set and a client's HTTP upgrade to DERP fails after any TLS handshake succeeded, the client redials and calls the hook to do a WebSocket handshake over the new connection instead. Once that works, the client keeps using WebSockets for its reconnects until they fail, so it doesn't pay for a refused upgrade every time. The new feature/derpwebsocket package sets the hook. Neither tailscaled nor tsnet links it in; programs that want the fallback, like tailcat, import it. Updates #22412 Signed-off-by: Brad Fitzpatrick <[email protected]> Change-Id: I20e4b29f1bca6e7e5e3b33f960ce9d331ec7dac9