mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-07 09:41:09 +08:00
Chore: error is ignorable
This commit is contained in:
@@ -79,12 +79,19 @@ func copyBuffer(dst io.Writer, src io.Reader) error {
|
||||
defer pool.Put(buf)
|
||||
|
||||
_, 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 */
|
||||
if err != nil && !isIgnorable(err) {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
return nil
|
||||
}
|
||||
|
||||
func isIgnorable(err error) bool {
|
||||
if ne, ok := err.(net.Error); ok && ne.Timeout() {
|
||||
return true /* ignore I/O timeout */
|
||||
} else if errors.Is(err, syscall.EPIPE) {
|
||||
return true /* ignore broken pipe */
|
||||
} else if errors.Is(err, syscall.ECONNRESET) {
|
||||
return true /* ignore connection reset by peer */
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user