From df5112175f251f7c68261680b792e63cc0195e70 Mon Sep 17 00:00:00 2001 From: Kaming Chan Date: Mon, 19 Apr 2021 14:36:06 +0800 Subject: [PATCH] Fix: io timeout when snell v2 reuse connection (#1362) --- component/snell/pool.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/component/snell/pool.go b/component/snell/pool.go index b169c128..6eda2a9d 100644 --- a/component/snell/pool.go +++ b/component/snell/pool.go @@ -3,6 +3,7 @@ package snell import ( "context" "net" + "time" "github.com/Dreamacro/clash/component/pool" @@ -61,6 +62,9 @@ func (pc *PoolConn) Write(b []byte) (int, error) { } func (pc *PoolConn) Close() error { + // clash use SetReadDeadline to break bidirectional copy between client and server. + // reset it before reuse connection to avoid io timeout error. + pc.Snell.Conn.SetReadDeadline(time.Time{}) pc.pool.Put(pc.Snell) return nil }