From bb9ad6cac075d55471b3a14f60b9d25c7a980461 Mon Sep 17 00:00:00 2001 From: H1JK Date: Mon, 20 Nov 2023 22:19:38 +0800 Subject: [PATCH] fix: Trojan websocket header panic --- adapter/outbound/trojan.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/adapter/outbound/trojan.go b/adapter/outbound/trojan.go index cd1dd28c..f03c3be9 100644 --- a/adapter/outbound/trojan.go +++ b/adapter/outbound/trojan.go @@ -57,6 +57,7 @@ func (t *Trojan) plainStream(ctx context.Context, c net.Conn) (net.Conn, error) Port: port, Path: t.option.WSOpts.Path, V2rayHttpUpgrade: t.option.WSOpts.V2rayHttpUpgrade, + Headers: http.Header{}, } if t.option.SNI != "" { @@ -64,11 +65,9 @@ func (t *Trojan) plainStream(ctx context.Context, c net.Conn) (net.Conn, error) } if len(t.option.WSOpts.Headers) != 0 { - header := http.Header{} for key, value := range t.option.WSOpts.Headers { - header.Add(key, value) + wsOpts.Headers.Add(key, value) } - wsOpts.Headers = header } return t.instance.StreamWebsocketConn(ctx, c, wsOpts)