mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-20 08:16:55 -05:00
update reverse test
This commit is contained in:
parent
5c37439dbb
commit
84bb0f13a5
@ -1,13 +1,11 @@
|
||||
package scenarios
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"v2ray.com/core"
|
||||
"v2ray.com/core/app/log"
|
||||
"v2ray.com/core/app/policy"
|
||||
@ -15,7 +13,6 @@ import (
|
||||
"v2ray.com/core/app/reverse"
|
||||
"v2ray.com/core/app/router"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/errors"
|
||||
clog "v2ray.com/core/common/log"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/protocol"
|
||||
@ -193,34 +190,7 @@ func TestReverseProxy(t *testing.T) {
|
||||
|
||||
var errg errgroup.Group
|
||||
for i := 0; i < 32; i++ {
|
||||
errg.Go(func() error {
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(externalPort),
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
payload := make([]byte, 10240*1024)
|
||||
rand.Read(payload)
|
||||
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if nBytes != len(payload) {
|
||||
return errors.New("only part of payload is written: ", nBytes)
|
||||
}
|
||||
|
||||
response := readFrom(conn, time.Second*20, 10240*1024)
|
||||
if r := cmp.Diff(response, xor(payload)); r != "" {
|
||||
return errors.New(r)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
errg.Go(testTCPConn(externalPort, 10240*1024, time.Second*20))
|
||||
}
|
||||
|
||||
if err := errg.Wait(); err != nil {
|
||||
@ -418,27 +388,8 @@ func TestReverseProxyLongRunning(t *testing.T) {
|
||||
defer CloseAllServers(servers)
|
||||
|
||||
for i := 0; i < 4096; i++ {
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(externalPort),
|
||||
})
|
||||
common.Must(err)
|
||||
|
||||
payload := make([]byte, 1024)
|
||||
rand.Read(payload)
|
||||
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
common.Must(err)
|
||||
|
||||
if nBytes != len(payload) {
|
||||
t.Error("only part of payload is written: ", nBytes)
|
||||
if err := testTCPConn(externalPort, 1024, time.Second*10)(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
response := readFrom(conn, time.Second*5, 1024)
|
||||
if r := cmp.Diff(response, xor(payload)); r != "" {
|
||||
t.Error(r)
|
||||
}
|
||||
|
||||
conn.Close()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user