netbird/relay/client/dialer/wsnhooyr/ws.go
2024-06-03 21:38:37 +02:00

23 lines
318 B
Go

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
}