netbird/relay/client/dialer/ws/ws.go
2024-06-05 19:49:30 +02:00

23 lines
363 B
Go

package ws
import (
"fmt"
"net"
"time"
"github.com/gorilla/websocket"
)
func Dial(address string) (net.Conn, error) {
addr := fmt.Sprintf("ws://" + address)
wsDialer := websocket.Dialer{
HandshakeTimeout: 3 * time.Second,
}
wsConn, _, err := wsDialer.Dial(addr, nil)
if err != nil {
return nil, err
}
conn := NewConn(wsConn)
return conn, nil
}