1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-21 21:19:12 -04:00

fix udp handling in dokodemo and mux

This commit is contained in:
Darien Raymond
2017-05-02 23:36:37 +02:00
parent d5ef224ac0
commit d5f931ae8b
3 changed files with 28 additions and 11 deletions

View File

@@ -1198,15 +1198,26 @@ func TestVMessGCMMuxUDP(t *testing.T) {
})
assert.Error(err).IsNil()
conn.SetDeadline(time.Now().Add(time.Second * 10))
payload := make([]byte, 1024)
rand.Read(payload)
nBytes, err := conn.Write(payload)
assert.Error(err).IsNil()
assert.Int(nBytes).Equals(len(payload))
for j := 0; j < 10; j++ {
nBytes, _, err := conn.WriteMsgUDP(payload, nil, nil)
assert.Error(err).IsNil()
assert.Int(nBytes).Equals(len(payload))
}
response := make([]byte, 1024)
oob := make([]byte, 16)
for j := 0; j < 10; j++ {
nBytes, _, _, _, err := conn.ReadMsgUDP(response, oob)
assert.Error(err).IsNil()
assert.Int(nBytes).Equals(1024)
assert.Bytes(response).Equals(xor(payload))
}
response := readFrom(conn, time.Second*5, 1024)
assert.Bytes(response).Equals(xor(payload))
assert.Error(conn.Close()).IsNil()
wg.Done()
}()