|
@@ -6,7 +6,7 @@ import (
|
|
|
"testing"
|
|
"testing"
|
|
|
"time"
|
|
"time"
|
|
|
|
|
|
|
|
- v2net "v2ray.com/core/common/net"
|
|
|
|
|
|
|
+ "v2ray.com/core/common/net"
|
|
|
"v2ray.com/core/testing/assert"
|
|
"v2ray.com/core/testing/assert"
|
|
|
tlsgen "v2ray.com/core/testing/tls"
|
|
tlsgen "v2ray.com/core/testing/tls"
|
|
|
"v2ray.com/core/transport/internet"
|
|
"v2ray.com/core/transport/internet"
|
|
@@ -18,7 +18,7 @@ func Test_listenWSAndDial(t *testing.T) {
|
|
|
assert := assert.On(t)
|
|
assert := assert.On(t)
|
|
|
listen, err := ListenWS(internet.ContextWithTransportSettings(context.Background(), &Config{
|
|
listen, err := ListenWS(internet.ContextWithTransportSettings(context.Background(), &Config{
|
|
|
Path: "ws",
|
|
Path: "ws",
|
|
|
- }), v2net.DomainAddress("localhost"), 13146, func(ctx context.Context, conn internet.Connection) bool {
|
|
|
|
|
|
|
+ }), net.DomainAddress("localhost"), 13146, func(ctx context.Context, conn internet.Connection) bool {
|
|
|
go func(c internet.Connection) {
|
|
go func(c internet.Connection) {
|
|
|
defer c.Close()
|
|
defer c.Close()
|
|
|
|
|
|
|
@@ -38,7 +38,7 @@ func Test_listenWSAndDial(t *testing.T) {
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
|
|
|
|
|
ctx := internet.ContextWithTransportSettings(context.Background(), &Config{Path: "ws"})
|
|
ctx := internet.ContextWithTransportSettings(context.Background(), &Config{Path: "ws"})
|
|
|
- conn, err := Dial(ctx, v2net.TCPDestination(v2net.DomainAddress("localhost"), 13146))
|
|
|
|
|
|
|
+ conn, err := Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13146))
|
|
|
|
|
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
_, err = conn.Write([]byte("Test connection 1"))
|
|
_, err = conn.Write([]byte("Test connection 1"))
|
|
@@ -51,7 +51,7 @@ func Test_listenWSAndDial(t *testing.T) {
|
|
|
|
|
|
|
|
assert.Error(conn.Close()).IsNil()
|
|
assert.Error(conn.Close()).IsNil()
|
|
|
<-time.After(time.Second * 5)
|
|
<-time.After(time.Second * 5)
|
|
|
- conn, err = Dial(ctx, v2net.TCPDestination(v2net.DomainAddress("localhost"), 13146))
|
|
|
|
|
|
|
+ conn, err = Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13146))
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
_, err = conn.Write([]byte("Test connection 2"))
|
|
_, err = conn.Write([]byte("Test connection 2"))
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
@@ -60,7 +60,7 @@ func Test_listenWSAndDial(t *testing.T) {
|
|
|
assert.String(string(b[:n])).Equals("Response")
|
|
assert.String(string(b[:n])).Equals("Response")
|
|
|
assert.Error(conn.Close()).IsNil()
|
|
assert.Error(conn.Close()).IsNil()
|
|
|
<-time.After(time.Second * 15)
|
|
<-time.After(time.Second * 15)
|
|
|
- conn, err = Dial(ctx, v2net.TCPDestination(v2net.DomainAddress("localhost"), 13146))
|
|
|
|
|
|
|
+ conn, err = Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13146))
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
_, err = conn.Write([]byte("Test connection 3"))
|
|
_, err = conn.Write([]byte("Test connection 3"))
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
@@ -86,7 +86,7 @@ func Test_listenWSAndDial_TLS(t *testing.T) {
|
|
|
AllowInsecure: true,
|
|
AllowInsecure: true,
|
|
|
Certificate: []*v2tls.Certificate{tlsgen.GenerateCertificateForTest()},
|
|
Certificate: []*v2tls.Certificate{tlsgen.GenerateCertificateForTest()},
|
|
|
})
|
|
})
|
|
|
- listen, err := ListenWS(ctx, v2net.DomainAddress("localhost"), 13143, func(ctx context.Context, conn internet.Connection) bool {
|
|
|
|
|
|
|
+ listen, err := ListenWS(ctx, net.DomainAddress("localhost"), 13143, func(ctx context.Context, conn internet.Connection) bool {
|
|
|
go func() {
|
|
go func() {
|
|
|
conn.Close()
|
|
conn.Close()
|
|
|
}()
|
|
}()
|
|
@@ -95,7 +95,7 @@ func Test_listenWSAndDial_TLS(t *testing.T) {
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
defer listen.Close()
|
|
defer listen.Close()
|
|
|
|
|
|
|
|
- conn, err := Dial(ctx, v2net.TCPDestination(v2net.DomainAddress("localhost"), 13143))
|
|
|
|
|
|
|
+ conn, err := Dial(ctx, net.TCPDestination(net.DomainAddress("localhost"), 13143))
|
|
|
assert.Error(err).IsNil()
|
|
assert.Error(err).IsNil()
|
|
|
conn.Close()
|
|
conn.Close()
|
|
|
}
|
|
}
|