mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 17:46:58 -05:00
Explictly wait for server ready
This commit is contained in:
parent
9e4902d17a
commit
d77fdbd719
@ -3,6 +3,7 @@ package freedom
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/net/proxy"
|
||||
@ -20,6 +21,9 @@ func TestSocksTcpConnect(t *testing.T) {
|
||||
data2Send := "Data to be sent to remote"
|
||||
data2Return := "Data to be returned to local"
|
||||
|
||||
var serverReady sync.Mutex
|
||||
serverReady.Lock()
|
||||
|
||||
go func() {
|
||||
listener, err := net.ListenTCP("tcp", &net.TCPAddr{
|
||||
IP: []byte{0, 0, 0, 0},
|
||||
@ -27,6 +31,8 @@ func TestSocksTcpConnect(t *testing.T) {
|
||||
Zone: "",
|
||||
})
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
serverReady.Unlock()
|
||||
conn, err := listener.Accept()
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
@ -65,6 +71,8 @@ func TestSocksTcpConnect(t *testing.T) {
|
||||
socks5Client, err := proxy.SOCKS5("tcp", "127.0.0.1:38724", nil, proxy.Direct)
|
||||
assert.Error(err).IsNil()
|
||||
|
||||
serverReady.Lock()
|
||||
|
||||
targetServer := "127.0.0.1:48274"
|
||||
conn, err := socks5Client.Dial("tcp", targetServer)
|
||||
assert.Error(err).IsNil()
|
||||
|
Loading…
Reference in New Issue
Block a user