Skip to content

Commit

Permalink
ignore broken pipe error
Browse files Browse the repository at this point in the history
  • Loading branch information
FlowerWrong committed Jan 26, 2018
1 parent ec57d3b commit ef13950
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tunnel/tcp2socks.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ readFromLocal:
n, err := tcpTunnel.remoteConn.Write(v)
if err != nil {
if !util.IsEOF(err) {
// FIXME write: broken pipe. because of remote timeout and closed. always 46 bytes, start with "23 3 3 0 41 0 0 0 0 0 0 0", what?
log.Println("[error] write packet to remote failed", err, tcpTunnel.remoteAddr)
if !util.IsBrokenPipe(err) {
log.Println("[error] write packet to remote failed", err, tcpTunnel.remoteAddr)
}
tcpTunnel.Close(err)
}
break readFromLocal
Expand Down
9 changes: 9 additions & 0 deletions util/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package util
import (
"io"
"net"
"syscall"

"github.com/FlowerWrong/netstack/tcpip"
)
Expand Down Expand Up @@ -40,3 +41,11 @@ func IsTimeout(err error) bool {
}
return false
}

// IsBrokenPipe check this is broken pipe or not
func IsBrokenPipe(err error) bool {
if err == syscall.EPIPE {
return true
}
return false
}

0 comments on commit ef13950

Please sign in to comment.