|
|
|
@ -12,6 +12,28 @@ import (
|
|
|
|
|
"github.com/v2ray/v2ray-core/testing/servers/udp"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
serverUp = false
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func setupServer() error {
|
|
|
|
|
if serverUp {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
err := InitializeServer(TestFile("test_1_client.json"))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = InitializeServer(TestFile("test_1_server.json"))
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
serverUp = true
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestTCPConnection(t *testing.T) {
|
|
|
|
|
v2testing.Current(t)
|
|
|
|
|
|
|
|
|
@ -28,11 +50,7 @@ func TestTCPConnection(t *testing.T) {
|
|
|
|
|
_, err := tcpServer.Start()
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
|
|
err = InitializeServer(TestFile("test_1_client.json"))
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
|
|
err = InitializeServer(TestFile("test_1_server.json"))
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
assert.Error(setupServer()).IsNil()
|
|
|
|
|
|
|
|
|
|
socksPort := v2net.Port(50000)
|
|
|
|
|
|
|
|
|
@ -99,11 +117,7 @@ func TestTCPBind(t *testing.T) {
|
|
|
|
|
_, err := tcpServer.Start()
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
|
|
err = InitializeServer(TestFile("test_1_client.json"))
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
|
|
err = InitializeServer(TestFile("test_1_server.json"))
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
assert.Error(setupServer()).IsNil()
|
|
|
|
|
|
|
|
|
|
socksPort := v2net.Port(50000)
|
|
|
|
|
|
|
|
|
@ -151,11 +165,7 @@ func TestUDPAssociate(t *testing.T) {
|
|
|
|
|
_, err := udpServer.Start()
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
|
|
err = InitializeServer(TestFile("test_1_client.json"))
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
|
|
err = InitializeServer(TestFile("test_1_server.json"))
|
|
|
|
|
assert.Error(err).IsNil()
|
|
|
|
|
assert.Error(setupServer()).IsNil()
|
|
|
|
|
|
|
|
|
|
socksPort := v2net.Port(50000)
|
|
|
|
|
|
|
|
|
|