1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-30 22:15:27 -05:00

fix test cases

This commit is contained in:
Darien Raymond
2017-01-29 09:02:19 +01:00
parent 6629b6dd28
commit ebf15aa6bb
4 changed files with 16 additions and 57 deletions

View File

@@ -1,6 +1,7 @@
package scenarios
import (
"io"
"net"
"time"
@@ -29,20 +30,10 @@ func xor(b []byte) []byte {
func readFrom(conn net.Conn, timeout time.Duration, length int) []byte {
b := make([]byte, 2048)
totalBytes := 0
deadline := time.Now().Add(timeout)
conn.SetReadDeadline(deadline)
for totalBytes < length {
if time.Now().After(deadline) {
break
}
n, err := conn.Read(b[totalBytes:])
if err != nil {
break
}
totalBytes += n
}
return b[:totalBytes]
n, _ := io.ReadFull(conn, b[:length])
return b[:n]
}
func InitializeServerConfig(config *core.Config) error {