mirror of
https://github.com/netbirdio/netbird.git
synced 2024-12-15 03:11:02 +01:00
23 lines
363 B
Go
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
|
|
}
|