1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

remove buggy CloseWrite()

This commit is contained in:
Darien Raymond 2016-12-29 00:56:17 +01:00
parent 5ff2b3453a
commit 7bc98503a8
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
5 changed files with 28 additions and 12 deletions

View File

@ -13,6 +13,7 @@ import (
"v2ray.com/core/testing/assert"
"v2ray.com/core/testing/servers/tcp"
"v2ray.com/core/transport/internet"
_ "v2ray.com/core/transport/internet/tcp"
)
func TestProxyDial(t *testing.T) {

View File

@ -18,6 +18,7 @@ import (
"v2ray.com/core/testing/servers/tcp"
"v2ray.com/core/testing/servers/udp"
"v2ray.com/core/transport/internet"
_ "v2ray.com/core/transport/internet/tcp"
)
func TestDokodemoTCP(t *testing.T) {

View File

@ -15,7 +15,6 @@ import (
"v2ray.com/core/common/serial"
"v2ray.com/core/proxy"
"v2ray.com/core/transport/internet"
"v2ray.com/core/transport/internet/tcp"
"v2ray.com/core/transport/ray"
)
@ -109,9 +108,6 @@ func (v *Handler) Dispatch(destination v2net.Destination, payload *buf.Buffer, r
if err := buf.PipeUntilEOF(input, v2writer); err != nil {
log.Info("Freedom: Failed to transport all TCP request: ", err)
}
if tcpConn, ok := conn.(*tcp.RawConnection); ok {
tcpConn.CloseWrite()
}
}()
var reader io.Reader = conn

View File

@ -1,6 +1,7 @@
package freedom_test
import (
"fmt"
"testing"
"v2ray.com/core/app"
@ -18,6 +19,7 @@ import (
"v2ray.com/core/testing/assert"
"v2ray.com/core/testing/servers/tcp"
"v2ray.com/core/transport/internet"
_ "v2ray.com/core/transport/internet/tcp"
"v2ray.com/core/transport/ray"
)
@ -32,7 +34,7 @@ func TestSinglePacket(t *testing.T) {
return buffer
},
}
_, err := tcpServer.Start()
tcpServerAddr, err := tcpServer.Start()
assert.Error(err).IsNil()
space := app.NewSpace()
@ -52,7 +54,8 @@ func TestSinglePacket(t *testing.T) {
payload := buf.NewLocal(2048)
payload.Append([]byte(data2Send))
go freedom.Dispatch(v2net.TCPDestination(v2net.LocalHostIP, tcpServer.Port), payload, traffic)
fmt.Println(tcpServerAddr.Network, tcpServerAddr.Address, tcpServerAddr.Port)
go freedom.Dispatch(tcpServerAddr, payload, traffic)
traffic.InboundInput().Close()
respPayload, err := traffic.InboundOutput().Read()

View File

@ -1,11 +1,11 @@
package scenarios
import (
"bytes"
"io"
"fmt"
"net"
"testing"
"v2ray.com/core/common/buf"
v2net "v2ray.com/core/common/net"
"v2ray.com/core/testing/assert"
"v2ray.com/core/testing/servers/tcp"
@ -43,10 +43,25 @@ func TestDynamicVMess(t *testing.T) {
conn.CloseWrite()
response := bytes.NewBuffer(nil)
_, err = io.Copy(response, conn)
assert.Error(err).IsNil()
assert.String("Processed: " + payload).Equals(string(response.Bytes()))
expectedResponse := "Processed: " + payload
finished := false
response := buf.New()
for {
err := response.AppendSupplier(buf.ReadFrom(conn))
assert.Error(err).IsNil()
if err != nil {
break
}
if response.String() == expectedResponse {
finished = true
break
}
if response.Len() > len(expectedResponse) {
fmt.Printf("Unexpected response: %v\n", response.Bytes())
break
}
}
assert.Bool(finished).IsTrue()
conn.Close()
}