mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 19:29:57 +00:00
TUN-3817: Adds tests for websocket based streaming regression
This commit is contained in:

committed by
Nuno Diegues

parent
6681d179dc
commit
a6c2348127
@@ -5,6 +5,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
|
||||
"github.com/cloudflare/cloudflared/connection"
|
||||
"github.com/cloudflare/cloudflared/websocket"
|
||||
gws "github.com/gorilla/websocket"
|
||||
)
|
||||
@@ -15,6 +16,7 @@ type OriginConnection interface {
|
||||
// Stream should generally be implemented as a bidirectional io.Copy.
|
||||
Stream(tunnelConn io.ReadWriter)
|
||||
Close()
|
||||
Type() connection.Type
|
||||
}
|
||||
|
||||
type streamHandlerFunc func(originConn io.ReadWriter, remoteConn net.Conn)
|
||||
@@ -57,6 +59,10 @@ func (tc *tcpConnection) Close() {
|
||||
tc.conn.Close()
|
||||
}
|
||||
|
||||
func (*tcpConnection) Type() connection.Type {
|
||||
return connection.TypeTCP
|
||||
}
|
||||
|
||||
// wsConnection is an OriginConnection that streams to TCP packets by encapsulating them in Websockets.
|
||||
// TODO: TUN-3710 Remove wsConnection and have helloworld service reuse tcpConnection like bridgeService does.
|
||||
type wsConnection struct {
|
||||
@@ -73,6 +79,10 @@ func (wsc *wsConnection) Close() {
|
||||
wsc.wsConn.Close()
|
||||
}
|
||||
|
||||
func (wsc *wsConnection) Type() connection.Type {
|
||||
return connection.TypeWebsocket
|
||||
}
|
||||
|
||||
func newWSConnection(transport *http.Transport, r *http.Request) (OriginConnection, error) {
|
||||
d := &gws.Dialer{
|
||||
TLSClientConfig: transport.TLSClientConfig,
|
||||
|
Reference in New Issue
Block a user