From c6cceeb0c589983ee0758f1bbbe6fd7ad1f3a1eb Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Tue, 19 Oct 2021 22:34:18 +0800 Subject: [PATCH] Chore: use alpn http 1.1 only on trojan websocket by default --- transport/trojan/trojan.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/transport/trojan/trojan.go b/transport/trojan/trojan.go index 26e7adc7..9d9a33b9 100644 --- a/transport/trojan/trojan.go +++ b/transport/trojan/trojan.go @@ -22,8 +22,10 @@ const ( ) var ( - defaultALPN = []string{"h2", "http/1.1"} - crlf = []byte{'\r', '\n'} + defaultALPN = []string{"h2", "http/1.1"} + defaultWebsocketALPN = []string{"http/1.1"} + + crlf = []byte{'\r', '\n'} ) type Command = byte @@ -74,7 +76,7 @@ func (t *Trojan) StreamConn(conn net.Conn) (net.Conn, error) { } func (t *Trojan) StreamWebsocketConn(conn net.Conn, wsOptions *WebsocketOption) (net.Conn, error) { - alpn := defaultALPN + alpn := defaultWebsocketALPN if len(t.option.ALPN) != 0 { alpn = t.option.ALPN }