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

23 lines
363 B
Go
Raw Normal View History

2024-05-17 17:43:28 +02:00
package ws
import (
"fmt"
"net"
2024-06-05 19:49:30 +02:00
"time"
2024-05-17 17:43:28 +02:00
"github.com/gorilla/websocket"
)
func Dial(address string) (net.Conn, error) {
addr := fmt.Sprintf("ws://" + address)
2024-06-05 19:49:30 +02:00
wsDialer := websocket.Dialer{
HandshakeTimeout: 3 * time.Second,
}
wsConn, _, err := wsDialer.Dial(addr, nil)
2024-05-17 17:43:28 +02:00
if err != nil {
return nil, err
}
conn := NewConn(wsConn)
return conn, nil
}