Fix: io timeout when snell v2 reuse connection (#1362)

This commit is contained in:
Kaming Chan 2021-04-19 14:36:06 +08:00 committed by GitHub
parent d9341a49ea
commit df5112175f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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
}