mirror of https://github.com/cbeuw/Cloak
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)
|
log.Error("Failed to send first packet to redirection server", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go io.Copy(webConn, conn)
|
go common.Copy(webConn, conn)
|
||||||
go io.Copy(conn, webConn)
|
go common.Copy(conn, webConn)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,24 @@ func TestReadFirstPacket(t *testing.T) {
|
||||||
assert.NoError(t, ret.err)
|
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) {
|
t.Run("Good WebSocket", func(t *testing.T) {
|
||||||
local, remote := connutil.AsyncPipe()
|
local, remote := connutil.AsyncPipe()
|
||||||
buf := make([]byte, 1500)
|
buf := make([]byte, 1500)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue