mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 21:15:39 +00:00
6c852fa817
Coder has just adopted nhooyr/websocket which unfortunately changes the import path. `github.com/coder/coder` imports `tailscale.com/net/wsconn` which was still pointing to `nhooyr.io/websocket`, but this change updates it. See https://coder.com/blog/websocket Updates #13154 Change-Id: I3dec6512472b14eae337ae22c5bcc1e3758888d5 Signed-off-by: Kyle Carberry <kyle@carberry.com>
33 lines
700 B
Go
33 lines
700 B
Go
// Copyright (c) Tailscale Inc & AUTHORS
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
//go:build linux || js
|
|
|
|
package derphttp
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"net"
|
|
|
|
"github.com/coder/websocket"
|
|
"tailscale.com/net/wsconn"
|
|
)
|
|
|
|
func init() {
|
|
dialWebsocketFunc = dialWebsocket
|
|
}
|
|
|
|
func dialWebsocket(ctx context.Context, urlStr string) (net.Conn, error) {
|
|
c, res, err := websocket.Dial(ctx, urlStr, &websocket.DialOptions{
|
|
Subprotocols: []string{"derp"},
|
|
})
|
|
if err != nil {
|
|
log.Printf("websocket Dial: %v, %+v", err, res)
|
|
return nil, err
|
|
}
|
|
log.Printf("websocket: connected to %v", urlStr)
|
|
netConn := wsconn.NetConn(context.Background(), c, websocket.MessageBinary, urlStr)
|
|
return netConn, nil
|
|
}
|