fix: allow use vision on vless encryption over ws
Some checks are pending
Test / test (1.20, macos-13) (push) Waiting to run
Test / test (1.20, macos-latest) (push) Waiting to run
Test / test (1.20, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.20, ubuntu-latest) (push) Waiting to run
Test / test (1.20, windows-latest) (push) Waiting to run
Test / test (1.21, macos-13) (push) Waiting to run
Test / test (1.21, macos-latest) (push) Waiting to run
Test / test (1.21, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.21, ubuntu-latest) (push) Waiting to run
Test / test (1.21, windows-latest) (push) Waiting to run
Test / test (1.22, macos-13) (push) Waiting to run
Test / test (1.22, macos-latest) (push) Waiting to run
Test / test (1.22, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.22, ubuntu-latest) (push) Waiting to run
Test / test (1.22, windows-latest) (push) Waiting to run
Test / test (1.23, macos-13) (push) Waiting to run
Test / test (1.23, macos-latest) (push) Waiting to run
Test / test (1.23, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.23, ubuntu-latest) (push) Waiting to run
Test / test (1.23, windows-latest) (push) Waiting to run
Test / test (1.24, macos-13) (push) Waiting to run
Test / test (1.24, macos-latest) (push) Waiting to run
Test / test (1.24, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.24, ubuntu-latest) (push) Waiting to run
Test / test (1.24, windows-latest) (push) Waiting to run
Test / test (1.25, macos-13) (push) Waiting to run
Test / test (1.25, macos-latest) (push) Waiting to run
Test / test (1.25, ubuntu-24.04-arm) (push) Waiting to run
Test / test (1.25, ubuntu-latest) (push) Waiting to run
Test / test (1.25, windows-latest) (push) Waiting to run
Trigger CMFA Update / trigger-CMFA-update (push) Waiting to run

This commit is contained in:
wwqgtxx 2025-09-11 23:49:14 +08:00
parent 6c527f8d20
commit 909729ca8f
3 changed files with 37 additions and 33 deletions

View File

@ -64,7 +64,6 @@ type VlessOption struct {
HTTP2Opts HTTP2Options `proxy:"h2-opts,omitempty"` HTTP2Opts HTTP2Options `proxy:"h2-opts,omitempty"`
GrpcOpts GrpcOptions `proxy:"grpc-opts,omitempty"` GrpcOpts GrpcOptions `proxy:"grpc-opts,omitempty"`
WSOpts WSOptions `proxy:"ws-opts,omitempty"` WSOpts WSOptions `proxy:"ws-opts,omitempty"`
WSPath string `proxy:"ws-path,omitempty"`
WSHeaders map[string]string `proxy:"ws-headers,omitempty"` WSHeaders map[string]string `proxy:"ws-headers,omitempty"`
SkipCertVerify bool `proxy:"skip-cert-verify,omitempty"` SkipCertVerify bool `proxy:"skip-cert-verify,omitempty"`
Fingerprint string `proxy:"fingerprint,omitempty"` Fingerprint string `proxy:"fingerprint,omitempty"`
@ -407,7 +406,7 @@ func parseVlessAddr(metadata *C.Metadata, xudp bool) *vless.DstAddr {
func NewVless(option VlessOption) (*Vless, error) { func NewVless(option VlessOption) (*Vless, error) {
var addons *vless.Addons var addons *vless.Addons
if option.Network != "ws" && len(option.Flow) >= 16 { if len(option.Flow) >= 16 {
option.Flow = option.Flow[:16] option.Flow = option.Flow[:16]
if option.Flow != vless.XRV { if option.Flow != vless.XRV {
return nil, fmt.Errorf("unsupported xtls flow type: %s", option.Flow) return nil, fmt.Errorf("unsupported xtls flow type: %s", option.Flow)

View File

@ -120,12 +120,14 @@ func TestInboundVless_Encryption(t *testing.T) {
for i := range paddings { for i := range paddings {
padding := paddings[i].data padding := paddings[i].data
t.Run(paddings[i].name, func(t *testing.T) { t.Run(paddings[i].name, func(t *testing.T) {
t.Parallel()
inboundOptions := inbound.VlessOption{ inboundOptions := inbound.VlessOption{
Decryption: "mlkem768x25519plus." + mode + ".600s." + padding + privateKeyBase64 + "." + seedBase64, Decryption: "mlkem768x25519plus." + mode + ".600s." + padding + privateKeyBase64 + "." + seedBase64,
} }
outboundOptions := outbound.VlessOption{ outboundOptions := outbound.VlessOption{
Encryption: "mlkem768x25519plus." + mode + ".0rtt." + padding + passwordBase64 + "." + clientBase64, Encryption: "mlkem768x25519plus." + mode + ".0rtt." + padding + passwordBase64 + "." + clientBase64,
} }
t.Run("raw", func(t *testing.T) {
testInboundVless(t, inboundOptions, outboundOptions) testInboundVless(t, inboundOptions, outboundOptions)
t.Run("xtls-rprx-vision", func(t *testing.T) { t.Run("xtls-rprx-vision", func(t *testing.T) {
outboundOptions := outboundOptions outboundOptions := outboundOptions
@ -133,6 +135,33 @@ func TestInboundVless_Encryption(t *testing.T) {
testInboundVless(t, inboundOptions, outboundOptions) testInboundVless(t, inboundOptions, outboundOptions)
}) })
}) })
t.Run("ws", func(t *testing.T) {
inboundOptions := inboundOptions
inboundOptions.WsPath = "/ws"
outboundOptions := outboundOptions
outboundOptions.Network = "ws"
outboundOptions.WSOpts = outbound.WSOptions{Path: "/ws"}
testInboundVless(t, inboundOptions, outboundOptions)
t.Run("xtls-rprx-vision", func(t *testing.T) {
outboundOptions := outboundOptions
outboundOptions.Flow = "xtls-rprx-vision"
testInboundVless(t, inboundOptions, outboundOptions)
})
})
t.Run("grpc", func(t *testing.T) {
inboundOptions := inboundOptions
inboundOptions.GrpcServiceName = "GunService"
outboundOptions := outboundOptions
outboundOptions.Network = "grpc"
outboundOptions.GrpcOpts = outbound.GrpcOptions{GrpcServiceName: "GunService"}
testInboundVless(t, inboundOptions, outboundOptions)
t.Run("xtls-rprx-vision", func(t *testing.T) {
outboundOptions := outboundOptions
outboundOptions.Flow = "xtls-rprx-vision"
testInboundVless(t, inboundOptions, outboundOptions)
})
})
})
} }
}) })
@ -149,16 +178,9 @@ func TestInboundVless_Wss1(t *testing.T) {
TLS: true, TLS: true,
Fingerprint: tlsFingerprint, Fingerprint: tlsFingerprint,
Network: "ws", Network: "ws",
WSOpts: outbound.WSOptions{ WSOpts: outbound.WSOptions{Path: "/ws"},
Path: "/ws",
},
} }
testInboundVless(t, inboundOptions, outboundOptions) testInboundVless(t, inboundOptions, outboundOptions)
t.Run("xtls-rprx-vision", func(t *testing.T) {
outboundOptions := outboundOptions
outboundOptions.Flow = "xtls-rprx-vision"
testInboundVless(t, inboundOptions, outboundOptions)
})
t.Run("ECH", func(t *testing.T) { t.Run("ECH", func(t *testing.T) {
inboundOptions := inboundOptions inboundOptions := inboundOptions
outboundOptions := outboundOptions outboundOptions := outboundOptions
@ -168,11 +190,6 @@ func TestInboundVless_Wss1(t *testing.T) {
Config: echConfigBase64, Config: echConfigBase64,
} }
testInboundVless(t, inboundOptions, outboundOptions) testInboundVless(t, inboundOptions, outboundOptions)
t.Run("xtls-rprx-vision", func(t *testing.T) {
outboundOptions := outboundOptions
outboundOptions.Flow = "xtls-rprx-vision"
testInboundVless(t, inboundOptions, outboundOptions)
})
}) })
} }
@ -187,16 +204,9 @@ func TestInboundVless_Wss2(t *testing.T) {
TLS: true, TLS: true,
Fingerprint: tlsFingerprint, Fingerprint: tlsFingerprint,
Network: "ws", Network: "ws",
WSOpts: outbound.WSOptions{ WSOpts: outbound.WSOptions{Path: "/ws"},
Path: "/ws",
},
} }
testInboundVless(t, inboundOptions, outboundOptions) testInboundVless(t, inboundOptions, outboundOptions)
t.Run("xtls-rprx-vision", func(t *testing.T) {
outboundOptions := outboundOptions
outboundOptions.Flow = "xtls-rprx-vision"
testInboundVless(t, inboundOptions, outboundOptions)
})
t.Run("ECH", func(t *testing.T) { t.Run("ECH", func(t *testing.T) {
inboundOptions := inboundOptions inboundOptions := inboundOptions
outboundOptions := outboundOptions outboundOptions := outboundOptions
@ -206,11 +216,6 @@ func TestInboundVless_Wss2(t *testing.T) {
Config: echConfigBase64, Config: echConfigBase64,
} }
testInboundVless(t, inboundOptions, outboundOptions) testInboundVless(t, inboundOptions, outboundOptions)
t.Run("xtls-rprx-vision", func(t *testing.T) {
outboundOptions := outboundOptions
outboundOptions.Flow = "xtls-rprx-vision"
testInboundVless(t, inboundOptions, outboundOptions)
})
}) })
} }

View File

@ -82,7 +82,7 @@ func NewConn(conn net.Conn, tlsConn net.Conn, userUUID uuid.UUID) (*Conn, error)
} }
if t == nil || p == nil { if t == nil || p == nil {
log.Warnln("vision: not a valid supported TLS connection: %s", reflect.TypeOf(tlsConn)) log.Warnln("vision: not a valid supported TLS connection: %s", reflect.TypeOf(tlsConn))
return nil, fmt.Errorf(`failed to use vision, maybe "security" is not "tls" or "utls"`) return nil, fmt.Errorf(`failed to use vision, maybe "tls" is not enable and "encryption" is empty`)
} }
if err := checkTLSVersion(tlsConn); err != nil { if err := checkTLSVersion(tlsConn); err != nil {