mirror of https://github.com/v2ray/v2ray-core
fix mux test
parent
dc76e36ed7
commit
0210a718f6
|
@ -30,6 +30,18 @@ func pickPort() v2net.Port {
|
|||
return v2net.Port(addr.Port)
|
||||
}
|
||||
|
||||
func pickUDPPort() v2net.Port {
|
||||
conn, err := net.ListenUDP("udp4", &net.UDPAddr{
|
||||
IP: v2net.LocalHostIP.IP(),
|
||||
Port: 0,
|
||||
})
|
||||
common.Must(err)
|
||||
defer conn.Close()
|
||||
|
||||
addr := conn.LocalAddr().(*net.UDPAddr)
|
||||
return v2net.Port(addr.Port)
|
||||
}
|
||||
|
||||
func xor(b []byte) []byte {
|
||||
r := make([]byte, len(b))
|
||||
for i, v := range b {
|
||||
|
|
|
@ -1095,7 +1095,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
|||
}
|
||||
|
||||
clientPort := pickPort()
|
||||
clientUDPPort := pickPort()
|
||||
clientUDPPort := pickUDPPort()
|
||||
clientConfig := &core.Config{
|
||||
Inbound: []*proxyman.InboundHandlerConfig{
|
||||
{
|
||||
|
@ -1203,7 +1203,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
|||
payload := make([]byte, 1024)
|
||||
rand.Read(payload)
|
||||
|
||||
for j := 0; j < 10; j++ {
|
||||
for j := 0; j < 5; j++ {
|
||||
nBytes, _, err := conn.WriteMsgUDP(payload, nil, nil)
|
||||
assert.Error(err).IsNil()
|
||||
assert.Int(nBytes).Equals(len(payload))
|
||||
|
@ -1211,7 +1211,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
|||
|
||||
response := make([]byte, 1024)
|
||||
oob := make([]byte, 16)
|
||||
for j := 0; j < 10; j++ {
|
||||
for j := 0; j < 5; j++ {
|
||||
nBytes, _, _, _, err := conn.ReadMsgUDP(response, oob)
|
||||
assert.Error(err).IsNil()
|
||||
assert.Int(nBytes).Equals(1024)
|
||||
|
|
Loading…
Reference in New Issue