netbird/relay/client/dialer/wsnhooyr/ws.go

23 lines
318 B
Go
Raw Normal View History

package wsnhooyr
import (
"context"
"fmt"
"net"
"nhooyr.io/websocket"
)
func Dial(address string) (net.Conn, error) {
addr := fmt.Sprintf("ws://" + address)
wsConn, _, err := websocket.Dial(context.Background(), addr, nil)
if err != nil {
return nil, err
}
conn := NewConn(wsConn)
return conn, nil
}