From 55a8d038d65745054191415effdb7a88cf100024 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Fri, 15 Jul 2022 21:08:11 +0800 Subject: [PATCH] Improve: ignore tcp errors --- tunnel/tcp.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tunnel/tcp.go b/tunnel/tcp.go index 9b922b4..569db02 100644 --- a/tunnel/tcp.go +++ b/tunnel/tcp.go @@ -1,9 +1,11 @@ package tunnel import ( + "errors" "io" "net" "sync" + "syscall" "time" "github.com/xjasonlyu/tun2socks/v2/common/pool" @@ -79,6 +81,10 @@ func copyBuffer(dst io.Writer, src io.Reader) error { _, err := io.CopyBuffer(dst, src, buf) if ne, ok := err.(net.Error); ok && ne.Timeout() { return nil /* ignore I/O timeout */ + } else if errors.Is(err, syscall.EPIPE) { + return nil /* ignore broken pipe */ + } else if errors.Is(err, syscall.ECONNRESET) { + return nil /* ignore connection reset by peer */ } return err }