From 740a6b0dcd06c7f357ae6f8906f5d280a1620a3c Mon Sep 17 00:00:00 2001 From: RPRX <63339210+RPRX@users.noreply.github.com> Date: Sat, 25 Jan 2025 11:15:42 +0000 Subject: [PATCH] RAW: Allow setting ALPN `http/1.1` for non-REALITY uTLS https://github.com/XTLS/Xray-core/issues/4313#issuecomment-2611889517 --- transport/internet/tcp/dialer.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/transport/internet/tcp/dialer.go b/transport/internet/tcp/dialer.go index bf50ed72..19b3f6b4 100644 --- a/transport/internet/tcp/dialer.go +++ b/transport/internet/tcp/dialer.go @@ -24,8 +24,14 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me tlsConfig := config.GetTLSConfig(tls.WithDestination(dest)) if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil { conn = tls.UClient(conn, tlsConfig, fingerprint) - if err := conn.(*tls.UConn).HandshakeContext(ctx); err != nil { - return nil, err + if len(tlsConfig.NextProtos) == 1 && tlsConfig.NextProtos[0] == "http/1.1" { + if err := conn.(*tls.UConn).WebsocketHandshakeContext(ctx); err != nil { + return nil, err + } + } else { + if err := conn.(*tls.UConn).HandshakeContext(ctx); err != nil { + return nil, err + } } } else { conn = tls.Client(conn, tlsConfig)