From 5836afc41f780a48fba99460f30f7b6d1295c70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8F=90=E7=90=85=E5=BD=A9=E5=B1=B1=E6=B0=B4=E4=BD=A9?= =?UTF-8?q?=E5=A5=87=E7=AB=A5=E8=BD=A6=E6=B8=B8=E6=98=A5=E9=A9=AC=E8=B9=84?= =?UTF-8?q?=E6=9D=AF?= Date: Tue, 17 Dec 2024 16:53:16 +0800 Subject: [PATCH] WebSocket config: Fix `headers` (#4177) Fixes https://github.com/XTLS/Xray-core/issues/4176 --- infra/conf/transport_internet.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/infra/conf/transport_internet.go b/infra/conf/transport_internet.go index 08f5768e..1731695d 100644 --- a/infra/conf/transport_internet.go +++ b/infra/conf/transport_internet.go @@ -165,11 +165,13 @@ func (c *WebSocketConfig) Build() (proto.Message, error) { } // Priority (client): host > serverName > address for k, v := range c.Headers { - errors.PrintDeprecatedFeatureWarning(`"host" in "headers"`, `independent "host"`) - if c.Host == "" { - c.Host = v + if strings.ToLower(k) == "host"{ + errors.PrintDeprecatedFeatureWarning(`"host" in "headers"`, `independent "host"`) + if c.Host == "" { + c.Host = v + } + delete(c.Headers, k) } - delete(c.Headers, k) } config := &websocket.Config{ Path: path,