Browse Source

Fix vless tests

世界 2 years ago
parent
commit
e8802357e1
5 changed files with 14 additions and 4 deletions
  1. 1 1
      test/go.mod
  2. 2 2
      test/go.sum
  3. 1 0
      test/reality_test.go
  4. 2 0
      test/vless_test.go
  5. 8 1
      transport/vless/service.go

+ 1 - 1
test/go.mod

@@ -10,7 +10,7 @@ require (
 	github.com/docker/docker v20.10.18+incompatible
 	github.com/docker/go-connections v0.4.0
 	github.com/gofrs/uuid v4.4.0+incompatible
-	github.com/sagernet/sing v0.1.8-0.20230228034829-bb617490652c
+	github.com/sagernet/sing v0.1.8-0.20230301160041-9fab0a9f4304
 	github.com/sagernet/sing-shadowsocks v0.1.2-0.20230221080503-769c01d6bba9
 	github.com/spyzhov/ajson v0.7.1
 	github.com/stretchr/testify v1.8.1

+ 2 - 2
test/go.sum

@@ -146,8 +146,8 @@ github.com/sagernet/reality v0.0.0-20230228045158-d3e085a8e5d1 h1:8mSzchN6DkM26J
 github.com/sagernet/reality v0.0.0-20230228045158-d3e085a8e5d1/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU=
 github.com/sagernet/sing v0.0.0-20220812082120-05f9836bff8f/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY=
 github.com/sagernet/sing v0.0.0-20220817130738-ce854cda8522/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY=
-github.com/sagernet/sing v0.1.8-0.20230228034829-bb617490652c h1:+YUwfoIkKlMi3Y1QrOy+OlIELC9KWV0+/5F3NX72q8U=
-github.com/sagernet/sing v0.1.8-0.20230228034829-bb617490652c/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk=
+github.com/sagernet/sing v0.1.8-0.20230301160041-9fab0a9f4304 h1:Yi7wqvHv+ZFLHPQn1DiSAdnMZkb5Cra7Y4s8vzBLrFE=
+github.com/sagernet/sing v0.1.8-0.20230301160041-9fab0a9f4304/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk=
 github.com/sagernet/sing-dns v0.1.4 h1:7VxgeoSCiiazDSaXXQVcvrTBxFpOePPq/4XdgnUDN+0=
 github.com/sagernet/sing-dns v0.1.4/go.mod h1:1+6pCa48B1AI78lD+/i/dLgpw4MwfnsSpZo0Ds8wzzk=
 github.com/sagernet/sing-shadowsocks v0.1.2-0.20230221080503-769c01d6bba9 h1:qS39eA4C7x+zhEkySbASrtmb6ebdy5v0y2M6mgkmSO0=

+ 1 - 0
test/reality_test.go

@@ -36,6 +36,7 @@ func TestVLESSVisionReality(t *testing.T) {
 						{
 							Name: "sekai",
 							UUID: userUUID.String(),
+							Flow: vless.FlowVision,
 						},
 					},
 					TLS: &option.InboundTLSOptions{

+ 2 - 0
test/vless_test.go

@@ -234,6 +234,7 @@ func testVLESSSelf(t *testing.T, flow string) {
 						{
 							Name: "sekai",
 							UUID: userUUID.String(),
+							Flow: flow,
 						},
 					},
 					TLS: &option.InboundTLSOptions{
@@ -308,6 +309,7 @@ func testVLESSSelfTLS(t *testing.T, flow string) {
 						{
 							Name: "sekai",
 							UUID: userUUID.String(),
+							Flow: flow,
 						},
 					},
 					TLS: &option.InboundTLSOptions{

+ 8 - 1
transport/vless/service.go

@@ -69,7 +69,7 @@ func (s *Service[T]) NewConnection(ctx context.Context, conn net.Conn, metadata
 
 	userFlow := s.userFlow[user]
 	if request.Flow != userFlow {
-		return E.New("flow mismatch: expected ", userFlow, ", but got ", request.Flow)
+		return E.New("flow mismatch: expected ", flowName(userFlow), ", but got ", flowName(request.Flow))
 	}
 
 	protocolConn := conn
@@ -94,6 +94,13 @@ func (s *Service[T]) NewConnection(ctx context.Context, conn net.Conn, metadata
 	}
 }
 
+func flowName(value string) string {
+	if value == "" {
+		return "none"
+	}
+	return value
+}
+
 type serverConn struct {
 	net.Conn
 	responseWriter  io.Writer