|
@@ -13,9 +13,7 @@ import (
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
var (
|
|
|
- EmptyRouting = func(v2net.Destination) bool {
|
|
|
|
|
- return false
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ serverUp = false
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func TestTCPConnection(t *testing.T) {
|
|
func TestTCPConnection(t *testing.T) {
|
|
@@ -34,13 +32,14 @@ func TestTCPConnection(t *testing.T) {
|
|
|
_, err := tcpServer.Start()
|
|
_, err := tcpServer.Start()
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
- v2rayPort, _, err := setUpV2Ray(EmptyRouting)
|
|
|
|
|
- assert.Error(err).IsNil()
|
|
|
|
|
|
|
+ assert.Error(InitializeServerSetOnce("test_1")).IsNil()
|
|
|
|
|
+
|
|
|
|
|
+ socksPort := v2net.Port(50000)
|
|
|
|
|
|
|
|
for i := 0; i < 100; i++ {
|
|
for i := 0; i < 100; i++ {
|
|
|
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
|
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
|
|
IP: []byte{127, 0, 0, 1},
|
|
IP: []byte{127, 0, 0, 1},
|
|
|
- Port: int(v2rayPort),
|
|
|
|
|
|
|
+ Port: int(socksPort),
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
authRequest := socks5AuthMethodRequest(byte(0))
|
|
authRequest := socks5AuthMethodRequest(byte(0))
|
|
@@ -100,12 +99,13 @@ func TestTCPBind(t *testing.T) {
|
|
|
_, err := tcpServer.Start()
|
|
_, err := tcpServer.Start()
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
- v2rayPort, _, err := setUpV2Ray(EmptyRouting)
|
|
|
|
|
- assert.Error(err).IsNil()
|
|
|
|
|
|
|
+ assert.Error(InitializeServerSetOnce("test_1")).IsNil()
|
|
|
|
|
+
|
|
|
|
|
+ socksPort := v2net.Port(50000)
|
|
|
|
|
|
|
|
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
|
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
|
|
IP: []byte{127, 0, 0, 1},
|
|
IP: []byte{127, 0, 0, 1},
|
|
|
- Port: int(v2rayPort),
|
|
|
|
|
|
|
+ Port: int(socksPort),
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
authRequest := socks5AuthMethodRequest(byte(0))
|
|
authRequest := socks5AuthMethodRequest(byte(0))
|
|
@@ -147,12 +147,13 @@ func TestUDPAssociate(t *testing.T) {
|
|
|
_, err := udpServer.Start()
|
|
_, err := udpServer.Start()
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
- v2rayPort, _, err := setUpV2Ray(EmptyRouting)
|
|
|
|
|
- assert.Error(err).IsNil()
|
|
|
|
|
|
|
+ assert.Error(InitializeServerSetOnce("test_1")).IsNil()
|
|
|
|
|
+
|
|
|
|
|
+ socksPort := v2net.Port(50000)
|
|
|
|
|
|
|
|
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
|
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
|
|
IP: []byte{127, 0, 0, 1},
|
|
IP: []byte{127, 0, 0, 1},
|
|
|
- Port: int(v2rayPort),
|
|
|
|
|
|
|
+ Port: int(socksPort),
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
authRequest := socks5AuthMethodRequest(byte(0))
|
|
authRequest := socks5AuthMethodRequest(byte(0))
|
|
@@ -173,11 +174,11 @@ func TestUDPAssociate(t *testing.T) {
|
|
|
connectResponse := make([]byte, 1024)
|
|
connectResponse := make([]byte, 1024)
|
|
|
nBytes, err = conn.Read(connectResponse)
|
|
nBytes, err = conn.Read(connectResponse)
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
- assert.Bytes(connectResponse[:nBytes]).Equals([]byte{socks5Version, 0, 0, 1, 127, 0, 0, 1, byte(v2rayPort >> 8), byte(v2rayPort)})
|
|
|
|
|
|
|
+ assert.Bytes(connectResponse[:nBytes]).Equals([]byte{socks5Version, 0, 0, 1, 127, 0, 0, 1, byte(socksPort >> 8), byte(socksPort)})
|
|
|
|
|
|
|
|
udpConn, err := net.DialUDP("udp", nil, &net.UDPAddr{
|
|
udpConn, err := net.DialUDP("udp", nil, &net.UDPAddr{
|
|
|
IP: []byte{127, 0, 0, 1},
|
|
IP: []byte{127, 0, 0, 1},
|
|
|
- Port: int(v2rayPort),
|
|
|
|
|
|
|
+ Port: int(socksPort),
|
|
|
})
|
|
})
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|