mirror of
https://github.com/cbeuw/Cloak.git
synced 2024-11-11 13:11:03 +00:00
Better redir piping behaviour
This commit is contained in:
parent
253ea94d2a
commit
de5c51d3e4
@ -141,8 +141,8 @@ func dispatchConnection(conn net.Conn, sta *State) {
|
||||
log.Error("Failed to send first packet to redirection server", err)
|
||||
return
|
||||
}
|
||||
go io.Copy(webConn, conn)
|
||||
go io.Copy(conn, webConn)
|
||||
go common.Copy(webConn, conn)
|
||||
go common.Copy(conn, webConn)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
@ -115,6 +115,24 @@ func TestReadFirstPacket(t *testing.T) {
|
||||
assert.NoError(t, ret.err)
|
||||
})
|
||||
|
||||
t.Run("TLS bad recordlayer length", func(t *testing.T) {
|
||||
local, remote := connutil.AsyncPipe()
|
||||
buf := make([]byte, 1500)
|
||||
retChan := make(chan rfpReturnValue)
|
||||
go rfp(remote, buf, retChan)
|
||||
|
||||
first, _ := hex.DecodeString("160301ffff")
|
||||
local.Write(first)
|
||||
|
||||
ret := <-retChan
|
||||
|
||||
assert.Equal(t, len(first), ret.n)
|
||||
assert.Equal(t, first, buf[:ret.n])
|
||||
assert.IsType(t, TLS{}, ret.transport)
|
||||
assert.Equal(t, io.ErrShortBuffer, ret.err)
|
||||
assert.True(t, ret.redirOnErr)
|
||||
})
|
||||
|
||||
t.Run("Good WebSocket", func(t *testing.T) {
|
||||
local, remote := connutil.AsyncPipe()
|
||||
buf := make([]byte, 1500)
|
||||
|
Loading…
Reference in New Issue
Block a user