From e8802357e1e72c361cbe31eb1136b922ac6216a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Thu, 2 Mar 2023 00:31:56 +0800 Subject: [PATCH] Fix vless tests --- test/go.mod | 2 +- test/go.sum | 4 ++-- test/reality_test.go | 1 + test/vless_test.go | 2 ++ transport/vless/service.go | 9 ++++++++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/test/go.mod b/test/go.mod index 3e11034a..6e711e14 100644 --- a/test/go.mod +++ b/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 diff --git a/test/go.sum b/test/go.sum index c1450f4f..46d3082f 100644 --- a/test/go.sum +++ b/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= diff --git a/test/reality_test.go b/test/reality_test.go index 3d8c1894..6bfb7988 100644 --- a/test/reality_test.go +++ b/test/reality_test.go @@ -36,6 +36,7 @@ func TestVLESSVisionReality(t *testing.T) { { Name: "sekai", UUID: userUUID.String(), + Flow: vless.FlowVision, }, }, TLS: &option.InboundTLSOptions{ diff --git a/test/vless_test.go b/test/vless_test.go index 6dea7707..bd0b6130 100644 --- a/test/vless_test.go +++ b/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{ diff --git a/transport/vless/service.go b/transport/vless/service.go index 1a6cfcfb..c25a3e50 100644 --- a/transport/vless/service.go +++ b/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