From 30008fdf9c0e7f4e9b666c66fcff107bdc3d4eba Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Tue, 18 Jan 2022 10:05:06 +0800 Subject: [PATCH] Merge from remote branch[ssh] --- transport/vless/xtls.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/transport/vless/xtls.go b/transport/vless/xtls.go index 69035aa0..6e2a4d46 100644 --- a/transport/vless/xtls.go +++ b/transport/vless/xtls.go @@ -1,8 +1,10 @@ package vless import ( + "context" "net" + C "github.com/Dreamacro/clash/constant" xtls "github.com/xtls/go" ) @@ -20,6 +22,10 @@ func StreamXTLSConn(conn net.Conn, cfg *XTLSConfig) (net.Conn, error) { } xtlsConn := xtls.Client(conn, xtlsConfig) - err := xtlsConn.Handshake() + + // fix tls handshake not timeout + ctx, cancel := context.WithTimeout(context.Background(), C.DefaultTLSTimeout) + defer cancel() + err := xtlsConn.HandshakeContext(ctx) return xtlsConn, err }