Better redir piping behaviour

This commit is contained in:
Andy Wang 2020-08-12 12:07:32 +01:00
parent 253ea94d2a
commit de5c51d3e4
2 changed files with 20 additions and 2 deletions

View File

@ -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 {

View File

@ -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)