mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 01:27:03 -05:00
remove dep on assert lib
This commit is contained in:
parent
2a0f3591f4
commit
bdd71a44b4
@ -6,6 +6,7 @@ import (
|
||||
|
||||
"v2ray.com/core/app/stats"
|
||||
. "v2ray.com/core/app/stats/command"
|
||||
"v2ray.com/core/common"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
|
||||
@ -13,10 +14,10 @@ func TestGetStats(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
m, err := stats.NewManager(context.Background(), &stats.Config{})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
sc, err := m.RegisterCounter("test_counter")
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
sc.Set(1)
|
||||
|
||||
@ -50,7 +51,7 @@ func TestGetStats(t *testing.T) {
|
||||
if tc.err {
|
||||
assert(err, IsNotNil)
|
||||
} else {
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp.Stat.Name, Equals, tc.name)
|
||||
assert(resp.Stat.Value, Equals, tc.value)
|
||||
}
|
||||
@ -61,25 +62,25 @@ func TestQueryStats(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
m, err := stats.NewManager(context.Background(), &stats.Config{})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
sc1, err := m.RegisterCounter("test_counter")
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
sc1.Set(1)
|
||||
|
||||
sc2, err := m.RegisterCounter("test_counter_2")
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
sc2.Set(2)
|
||||
|
||||
sc3, err := m.RegisterCounter("test_counter_3")
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
sc3.Set(3)
|
||||
|
||||
s := NewStatsServer(m)
|
||||
resp, err := s.QueryStats(context.Background(), &QueryStatsRequest{
|
||||
Pattern: "counter_",
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(len(resp.Stat), Equals, 2)
|
||||
|
||||
v2 := false
|
||||
|
@ -28,11 +28,11 @@ func TestBytesReaderWriteTo(t *testing.T) {
|
||||
writer.SetBuffered(false)
|
||||
|
||||
nBytes, err := io.Copy(writer, reader)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, int64(6))
|
||||
|
||||
mb, err := pReader2.ReadMultiBuffer()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(len(mb), Equals, 2)
|
||||
assert(mb[0].String(), Equals, "abc")
|
||||
assert(mb[1].String(), Equals, "efg")
|
||||
@ -52,7 +52,7 @@ func TestBytesReaderMultiBuffer(t *testing.T) {
|
||||
|
||||
mbReader := NewReader(reader)
|
||||
mb, err := mbReader.ReadMultiBuffer()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(len(mb), Equals, 2)
|
||||
assert(mb[0].String(), Equals, "abc")
|
||||
assert(mb[1].String(), Equals, "efg")
|
||||
|
@ -26,7 +26,7 @@ func TestWriter(t *testing.T) {
|
||||
writer := NewBufferedWriter(NewWriter(writeBuffer))
|
||||
writer.SetBuffered(false)
|
||||
err := writer.WriteMultiBuffer(MultiBuffer{lb})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(writer.Flush(), IsNil)
|
||||
assert(expectedBytes, Equals, writeBuffer.Bytes())
|
||||
}
|
||||
@ -46,7 +46,7 @@ func TestBytesWriterReadFrom(t *testing.T) {
|
||||
}
|
||||
|
||||
mb, err := pReader.ReadMultiBuffer()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(mb.Len(), Equals, int32(size))
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ func TestDiscardBytes(t *testing.T) {
|
||||
|
||||
nBytes, err := io.Copy(DiscardBytes, b)
|
||||
assert(nBytes, Equals, int64(Size))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
}
|
||||
|
||||
func TestDiscardBytesMultiBuffer(t *testing.T) {
|
||||
@ -71,7 +71,7 @@ func TestDiscardBytesMultiBuffer(t *testing.T) {
|
||||
r := NewReader(buffer)
|
||||
nBytes, err := io.Copy(DiscardBytes, &BufferedReader{Reader: r})
|
||||
assert(nBytes, Equals, int64(size))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
}
|
||||
|
||||
func TestWriterInterface(t *testing.T) {
|
||||
|
@ -21,10 +21,10 @@ func TestAuthenticationReaderWriter(t *testing.T) {
|
||||
key := make([]byte, 16)
|
||||
rand.Read(key)
|
||||
block, err := aes.NewCipher(key)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
aead, err := cipher.NewGCM(block)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
const payloadSize = 1024 * 80
|
||||
rawPayload := make([]byte, payloadSize)
|
||||
@ -57,7 +57,7 @@ func TestAuthenticationReaderWriter(t *testing.T) {
|
||||
|
||||
for mb.Len() < payloadSize {
|
||||
mb2, err := reader.ReadMultiBuffer()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
mb, _ = buf.MergeMulti(mb, mb2)
|
||||
}
|
||||
@ -78,10 +78,10 @@ func TestAuthenticationReaderWriterPacket(t *testing.T) {
|
||||
key := make([]byte, 16)
|
||||
common.Must2(rand.Read(key))
|
||||
block, err := aes.NewCipher(key)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
aead, err := cipher.NewGCM(block)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
cache := buf.New()
|
||||
iv := make([]byte, 12)
|
||||
@ -105,7 +105,7 @@ func TestAuthenticationReaderWriterPacket(t *testing.T) {
|
||||
assert(writer.WriteMultiBuffer(payload), IsNil)
|
||||
assert(cache.Len(), GreaterThan, int32(0))
|
||||
assert(writer.WriteMultiBuffer(buf.MultiBuffer{}), IsNil)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
reader := NewAuthenticationReader(&AEADAuthenticator{
|
||||
AEAD: aead,
|
||||
@ -114,7 +114,7 @@ func TestAuthenticationReaderWriterPacket(t *testing.T) {
|
||||
}, PlainChunkSizeParser{}, cache, protocol.TransferTypePacket, nil)
|
||||
|
||||
mb, err := reader.ReadMultiBuffer()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
mb, b1 := buf.SplitFirst(mb)
|
||||
assert(b1.String(), Equals, "abcd")
|
||||
|
@ -40,7 +40,7 @@ func TestChunkStreamIO(t *testing.T) {
|
||||
assert(mb[0].Bytes(), Equals, []byte("abcd"))
|
||||
|
||||
mb, err = reader.ReadMultiBuffer()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(mb.Len(), Equals, int32(3))
|
||||
assert(mb[0].Bytes(), Equals, []byte("efg"))
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
. "v2ray.com/core/common/mux"
|
||||
"v2ray.com/core/common/net"
|
||||
@ -63,72 +64,72 @@ func TestReaderWriter(t *testing.T) {
|
||||
|
||||
var meta FrameMetadata
|
||||
err := meta.Unmarshal(bytesReader)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(meta.SessionID, Equals, uint16(1))
|
||||
assert(byte(meta.SessionStatus), Equals, byte(SessionStatusNew))
|
||||
assert(meta.Target, Equals, dest)
|
||||
assert(byte(meta.Option), Equals, byte(OptionData))
|
||||
|
||||
data, err := readAll(NewStreamReader(bytesReader))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(len(data), Equals, 1)
|
||||
assert(data[0].String(), Equals, "abcd")
|
||||
|
||||
err = meta.Unmarshal(bytesReader)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(byte(meta.SessionStatus), Equals, byte(SessionStatusNew))
|
||||
assert(meta.SessionID, Equals, uint16(2))
|
||||
assert(byte(meta.Option), Equals, byte(0))
|
||||
assert(meta.Target, Equals, dest2)
|
||||
|
||||
err = meta.Unmarshal(bytesReader)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(byte(meta.SessionStatus), Equals, byte(SessionStatusKeep))
|
||||
assert(meta.SessionID, Equals, uint16(1))
|
||||
assert(byte(meta.Option), Equals, byte(1))
|
||||
|
||||
data, err = readAll(NewStreamReader(bytesReader))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(len(data), Equals, 1)
|
||||
assert(data[0].String(), Equals, "efgh")
|
||||
|
||||
err = meta.Unmarshal(bytesReader)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(byte(meta.SessionStatus), Equals, byte(SessionStatusNew))
|
||||
assert(meta.SessionID, Equals, uint16(3))
|
||||
assert(byte(meta.Option), Equals, byte(1))
|
||||
assert(meta.Target, Equals, dest3)
|
||||
|
||||
data, err = readAll(NewStreamReader(bytesReader))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(len(data), Equals, 1)
|
||||
assert(data[0].String(), Equals, "x")
|
||||
|
||||
err = meta.Unmarshal(bytesReader)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(byte(meta.SessionStatus), Equals, byte(SessionStatusEnd))
|
||||
assert(meta.SessionID, Equals, uint16(1))
|
||||
assert(byte(meta.Option), Equals, byte(0))
|
||||
|
||||
err = meta.Unmarshal(bytesReader)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(byte(meta.SessionStatus), Equals, byte(SessionStatusEnd))
|
||||
assert(meta.SessionID, Equals, uint16(3))
|
||||
assert(byte(meta.Option), Equals, byte(0))
|
||||
|
||||
err = meta.Unmarshal(bytesReader)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(byte(meta.SessionStatus), Equals, byte(SessionStatusKeep))
|
||||
assert(meta.SessionID, Equals, uint16(2))
|
||||
assert(byte(meta.Option), Equals, byte(1))
|
||||
|
||||
data, err = readAll(NewStreamReader(bytesReader))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(len(data), Equals, 1)
|
||||
assert(data[0].String(), Equals, "y")
|
||||
|
||||
err = meta.Unmarshal(bytesReader)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(byte(meta.SessionStatus), Equals, byte(SessionStatusEnd))
|
||||
assert(meta.SessionID, Equals, uint16(2))
|
||||
assert(byte(meta.Option), Equals, byte(0))
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
. "v2ray.com/core/common/platform"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
@ -47,7 +48,7 @@ func TestGetAssetLocation(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
exec, err := os.Executable()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
loc := GetAssetLocation("t")
|
||||
assert(filepath.Dir(loc), Equals, filepath.Dir(exec))
|
||||
@ -64,7 +65,7 @@ func TestGetPluginLocation(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
exec, err := os.Executable()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
loc := GetPluginDirectory()
|
||||
assert(loc, Equals, filepath.Join(filepath.Dir(exec), "plugins"))
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/net"
|
||||
|
||||
. "v2ray.com/core/common/protocol/http"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
@ -41,7 +41,7 @@ Accept-Language: de,en;q=0.7,en-us;q=0.3
|
||||
`
|
||||
b := bufio.NewReader(strings.NewReader(rawRequest))
|
||||
req, err := http.ReadRequest(b)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(req.Header.Get("Foo"), Equals, "foo")
|
||||
assert(req.Header.Get("Bar"), Equals, "bar")
|
||||
assert(req.Header.Get("Connection"), Equals, "keep-alive,Foo, Bar")
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/errors"
|
||||
. "v2ray.com/core/common/retry"
|
||||
. "v2ray.com/ext/assert"
|
||||
@ -22,7 +23,7 @@ func TestNoRetry(t *testing.T) {
|
||||
})
|
||||
endTime := time.Now().Unix()
|
||||
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(endTime-startTime, AtLeast, int64(0))
|
||||
}
|
||||
|
||||
@ -40,7 +41,7 @@ func TestRetryOnce(t *testing.T) {
|
||||
})
|
||||
duration := time.Since(startTime)
|
||||
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(int64(duration/time.Millisecond), AtLeast, int64(900))
|
||||
}
|
||||
|
||||
@ -58,7 +59,7 @@ func TestRetryMultiple(t *testing.T) {
|
||||
})
|
||||
duration := time.Since(startTime)
|
||||
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(int64(duration/time.Millisecond), AtLeast, int64(4900))
|
||||
}
|
||||
|
||||
|
@ -7,49 +7,54 @@ import (
|
||||
"time"
|
||||
|
||||
. "v2ray.com/core/common/signal"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
|
||||
func TestActivityTimer(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
timer := CancelAfterInactivity(ctx, cancel, time.Second*4)
|
||||
time.Sleep(time.Second * 6)
|
||||
assert(ctx.Err(), IsNotNil)
|
||||
if ctx.Err() == nil {
|
||||
t.Error("expected some error, but got nil")
|
||||
}
|
||||
runtime.KeepAlive(timer)
|
||||
}
|
||||
|
||||
func TestActivityTimerUpdate(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
timer := CancelAfterInactivity(ctx, cancel, time.Second*10)
|
||||
time.Sleep(time.Second * 3)
|
||||
assert(ctx.Err(), IsNil)
|
||||
if ctx.Err() != nil {
|
||||
t.Error("expected nil, but got ", ctx.Err().Error())
|
||||
}
|
||||
timer.SetTimeout(time.Second * 1)
|
||||
time.Sleep(time.Second * 2)
|
||||
assert(ctx.Err(), IsNotNil)
|
||||
if ctx.Err() == nil {
|
||||
t.Error("expcted some error, but got nil")
|
||||
}
|
||||
runtime.KeepAlive(timer)
|
||||
}
|
||||
|
||||
func TestActivityTimerNonBlocking(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
timer := CancelAfterInactivity(ctx, cancel, 0)
|
||||
time.Sleep(time.Second * 1)
|
||||
assert(ctx, HasDone)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
default:
|
||||
t.Error("context not done")
|
||||
}
|
||||
timer.SetTimeout(0)
|
||||
timer.SetTimeout(1)
|
||||
timer.SetTimeout(2)
|
||||
}
|
||||
|
||||
func TestActivityTimerZeroTimeout(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
timer := CancelAfterInactivity(ctx, cancel, 0)
|
||||
assert(ctx, HasDone)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
default:
|
||||
t.Error("context not done")
|
||||
}
|
||||
runtime.KeepAlive(timer)
|
||||
}
|
||||
|
@ -3,17 +3,17 @@ package task_test
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
. "v2ray.com/core/common/task"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
|
||||
func TestExecuteParallel(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
err := Run(context.Background(),
|
||||
func() error {
|
||||
time.Sleep(time.Millisecond * 200)
|
||||
@ -23,12 +23,12 @@ func TestExecuteParallel(t *testing.T) {
|
||||
return errors.New("test2")
|
||||
})
|
||||
|
||||
assert(err.Error(), Equals, "test")
|
||||
if r := cmp.Diff(err.Error(), "test"); r != "" {
|
||||
t.Error(r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteParallelContextCancel(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
err := Run(ctx, func() error {
|
||||
time.Sleep(time.Millisecond * 2000)
|
||||
@ -41,7 +41,10 @@ func TestExecuteParallelContextCancel(t *testing.T) {
|
||||
return nil
|
||||
})
|
||||
|
||||
assert(err.Error(), HasSubstring, "canceled")
|
||||
errStr := err.Error()
|
||||
if !strings.Contains(errStr, "canceled") {
|
||||
t.Error("expected error string to contain 'canceled', but actually not: ", errStr)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkExecuteOne(b *testing.B) {
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"testing"
|
||||
|
||||
. "v2ray.com/core/common"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
|
||||
type TConfig struct {
|
||||
@ -17,8 +16,6 @@ type YConfig struct {
|
||||
}
|
||||
|
||||
func TestObjectCreation(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
var f = func(ctx context.Context, t interface{}) (interface{}, error) {
|
||||
return func() int {
|
||||
return t.(*TConfig).value
|
||||
@ -27,12 +24,18 @@ func TestObjectCreation(t *testing.T) {
|
||||
|
||||
Must(RegisterConfig((*TConfig)(nil), f))
|
||||
err := RegisterConfig((*TConfig)(nil), f)
|
||||
assert(err, IsNotNil)
|
||||
if err == nil {
|
||||
t.Error("expect non-nil error, but got nil")
|
||||
}
|
||||
|
||||
g, err := CreateObject(context.Background(), &TConfig{value: 2})
|
||||
assert(err, IsNil)
|
||||
assert(g.(func() int)(), Equals, 2)
|
||||
Must(err)
|
||||
if v := g.(func() int)(); v != 2 {
|
||||
t.Error("expect return value 2, but got ", v)
|
||||
}
|
||||
|
||||
_, err = CreateObject(context.Background(), &YConfig{value: "T"})
|
||||
assert(err, IsNotNil)
|
||||
if err == nil {
|
||||
t.Error("expect non-nil error, but got nil")
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func TestNewUUID(t *testing.T) {
|
||||
uuid := New()
|
||||
uuid2, err := ParseString(uuid.String())
|
||||
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(uuid.String(), Equals, uuid2.String())
|
||||
assert(uuid.Bytes(), Equals, uuid2.Bytes())
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
|
||||
"v2ray.com/core/common"
|
||||
. "v2ray.com/core/proxy/mtproto"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
|
||||
func TestInverse(t *testing.T) {
|
||||
@ -31,15 +30,24 @@ func TestInverse(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAuthenticationReadWrite(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
a := NewAuthentication(DefaultSessionContext())
|
||||
b := bytes.NewReader(a.Header[:])
|
||||
a2, err := ReadAuthentication(b)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
assert(a.EncodingKey[:], Equals, a2.DecodingKey[:])
|
||||
assert(a.EncodingNonce[:], Equals, a2.DecodingNonce[:])
|
||||
assert(a.DecodingKey[:], Equals, a2.EncodingKey[:])
|
||||
assert(a.DecodingNonce[:], Equals, a2.EncodingNonce[:])
|
||||
if r := cmp.Diff(a.EncodingKey[:], a2.DecodingKey[:]); r != "" {
|
||||
t.Error("decoding key: ", r)
|
||||
}
|
||||
|
||||
if r := cmp.Diff(a.EncodingNonce[:], a2.DecodingNonce[:]); r != "" {
|
||||
t.Error("decoding nonce: ", r)
|
||||
}
|
||||
|
||||
if r := cmp.Diff(a.DecodingKey[:], a2.EncodingKey[:]); r != "" {
|
||||
t.Error("encoding key: ", r)
|
||||
}
|
||||
|
||||
if r := cmp.Diff(a.DecodingNonce[:], a2.EncodingNonce[:]); r != "" {
|
||||
t.Error("encoding nonce: ", r)
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,13 @@ package shadowsocks_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/protocol"
|
||||
. "v2ray.com/core/proxy/shadowsocks"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
|
||||
func toAccount(a *Account) protocol.Account {
|
||||
@ -18,8 +19,6 @@ func toAccount(a *Account) protocol.Account {
|
||||
}
|
||||
|
||||
func TestUDPEncoding(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
request := &protocol.RequestHeader{
|
||||
Version: Version,
|
||||
Command: protocol.RequestCommandUDP,
|
||||
@ -38,19 +37,21 @@ func TestUDPEncoding(t *testing.T) {
|
||||
data := buf.New()
|
||||
common.Must2(data.WriteString("test string"))
|
||||
encodedData, err := EncodeUDPPacket(request, data.Bytes())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
decodedRequest, decodedData, err := DecodeUDPPacket(request.User, encodedData)
|
||||
assert(err, IsNil)
|
||||
assert(decodedData.Bytes(), Equals, data.Bytes())
|
||||
assert(decodedRequest.Address, Equals, request.Address)
|
||||
assert(decodedRequest.Port, Equals, request.Port)
|
||||
assert(decodedRequest.Command, Equals, request.Command)
|
||||
common.Must(err)
|
||||
|
||||
if r := cmp.Diff(decodedData.Bytes(), data.Bytes()); r != "" {
|
||||
t.Error("data: ", r)
|
||||
}
|
||||
|
||||
if r := cmp.Diff(decodedRequest, request); r != "" {
|
||||
t.Error("request: ", r)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTCPRequest(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
cases := []struct {
|
||||
request *protocol.RequestHeader
|
||||
payload []byte
|
||||
@ -116,19 +117,21 @@ func TestTCPRequest(t *testing.T) {
|
||||
defer cache.Release()
|
||||
|
||||
writer, err := WriteTCPRequest(request, cache)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
assert(writer.WriteMultiBuffer(buf.MultiBuffer{data}), IsNil)
|
||||
common.Must(writer.WriteMultiBuffer(buf.MultiBuffer{data}))
|
||||
|
||||
decodedRequest, reader, err := ReadTCPSession(request.User, cache)
|
||||
assert(err, IsNil)
|
||||
assert(decodedRequest.Address, Equals, request.Address)
|
||||
assert(decodedRequest.Port, Equals, request.Port)
|
||||
assert(decodedRequest.Command, Equals, request.Command)
|
||||
common.Must(err)
|
||||
if r := cmp.Diff(decodedRequest, request); r != "" {
|
||||
t.Error("request: ", r)
|
||||
}
|
||||
|
||||
decodedData, err := reader.ReadMultiBuffer()
|
||||
assert(err, IsNil)
|
||||
assert(decodedData[0].String(), Equals, string(payload))
|
||||
common.Must(err)
|
||||
if r := cmp.Diff(decodedData[0].Bytes(), payload); r != "" {
|
||||
t.Error("data: ", r)
|
||||
}
|
||||
}
|
||||
|
||||
for _, test := range cases {
|
||||
@ -138,8 +141,6 @@ func TestTCPRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUDPReaderWriter(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
user := &protocol.MemoryUser{
|
||||
Account: toAccount(&Account{
|
||||
Password: "test-password",
|
||||
@ -168,22 +169,24 @@ func TestUDPReaderWriter(t *testing.T) {
|
||||
{
|
||||
b := buf.New()
|
||||
common.Must2(b.WriteString("test payload"))
|
||||
err := writer.WriteMultiBuffer(buf.MultiBuffer{b})
|
||||
assert(err, IsNil)
|
||||
common.Must(writer.WriteMultiBuffer(buf.MultiBuffer{b}))
|
||||
|
||||
payload, err := reader.ReadMultiBuffer()
|
||||
assert(err, IsNil)
|
||||
assert(payload[0].String(), Equals, "test payload")
|
||||
common.Must(err)
|
||||
if payload[0].String() != "test payload" {
|
||||
t.Error("unexpected output: ", payload[0].String())
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
b := buf.New()
|
||||
common.Must2(b.WriteString("test payload 2"))
|
||||
err := writer.WriteMultiBuffer(buf.MultiBuffer{b})
|
||||
assert(err, IsNil)
|
||||
common.Must(writer.WriteMultiBuffer(buf.MultiBuffer{b}))
|
||||
|
||||
payload, err := reader.ReadMultiBuffer()
|
||||
assert(err, IsNil)
|
||||
assert(payload[0].String(), Equals, "test payload 2")
|
||||
common.Must(err)
|
||||
if payload[0].String() != "test payload 2" {
|
||||
t.Error("unexpected output: ", payload[0].String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func TestRequestSerialization(t *testing.T) {
|
||||
|
||||
server := NewServerSession(userValidator, sessionHistory)
|
||||
actualRequest, err := server.DecodeRequestHeader(buffer)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
assert(expectedRequest.Version, Equals, actualRequest.Version)
|
||||
assert(byte(expectedRequest.Command), Equals, byte(actualRequest.Command))
|
||||
@ -151,7 +151,7 @@ func TestMuxRequest(t *testing.T) {
|
||||
|
||||
server := NewServerSession(userValidator, sessionHistory)
|
||||
actualRequest, err := server.DecodeRequestHeader(buffer)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
assert(expectedRequest.Version, Equals, actualRequest.Version)
|
||||
assert(byte(expectedRequest.Command), Equals, byte(actualRequest.Command))
|
||||
|
@ -9,12 +9,9 @@ import (
|
||||
"v2ray.com/core/common/serial"
|
||||
"v2ray.com/core/common/uuid"
|
||||
. "v2ray.com/core/proxy/vmess"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
|
||||
func TestUserValidator(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
hasher := protocol.DefaultIDHash
|
||||
v := NewTimedUserValidator(hasher)
|
||||
defer common.Close(v)
|
||||
@ -43,9 +40,15 @@ func TestUserValidator(t *testing.T) {
|
||||
userHash := idHash.Sum(nil)
|
||||
|
||||
euser, ets, found := v.Get(userHash)
|
||||
assert(found, IsTrue)
|
||||
assert(euser.Email, Equals, user.Email)
|
||||
assert(int64(ets), Equals, int64(ts))
|
||||
if !found {
|
||||
t.Fatal("user not found")
|
||||
}
|
||||
if euser.Email != user.Email {
|
||||
t.Error("unexpected user email: ", euser.Email, " want ", user.Email)
|
||||
}
|
||||
if ets != ts {
|
||||
t.Error("unexpected timestamp: ", ets, " want ", ts)
|
||||
}
|
||||
}
|
||||
|
||||
testSmallLag(0)
|
||||
@ -65,8 +68,9 @@ func TestUserValidator(t *testing.T) {
|
||||
userHash := idHash.Sum(nil)
|
||||
|
||||
euser, _, found := v.Get(userHash)
|
||||
assert(found, IsFalse)
|
||||
assert(euser, IsNil)
|
||||
if found || euser != nil {
|
||||
t.Error("unexpected user")
|
||||
}
|
||||
}
|
||||
|
||||
testBigLag(121)
|
||||
@ -77,6 +81,10 @@ func TestUserValidator(t *testing.T) {
|
||||
testBigLag(-500)
|
||||
}
|
||||
|
||||
assert(v.Remove(user.Email), IsTrue)
|
||||
assert(v.Remove(user.Email), IsFalse)
|
||||
if v := v.Remove(user.Email); !v {
|
||||
t.Error("unable to remove user")
|
||||
}
|
||||
if v := v.Remove(user.Email); v {
|
||||
t.Error("remove user twice")
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"v2ray.com/core/app/router"
|
||||
"v2ray.com/core/app/stats"
|
||||
statscmd "v2ray.com/core/app/stats/command"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/protocol"
|
||||
"v2ray.com/core/common/serial"
|
||||
@ -38,7 +39,7 @@ func TestCommanderRemoveHandler(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
clientPort := tcp.PickPort()
|
||||
@ -97,7 +98,7 @@ func TestCommanderRemoveHandler(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
defer CloseAllServers(servers)
|
||||
|
||||
@ -113,26 +114,26 @@ func TestCommanderRemoveHandler(t *testing.T) {
|
||||
|
||||
payload := "commander request."
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
if r := cmp.Diff(response[:nBytes], xor([]byte(payload))); r != "" {
|
||||
t.Fatal(r)
|
||||
}
|
||||
}
|
||||
|
||||
cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithInsecure(), grpc.WithBlock())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer cmdConn.Close()
|
||||
|
||||
hsClient := command.NewHandlerServiceClient(cmdConn)
|
||||
resp, err := hsClient.RemoveInbound(context.Background(), &command.RemoveInboundRequest{
|
||||
Tag: "d",
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp, IsNotNil)
|
||||
|
||||
{
|
||||
@ -151,7 +152,7 @@ func TestCommanderAddRemoveUser(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
u1 := protocol.NewID(uuid.New())
|
||||
@ -282,18 +283,18 @@ func TestCommanderAddRemoveUser(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "commander request."
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
@ -304,7 +305,7 @@ func TestCommanderAddRemoveUser(t *testing.T) {
|
||||
}
|
||||
|
||||
cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithInsecure(), grpc.WithBlock())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer cmdConn.Close()
|
||||
|
||||
hsClient := command.NewHandlerServiceClient(cmdConn)
|
||||
@ -321,7 +322,7 @@ func TestCommanderAddRemoveUser(t *testing.T) {
|
||||
},
|
||||
}),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp, IsNotNil)
|
||||
|
||||
{
|
||||
@ -329,16 +330,16 @@ func TestCommanderAddRemoveUser(t *testing.T) {
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "commander request."
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
}
|
||||
@ -348,7 +349,7 @@ func TestCommanderAddRemoveUser(t *testing.T) {
|
||||
Operation: serial.ToTypedMessage(&command.RemoveUserOperation{Email: "test@v2ray.com"}),
|
||||
})
|
||||
assert(resp, IsNotNil)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
CloseAllServers(servers)
|
||||
}
|
||||
@ -360,7 +361,7 @@ func TestCommanderStats(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
userID := protocol.NewID(uuid.New())
|
||||
@ -503,7 +504,7 @@ func TestCommanderStats(t *testing.T) {
|
||||
}
|
||||
|
||||
cmdConn, err := grpc.Dial(fmt.Sprintf("127.0.0.1:%d", cmdPort), grpc.WithInsecure(), grpc.WithBlock())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer cmdConn.Close()
|
||||
|
||||
const name = "user>>>test>>>traffic>>>uplink"
|
||||
@ -513,14 +514,14 @@ func TestCommanderStats(t *testing.T) {
|
||||
Name: name,
|
||||
Reset_: true,
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(sresp.Stat.Name, Equals, name)
|
||||
assert(sresp.Stat.Value, Equals, int64(10240*1024))
|
||||
|
||||
sresp, err = sClient.GetStats(context.Background(), &statscmd.GetStatsRequest{
|
||||
Name: name,
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(sresp.Stat.Name, Equals, name)
|
||||
assert(sresp.Stat.Value, Equals, int64(0))
|
||||
|
||||
@ -528,6 +529,6 @@ func TestCommanderStats(t *testing.T) {
|
||||
Name: "inbound>>>vmess>>>traffic>>>uplink",
|
||||
Reset_: true,
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(sresp.Stat.Value, GreaterThan, int64(10240*1024))
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"v2ray.com/core/app/dns"
|
||||
"v2ray.com/core/app/proxyman"
|
||||
"v2ray.com/core/app/router"
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/serial"
|
||||
"v2ray.com/core/proxy/blackhole"
|
||||
@ -25,7 +26,7 @@ func TestResolveIP(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -83,22 +84,22 @@ func TestResolveIP(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
noAuthDialer, err := xproxy.SOCKS5("tcp", net.TCPDestination(net.LocalHostIP, serverPort).NetAddr(), nil, xproxy.Direct)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
conn, err := noAuthDialer.Dial("tcp", fmt.Sprintf("google.com:%d", dest.Port))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "test payload"
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ func TestDokodemoUDP(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := udpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer udpServer.Close()
|
||||
|
||||
userID := protocol.NewID(uuid.New())
|
||||
@ -197,23 +197,23 @@ func TestDokodemoUDP(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
for port := clientPort; port <= clientPort+clientPortRange; port++ {
|
||||
conn, err := net.DialUDP("udp", nil, &net.UDPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(port),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "dokodemo request."
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func TestPassiveConnection(t *testing.T) {
|
||||
SendFirst: []byte("send first"),
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -72,18 +72,18 @@ func TestPassiveConnection(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(serverPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err := conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(string(response[:nBytes]), Equals, "send first")
|
||||
}
|
||||
|
||||
@ -91,14 +91,14 @@ func TestPassiveConnection(t *testing.T) {
|
||||
{
|
||||
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
}
|
||||
|
||||
{
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err := conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ func TestProxyOverKCP(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
serverUserID := protocol.NewID(uuid.New())
|
||||
@ -376,22 +376,22 @@ func TestProxyOverKCP(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, proxyConfig, clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "dokodemo request."
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
|
||||
@ -405,14 +405,14 @@ func TestBlackhole(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
tcpServer2 := tcp.Server{
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest2, err := tcpServer2.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer2.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -471,19 +471,19 @@ func TestBlackhole(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, &net.TCPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(serverPort2),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "dokodemo request."
|
||||
{
|
||||
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
}
|
||||
|
||||
@ -505,7 +505,7 @@ func TestForward(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -541,22 +541,22 @@ func TestForward(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
noAuthDialer, err := xproxy.SOCKS5("tcp", net.TCPDestination(net.LocalHostIP, serverPort).NetAddr(), nil, xproxy.Direct)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
conn, err := noAuthDialer.Dial("tcp", "google.com:80")
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "test payload"
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
}
|
||||
@ -571,7 +571,7 @@ func TestUDPConnection(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := udpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer udpServer.Close()
|
||||
|
||||
clientPort := tcp.PickPort()
|
||||
@ -599,24 +599,24 @@ func TestUDPConnection(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
conn, err := net.DialUDP("udp", nil, &net.UDPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "dokodemo request."
|
||||
for i := 0; i < 5; i++ {
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
}
|
||||
|
||||
@ -630,16 +630,16 @@ func TestUDPConnection(t *testing.T) {
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "dokodemo request."
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
}
|
||||
@ -721,7 +721,7 @@ func TestDomainSniffing(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
transport := &http.Transport{
|
||||
@ -735,7 +735,7 @@ func TestDomainSniffing(t *testing.T) {
|
||||
}
|
||||
|
||||
resp, err := client.Get("https://www.github.com/")
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp.StatusCode, Equals, 200)
|
||||
|
||||
assert(resp.Write(ioutil.Discard), IsNil)
|
||||
@ -751,7 +751,7 @@ func TestDialV2Ray(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
userID := protocol.NewID(uuid.New())
|
||||
@ -821,22 +821,22 @@ func TestDialV2Ray(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
client, err := core.New(clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
conn, err := core.Dial(context.Background(), client, dest)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "commander request."
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
|
||||
|
@ -32,7 +32,7 @@ func TestHttpConformance(t *testing.T) {
|
||||
PathHandler: make(map[string]http.HandlerFunc),
|
||||
}
|
||||
_, err := httpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer httpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -54,7 +54,7 @@ func TestHttpConformance(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
transport := &http.Transport{
|
||||
@ -68,11 +68,11 @@ func TestHttpConformance(t *testing.T) {
|
||||
}
|
||||
|
||||
resp, err := client.Get("http://127.0.0.1:" + httpServerPort.String())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp.StatusCode, Equals, 200)
|
||||
|
||||
content, err := ioutil.ReadAll(resp.Body)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(string(content), Equals, "Home")
|
||||
|
||||
}
|
||||
@ -89,7 +89,7 @@ func TestHttpError(t *testing.T) {
|
||||
},
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
time.AfterFunc(time.Second*2, func() {
|
||||
@ -115,7 +115,7 @@ func TestHttpError(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
transport := &http.Transport{
|
||||
@ -129,7 +129,7 @@ func TestHttpError(t *testing.T) {
|
||||
}
|
||||
|
||||
resp, err := client.Get("http://127.0.0.1:" + dest.Port.String())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp.StatusCode, Equals, 503)
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ func TestHttpConnectMethod(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -165,7 +165,7 @@ func TestHttpConnectMethod(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
transport := &http.Transport{
|
||||
@ -186,12 +186,12 @@ func TestHttpConnectMethod(t *testing.T) {
|
||||
common.Must(err)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp.StatusCode, Equals, 200)
|
||||
|
||||
content := make([]byte, len(payload))
|
||||
common.Must2(io.ReadFull(resp.Body, content))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(content, Equals, xor(payload))
|
||||
|
||||
}
|
||||
@ -222,7 +222,7 @@ func TestHttpPost(t *testing.T) {
|
||||
}
|
||||
|
||||
_, err := httpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer httpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -244,7 +244,7 @@ func TestHttpPost(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
transport := &http.Transport{
|
||||
@ -261,11 +261,11 @@ func TestHttpPost(t *testing.T) {
|
||||
common.Must2(rand.Read(payload))
|
||||
|
||||
resp, err := client.Post("http://127.0.0.1:"+httpServerPort.String()+"/testpost", "application/x-www-form-urlencoded", bytes.NewReader(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp.StatusCode, Equals, 200)
|
||||
|
||||
content, err := ioutil.ReadAll(resp.Body)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(content, Equals, xor(payload))
|
||||
|
||||
}
|
||||
@ -288,7 +288,7 @@ func TestHttpBasicAuth(t *testing.T) {
|
||||
PathHandler: make(map[string]http.HandlerFunc),
|
||||
}
|
||||
_, err := httpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer httpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -314,7 +314,7 @@ func TestHttpBasicAuth(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
transport := &http.Transport{
|
||||
@ -329,31 +329,31 @@ func TestHttpBasicAuth(t *testing.T) {
|
||||
|
||||
{
|
||||
resp, err := client.Get("http://127.0.0.1:" + httpServerPort.String())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp.StatusCode, Equals, 407)
|
||||
}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+httpServerPort.String(), nil)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
setProxyBasicAuth(req, "a", "c")
|
||||
resp, err := client.Do(req)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp.StatusCode, Equals, 407)
|
||||
}
|
||||
|
||||
{
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+httpServerPort.String(), nil)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
setProxyBasicAuth(req, "a", "b")
|
||||
resp, err := client.Do(req)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(resp.StatusCode, Equals, 200)
|
||||
|
||||
content, err := ioutil.ReadAll(resp.Body)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(string(content), Equals, "Home")
|
||||
}
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ func TestShadowsocksAES128GCMUDP(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := udpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer udpServer.Close()
|
||||
|
||||
account := serial.ToTypedMessage(&shadowsocks.Account{
|
||||
@ -625,7 +625,7 @@ func TestShadowsocksAES128GCMUDP(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -635,13 +635,13 @@ func TestShadowsocksAES128GCMUDP(t *testing.T) {
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := make([]byte, 1024)
|
||||
rand.Read(payload)
|
||||
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := readFrom(conn, time.Second*5, 1024)
|
||||
@ -662,7 +662,7 @@ func TestShadowsocksAES128GCMUDPMux(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := udpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer udpServer.Close()
|
||||
|
||||
account := serial.ToTypedMessage(&shadowsocks.Account{
|
||||
@ -749,7 +749,7 @@ func TestShadowsocksAES128GCMUDPMux(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -759,13 +759,13 @@ func TestShadowsocksAES128GCMUDPMux(t *testing.T) {
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := make([]byte, 1024)
|
||||
rand.Read(payload)
|
||||
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := readFrom(conn, time.Second*5, 1024)
|
||||
|
@ -111,7 +111,7 @@ func TestSocksBridageUDP(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := udpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer udpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -179,22 +179,22 @@ func TestSocksBridageUDP(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
conn, err := net.DialUDP("udp", nil, &net.UDPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "dokodemo request."
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
|
||||
@ -208,7 +208,7 @@ func TestSocksBridageUDPWithRouting(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := udpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer udpServer.Close()
|
||||
|
||||
serverPort := tcp.PickPort()
|
||||
@ -282,22 +282,22 @@ func TestSocksBridageUDPWithRouting(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
conn, err := net.DialUDP("udp", nil, &net.UDPAddr{
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "dokodemo request."
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
|
||||
@ -311,7 +311,7 @@ func TestSocksConformance(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
authPort := tcp.PickPort()
|
||||
@ -355,40 +355,40 @@ func TestSocksConformance(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
{
|
||||
noAuthDialer, err := xproxy.SOCKS5("tcp", net.TCPDestination(net.LocalHostIP, noAuthPort).NetAddr(), nil, xproxy.Direct)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
conn, err := noAuthDialer.Dial("tcp", dest.NetAddr())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "test payload"
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
}
|
||||
|
||||
{
|
||||
authDialer, err := xproxy.SOCKS5("tcp", net.TCPDestination(net.LocalHostIP, authPort).NetAddr(), &xproxy.Auth{User: "Test Account", Password: "Test Password"}, xproxy.Direct)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
conn, err := authDialer.Dial("tcp", dest.NetAddr())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "test payload"
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
}
|
||||
@ -396,16 +396,16 @@ func TestSocksConformance(t *testing.T) {
|
||||
{
|
||||
dialer := socks4.DialSocksProxy(socks4.SOCKS4, net.TCPDestination(net.LocalHostIP, noAuthPort).NetAddr())
|
||||
conn, err := dialer("tcp", dest.NetAddr())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "test payload"
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
}
|
||||
@ -413,16 +413,16 @@ func TestSocksConformance(t *testing.T) {
|
||||
{
|
||||
dialer := socks4.DialSocksProxy(socks4.SOCKS4A, net.TCPDestination(net.LocalHostIP, noAuthPort).NetAddr())
|
||||
conn, err := dialer("tcp", net.TCPDestination(net.LocalHostDomain, tcpServer.Port).NetAddr())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := "test payload"
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := make([]byte, 1024)
|
||||
nBytes, err = conn.Read(response)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(response[:nBytes], Equals, xor([]byte(payload)))
|
||||
assert(conn.Close(), IsNil)
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ func TestVMessGCMUDP(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := udpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer udpServer.Close()
|
||||
|
||||
userID := protocol.NewID(uuid.New())
|
||||
@ -456,7 +456,7 @@ func TestVMessGCMUDP(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(10)
|
||||
@ -466,19 +466,19 @@ func TestVMessGCMUDP(t *testing.T) {
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := make([]byte, 1024)
|
||||
rand.Read(payload)
|
||||
|
||||
nBytes, err := conn.Write([]byte(payload))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
payload1 := make([]byte, 1024)
|
||||
rand.Read(payload1)
|
||||
nBytes, err = conn.Write([]byte(payload1))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload1))
|
||||
|
||||
response := readFrom(conn, time.Second*5, 1024)
|
||||
@ -1082,14 +1082,14 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
udpServer := udp.Server{
|
||||
MsgProcessor: xor,
|
||||
}
|
||||
udpDest, err := udpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer udpServer.Close()
|
||||
|
||||
userID := protocol.NewID(uuid.New())
|
||||
@ -1195,7 +1195,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
}
|
||||
|
||||
servers, err := InitializeServerConfigs(serverConfig, clientConfig)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
for range "abcd" {
|
||||
var wg sync.WaitGroup
|
||||
@ -1207,7 +1207,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
payload := make([]byte, 10240)
|
||||
rand.Read(payload)
|
||||
@ -1215,7 +1215,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
xorpayload := xor(payload)
|
||||
|
||||
nBytes, err := conn.Write(payload)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
|
||||
response := readFrom(conn, time.Second*20, 10240)
|
||||
@ -1230,7 +1230,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
IP: []byte{127, 0, 0, 1},
|
||||
Port: int(clientUDPPort),
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
conn.SetDeadline(time.Now().Add(time.Second * 10))
|
||||
|
||||
@ -1241,7 +1241,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
|
||||
for j := 0; j < 2; j++ {
|
||||
nBytes, _, err := conn.WriteMsgUDP(payload, nil, nil)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, len(payload))
|
||||
}
|
||||
|
||||
@ -1249,7 +1249,7 @@ func TestVMessGCMMuxUDP(t *testing.T) {
|
||||
oob := make([]byte, 16)
|
||||
for j := 0; j < 2; j++ {
|
||||
nBytes, _, _, _, err := conn.ReadMsgUDP(response, oob)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(nBytes, Equals, 1024)
|
||||
assert(response, Equals, xorpayload)
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ func TestReaderWriter(t *testing.T) {
|
||||
common.Must2(b.WriteString("abcd" + ENDING))
|
||||
writer := NewHeaderWriter(b)
|
||||
err := writer.Write(cache)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(cache.Len(), Equals, int32(8))
|
||||
_, err = cache.Write([]byte{'e', 'f', 'g'})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
reader := &HeaderReader{}
|
||||
buffer, err := reader.Read(cache)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(buffer.Bytes(), Equals, []byte{'e', 'f', 'g'})
|
||||
}
|
||||
|
||||
@ -47,11 +47,11 @@ func TestRequestHeader(t *testing.T) {
|
||||
},
|
||||
},
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
cache := buf.New()
|
||||
err = auth.GetClientWriter().Write(cache)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
assert(cache.String(), Equals, "GET / HTTP/1.1\r\nTest: Value\r\n\r\n")
|
||||
}
|
||||
@ -98,26 +98,26 @@ func TestConnection(t *testing.T) {
|
||||
},
|
||||
},
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
listener, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
go func() {
|
||||
conn, err := listener.Accept()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
authConn := auth.Server(conn)
|
||||
b := make([]byte, 256)
|
||||
for {
|
||||
n, err := authConn.Read(b)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
_, err = authConn.Write(b[:n])
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
}
|
||||
}()
|
||||
|
||||
conn, err := net.DialTCP("tcp", nil, listener.Addr().(*net.TCPAddr))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
authConn := auth.Client(conn)
|
||||
authConn.Write([]byte("Test payload"))
|
||||
@ -129,7 +129,7 @@ func TestConnection(t *testing.T) {
|
||||
totalBytes := 0
|
||||
for {
|
||||
n, err := authConn.Read(actualResponse[totalBytes:])
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
totalBytes += n
|
||||
if totalBytes >= len(expectedResponse) || time.Now().After(deadline) {
|
||||
break
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
. "v2ray.com/core/transport/internet/headers/tls"
|
||||
. "v2ray.com/ext/assert"
|
||||
@ -14,7 +15,7 @@ func TestDTLSWrite(t *testing.T) {
|
||||
|
||||
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
|
||||
dtlsRaw, err := New(context.Background(), &PacketConfig{})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
dtls := dtlsRaw.(*DTLS)
|
||||
|
||||
|
@ -4,17 +4,15 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
. "v2ray.com/core/transport/internet/headers/utp"
|
||||
. "v2ray.com/ext/assert"
|
||||
)
|
||||
|
||||
func TestUTPWrite(t *testing.T) {
|
||||
assert := With(t)
|
||||
|
||||
content := []byte{'a', 'b', 'c', 'd', 'e', 'f', 'g'}
|
||||
utpRaw, err := New(context.Background(), &Config{})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
utp := utpRaw.(*UTP)
|
||||
|
||||
@ -22,5 +20,7 @@ func TestUTPWrite(t *testing.T) {
|
||||
utp.Serialize(payload.Extend(utp.Size()))
|
||||
payload.Write(content)
|
||||
|
||||
assert(payload.Len(), Equals, int32(len(content))+utp.Size())
|
||||
if payload.Len() != int32(len(content))+utp.Size() {
|
||||
t.Error("unexpected payload length: ", payload.Len())
|
||||
}
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ func TestHTTPConnection(t *testing.T) {
|
||||
return
|
||||
}
|
||||
nBytes, err := conn.Write(b.Bytes())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(int32(nBytes), Equals, b.Len())
|
||||
}
|
||||
}()
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
defer listener.Close()
|
||||
|
||||
@ -62,7 +62,7 @@ func TestHTTPConnection(t *testing.T) {
|
||||
AllowInsecure: true,
|
||||
},
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer conn.Close()
|
||||
|
||||
const N = 1024
|
||||
@ -72,7 +72,7 @@ func TestHTTPConnection(t *testing.T) {
|
||||
|
||||
nBytes, err := conn.Write(b1)
|
||||
assert(nBytes, Equals, N)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
b2.Clear()
|
||||
common.Must2(b2.ReadFullFrom(conn, N))
|
||||
@ -80,7 +80,7 @@ func TestHTTPConnection(t *testing.T) {
|
||||
|
||||
nBytes, err = conn.Write(b1)
|
||||
assert(nBytes, Equals, N)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
b2.Clear()
|
||||
common.Must2(b2.ReadFullFrom(conn, N))
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/transport/internet"
|
||||
. "v2ray.com/core/transport/internet/kcp"
|
||||
@ -36,7 +37,7 @@ func TestDialAndListen(t *testing.T) {
|
||||
c.Close()
|
||||
}(conn)
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
port := net.Port(listerner.Addr().(*net.UDPAddr).Port)
|
||||
|
||||
wg := new(sync.WaitGroup)
|
||||
@ -45,7 +46,7 @@ func TestDialAndListen(t *testing.T) {
|
||||
ProtocolName: "mkcp",
|
||||
ProtocolSettings: &Config{},
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
|
@ -45,12 +45,12 @@ func TestQuicConnection(t *testing.T) {
|
||||
return
|
||||
}
|
||||
nBytes, err := conn.Write(b.Bytes())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(int32(nBytes), Equals, b.Len())
|
||||
}
|
||||
}()
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
defer listener.Close()
|
||||
|
||||
@ -66,7 +66,7 @@ func TestQuicConnection(t *testing.T) {
|
||||
AllowInsecure: true,
|
||||
},
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer conn.Close()
|
||||
|
||||
const N = 1024
|
||||
@ -76,7 +76,7 @@ func TestQuicConnection(t *testing.T) {
|
||||
|
||||
nBytes, err := conn.Write(b1)
|
||||
assert(nBytes, Equals, N)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
b2.Clear()
|
||||
common.Must2(b2.ReadFullFrom(conn, N))
|
||||
@ -84,7 +84,7 @@ func TestQuicConnection(t *testing.T) {
|
||||
|
||||
nBytes, err = conn.Write(b1)
|
||||
assert(nBytes, Equals, N)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
b2.Clear()
|
||||
common.Must2(b2.ReadFullFrom(conn, N))
|
||||
@ -112,12 +112,12 @@ func TestQuicConnectionWithoutTLS(t *testing.T) {
|
||||
return
|
||||
}
|
||||
nBytes, err := conn.Write(b.Bytes())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(int32(nBytes), Equals, b.Len())
|
||||
}
|
||||
}()
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
defer listener.Close()
|
||||
|
||||
@ -128,7 +128,7 @@ func TestQuicConnectionWithoutTLS(t *testing.T) {
|
||||
ProtocolName: "quic",
|
||||
ProtocolSettings: &quic.Config{},
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer conn.Close()
|
||||
|
||||
const N = 1024
|
||||
@ -138,7 +138,7 @@ func TestQuicConnectionWithoutTLS(t *testing.T) {
|
||||
|
||||
nBytes, err := conn.Write(b1)
|
||||
assert(nBytes, Equals, N)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
b2.Clear()
|
||||
common.Must2(b2.ReadFullFrom(conn, N))
|
||||
@ -146,7 +146,7 @@ func TestQuicConnectionWithoutTLS(t *testing.T) {
|
||||
|
||||
nBytes, err = conn.Write(b1)
|
||||
assert(nBytes, Equals, N)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
b2.Clear()
|
||||
common.Must2(b2.ReadFullFrom(conn, N))
|
||||
@ -180,12 +180,12 @@ func TestQuicConnectionAuthHeader(t *testing.T) {
|
||||
return
|
||||
}
|
||||
nBytes, err := conn.Write(b.Bytes())
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(int32(nBytes), Equals, b.Len())
|
||||
}
|
||||
}()
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
defer listener.Close()
|
||||
|
||||
@ -202,7 +202,7 @@ func TestQuicConnectionAuthHeader(t *testing.T) {
|
||||
},
|
||||
},
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer conn.Close()
|
||||
|
||||
const N = 1024
|
||||
@ -212,7 +212,7 @@ func TestQuicConnectionAuthHeader(t *testing.T) {
|
||||
|
||||
nBytes, err := conn.Write(b1)
|
||||
assert(nBytes, Equals, N)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
b2.Clear()
|
||||
common.Must2(b2.ReadFullFrom(conn, N))
|
||||
@ -220,7 +220,7 @@ func TestQuicConnectionAuthHeader(t *testing.T) {
|
||||
|
||||
nBytes, err = conn.Write(b1)
|
||||
assert(nBytes, Equals, N)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
b2.Clear()
|
||||
common.Must2(b2.ReadFullFrom(conn, N))
|
||||
|
@ -19,13 +19,13 @@ func TestGetOriginalDestination(t *testing.T) {
|
||||
|
||||
tcpServer := tcp.Server{}
|
||||
dest, err := tcpServer.Start()
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer tcpServer.Close()
|
||||
|
||||
config, err := internet.ToMemoryStreamConfig(nil)
|
||||
common.Must(err)
|
||||
conn, err := Dial(context.Background(), dest, config)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer conn.Close()
|
||||
|
||||
originalDest, err := GetOriginalDestination(conn)
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/protocol/tls/cert"
|
||||
. "v2ray.com/core/transport/internet/tls"
|
||||
. "v2ray.com/ext/assert"
|
||||
@ -27,10 +28,10 @@ func TestCertificateIssuing(t *testing.T) {
|
||||
v2rayCert, err := tlsConfig.GetCertificate(&gotls.ClientHelloInfo{
|
||||
ServerName: "www.v2ray.com",
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
x509Cert, err := x509.ParseCertificate(v2rayCert.Certificate[0])
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(x509Cert.NotAfter.After(time.Now()), IsTrue)
|
||||
}
|
||||
|
||||
@ -56,10 +57,10 @@ func TestExpiredCertificate(t *testing.T) {
|
||||
v2rayCert, err := tlsConfig.GetCertificate(&gotls.ClientHelloInfo{
|
||||
ServerName: "www.v2ray.com",
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
x509Cert, err := x509.ParseCertificate(v2rayCert.Certificate[0])
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(x509Cert.NotAfter.After(time.Now()), IsTrue)
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/buf"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/protocol/udp"
|
||||
@ -50,7 +51,7 @@ func TestSameDestinationDispatching(t *testing.T) {
|
||||
break
|
||||
}
|
||||
err = downlinkWriter.WriteMultiBuffer(data)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
}
|
||||
}()
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"v2ray.com/core/common"
|
||||
"v2ray.com/core/common/net"
|
||||
"v2ray.com/core/common/protocol/tls/cert"
|
||||
"v2ray.com/core/transport/internet"
|
||||
@ -29,17 +30,17 @@ func Test_listenWSAndDial(t *testing.T) {
|
||||
|
||||
var b [1024]byte
|
||||
n, err := c.Read(b[:])
|
||||
//assert(err, IsNil)
|
||||
//common.Must(err)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
assert(bytes.HasPrefix(b[:n], []byte("Test connection")), IsTrue)
|
||||
|
||||
_, err = c.Write([]byte("Response"))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
}(conn)
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
ctx := context.Background()
|
||||
streamSettings := &internet.MemoryStreamConfig{
|
||||
@ -48,23 +49,23 @@ func Test_listenWSAndDial(t *testing.T) {
|
||||
}
|
||||
conn, err := Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13146), streamSettings)
|
||||
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
_, err = conn.Write([]byte("Test connection 1"))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
var b [1024]byte
|
||||
n, err := conn.Read(b[:])
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(string(b[:n]), Equals, "Response")
|
||||
|
||||
assert(conn.Close(), IsNil)
|
||||
<-time.After(time.Second * 5)
|
||||
conn, err = Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13146), streamSettings)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
_, err = conn.Write([]byte("Test connection 2"))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
n, err = conn.Read(b[:])
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(string(b[:n]), Equals, "Response")
|
||||
assert(conn.Close(), IsNil)
|
||||
|
||||
@ -86,30 +87,30 @@ func TestDialWithRemoteAddr(t *testing.T) {
|
||||
|
||||
var b [1024]byte
|
||||
n, err := c.Read(b[:])
|
||||
//assert(err, IsNil)
|
||||
//common.Must(err)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
assert(bytes.HasPrefix(b[:n], []byte("Test connection")), IsTrue)
|
||||
|
||||
_, err = c.Write([]byte("Response"))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
}(conn)
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
conn, err := Dial(context.Background(), net.TCPDestination(net.DomainAddress("localhost"), 13148), &internet.MemoryStreamConfig{
|
||||
ProtocolName: "websocket",
|
||||
ProtocolSettings: &Config{Path: "ws", Header: []*Header{{Key: "X-Forwarded-For", Value: "1.1.1.1"}}},
|
||||
})
|
||||
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
_, err = conn.Write([]byte("Test connection 1"))
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
|
||||
var b [1024]byte
|
||||
n, err := conn.Read(b[:])
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
assert(string(b[:n]), Equals, "Response")
|
||||
|
||||
assert(listen.Close(), IsNil)
|
||||
@ -140,11 +141,11 @@ func Test_listenWSAndDial_TLS(t *testing.T) {
|
||||
_ = conn.Close()
|
||||
}()
|
||||
})
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
defer listen.Close()
|
||||
|
||||
conn, err := Dial(context.Background(), net.TCPDestination(net.DomainAddress("localhost"), 13143), streamSettings)
|
||||
assert(err, IsNil)
|
||||
common.Must(err)
|
||||
_ = conn.Close()
|
||||
|
||||
end := time.Now()
|
||||
|
Loading…
Reference in New Issue
Block a user