Xray-core: More robust browser header masquerading (chrome, firefox, edge) (#5802)

Fixes https://github.com/XTLS/Xray-core/issues/5800
This commit is contained in:
Lumière Élevé
2026-03-21 12:24:08 +00:00
committed by GitHub
parent bb05684407
commit 9e09399087
12 changed files with 212 additions and 21 deletions
+10 -2
View File
@@ -10,8 +10,8 @@ import (
c "github.com/xtls/xray-core/common/ctx"
"github.com/xtls/xray-core/common/errors"
"github.com/xtls/xray-core/common/net"
"github.com/xtls/xray-core/common/session"
"github.com/xtls/xray-core/common/utils"
"github.com/xtls/xray-core/common/session"
"github.com/xtls/xray-core/transport/internet"
"github.com/xtls/xray-core/transport/internet/grpc/encoding"
"github.com/xtls/xray-core/transport/internet/reality"
@@ -191,8 +191,16 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in
)
if err == nil {
userAgent := grpcSettings.UserAgent
if userAgent == "" {
// It's NOT recommended to set the UA of gRPC connections to that of real browsers, as they are fundamentally incapable of initiating real gRPC connections.
switch userAgent {
case "chrome", "":
userAgent = utils.ChromeUA
case "firefox":
userAgent = utils.FirefoxUA
case "edge":
userAgent = utils.MSEdgeUA
case "golang":
userAgent = ""
}
setUserAgent(conn, userAgent)
conn.Connect()