Skip to content

Commit 909729c

Browse files
committed
fix: allow use vision on vless encryption over ws
1 parent 6c527f8 commit 909729c

File tree

3 files changed

+36
-32
lines changed

3 files changed

+36
-32
lines changed

adapter/outbound/vless.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ type VlessOption struct {
6464
HTTP2Opts HTTP2Options `proxy:"h2-opts,omitempty"`
6565
GrpcOpts GrpcOptions `proxy:"grpc-opts,omitempty"`
6666
WSOpts WSOptions `proxy:"ws-opts,omitempty"`
67-
WSPath string `proxy:"ws-path,omitempty"`
6867
WSHeaders map[string]string `proxy:"ws-headers,omitempty"`
6968
SkipCertVerify bool `proxy:"skip-cert-verify,omitempty"`
7069
Fingerprint string `proxy:"fingerprint,omitempty"`
@@ -407,7 +406,7 @@ func parseVlessAddr(metadata *C.Metadata, xudp bool) *vless.DstAddr {
407406

408407
func NewVless(option VlessOption) (*Vless, error) {
409408
var addons *vless.Addons
410-
if option.Network != "ws" && len(option.Flow) >= 16 {
409+
if len(option.Flow) >= 16 {
411410
option.Flow = option.Flow[:16]
412411
if option.Flow != vless.XRV {
413412
return nil, fmt.Errorf("unsupported xtls flow type: %s", option.Flow)

listener/inbound/vless_test.go

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,46 @@ func TestInboundVless_Encryption(t *testing.T) {
120120
for i := range paddings {
121121
padding := paddings[i].data
122122
t.Run(paddings[i].name, func(t *testing.T) {
123+
t.Parallel()
123124
inboundOptions := inbound.VlessOption{
124125
Decryption: "mlkem768x25519plus." + mode + ".600s." + padding + privateKeyBase64 + "." + seedBase64,
125126
}
126127
outboundOptions := outbound.VlessOption{
127128
Encryption: "mlkem768x25519plus." + mode + ".0rtt." + padding + passwordBase64 + "." + clientBase64,
128129
}
129-
testInboundVless(t, inboundOptions, outboundOptions)
130-
t.Run("xtls-rprx-vision", func(t *testing.T) {
130+
t.Run("raw", func(t *testing.T) {
131+
testInboundVless(t, inboundOptions, outboundOptions)
132+
t.Run("xtls-rprx-vision", func(t *testing.T) {
133+
outboundOptions := outboundOptions
134+
outboundOptions.Flow = "xtls-rprx-vision"
135+
testInboundVless(t, inboundOptions, outboundOptions)
136+
})
137+
})
138+
t.Run("ws", func(t *testing.T) {
139+
inboundOptions := inboundOptions
140+
inboundOptions.WsPath = "/ws"
131141
outboundOptions := outboundOptions
132-
outboundOptions.Flow = "xtls-rprx-vision"
142+
outboundOptions.Network = "ws"
143+
outboundOptions.WSOpts = outbound.WSOptions{Path: "/ws"}
133144
testInboundVless(t, inboundOptions, outboundOptions)
145+
t.Run("xtls-rprx-vision", func(t *testing.T) {
146+
outboundOptions := outboundOptions
147+
outboundOptions.Flow = "xtls-rprx-vision"
148+
testInboundVless(t, inboundOptions, outboundOptions)
149+
})
150+
})
151+
t.Run("grpc", func(t *testing.T) {
152+
inboundOptions := inboundOptions
153+
inboundOptions.GrpcServiceName = "GunService"
154+
outboundOptions := outboundOptions
155+
outboundOptions.Network = "grpc"
156+
outboundOptions.GrpcOpts = outbound.GrpcOptions{GrpcServiceName: "GunService"}
157+
testInboundVless(t, inboundOptions, outboundOptions)
158+
t.Run("xtls-rprx-vision", func(t *testing.T) {
159+
outboundOptions := outboundOptions
160+
outboundOptions.Flow = "xtls-rprx-vision"
161+
testInboundVless(t, inboundOptions, outboundOptions)
162+
})
134163
})
135164
})
136165
}
@@ -149,16 +178,9 @@ func TestInboundVless_Wss1(t *testing.T) {
149178
TLS: true,
150179
Fingerprint: tlsFingerprint,
151180
Network: "ws",
152-
WSOpts: outbound.WSOptions{
153-
Path: "/ws",
154-
},
181+
WSOpts: outbound.WSOptions{Path: "/ws"},
155182
}
156183
testInboundVless(t, inboundOptions, outboundOptions)
157-
t.Run("xtls-rprx-vision", func(t *testing.T) {
158-
outboundOptions := outboundOptions
159-
outboundOptions.Flow = "xtls-rprx-vision"
160-
testInboundVless(t, inboundOptions, outboundOptions)
161-
})
162184
t.Run("ECH", func(t *testing.T) {
163185
inboundOptions := inboundOptions
164186
outboundOptions := outboundOptions
@@ -168,11 +190,6 @@ func TestInboundVless_Wss1(t *testing.T) {
168190
Config: echConfigBase64,
169191
}
170192
testInboundVless(t, inboundOptions, outboundOptions)
171-
t.Run("xtls-rprx-vision", func(t *testing.T) {
172-
outboundOptions := outboundOptions
173-
outboundOptions.Flow = "xtls-rprx-vision"
174-
testInboundVless(t, inboundOptions, outboundOptions)
175-
})
176193
})
177194
}
178195

@@ -187,16 +204,9 @@ func TestInboundVless_Wss2(t *testing.T) {
187204
TLS: true,
188205
Fingerprint: tlsFingerprint,
189206
Network: "ws",
190-
WSOpts: outbound.WSOptions{
191-
Path: "/ws",
192-
},
207+
WSOpts: outbound.WSOptions{Path: "/ws"},
193208
}
194209
testInboundVless(t, inboundOptions, outboundOptions)
195-
t.Run("xtls-rprx-vision", func(t *testing.T) {
196-
outboundOptions := outboundOptions
197-
outboundOptions.Flow = "xtls-rprx-vision"
198-
testInboundVless(t, inboundOptions, outboundOptions)
199-
})
200210
t.Run("ECH", func(t *testing.T) {
201211
inboundOptions := inboundOptions
202212
outboundOptions := outboundOptions
@@ -206,11 +216,6 @@ func TestInboundVless_Wss2(t *testing.T) {
206216
Config: echConfigBase64,
207217
}
208218
testInboundVless(t, inboundOptions, outboundOptions)
209-
t.Run("xtls-rprx-vision", func(t *testing.T) {
210-
outboundOptions := outboundOptions
211-
outboundOptions.Flow = "xtls-rprx-vision"
212-
testInboundVless(t, inboundOptions, outboundOptions)
213-
})
214219
})
215220
}
216221

transport/vless/vision/vision.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func NewConn(conn net.Conn, tlsConn net.Conn, userUUID uuid.UUID) (*Conn, error)
8282
}
8383
if t == nil || p == nil {
8484
log.Warnln("vision: not a valid supported TLS connection: %s", reflect.TypeOf(tlsConn))
85-
return nil, fmt.Errorf(`failed to use vision, maybe "security" is not "tls" or "utls"`)
85+
return nil, fmt.Errorf(`failed to use vision, maybe "tls" is not enable and "encryption" is empty`)
8686
}
8787

8888
if err := checkTLSVersion(tlsConn); err != nil {

0 commit comments

Comments
 (0)