mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 15:49:58 +00:00
AUTH-2394 added socks5 proxy
This commit is contained in:
@@ -116,10 +116,15 @@ func Stream(conn, backendConn io.ReadWriter) {
|
||||
<-proxyDone
|
||||
}
|
||||
|
||||
// DefaultStreamHandler is provided to the the standard websocket to origin stream
|
||||
// This exist to allow SOCKS to deframe data before it gets to the origin
|
||||
func DefaultStreamHandler(wsConn *Conn, remoteConn net.Conn) {
|
||||
Stream(wsConn, remoteConn)
|
||||
}
|
||||
|
||||
// StartProxyServer will start a websocket server that will decode
|
||||
// the websocket data and write the resulting data to the provided
|
||||
// address
|
||||
func StartProxyServer(logger *logrus.Logger, listener net.Listener, remote string, shutdownC <-chan struct{}) error {
|
||||
func StartProxyServer(logger *logrus.Logger, listener net.Listener, remote string, shutdownC <-chan struct{}, streamHandler func(wsConn *Conn, remoteConn net.Conn)) error {
|
||||
upgrader := websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
@@ -165,7 +170,7 @@ func StartProxyServer(logger *logrus.Logger, listener net.Listener, remote strin
|
||||
}
|
||||
}
|
||||
|
||||
Stream(&Conn{conn}, stream)
|
||||
streamHandler(&Conn{conn}, stream)
|
||||
})
|
||||
|
||||
return httpServer.Serve(listener)
|
||||
|
Reference in New Issue
Block a user