Improve: cleanup code

This commit is contained in:
Dreamacro
2018-09-21 11:33:29 +08:00
parent 0caa8e05a3
commit eb778ad6e2
4 changed files with 16 additions and 9 deletions

View File

@ -5,6 +5,7 @@ import (
"io"
"net"
"net/http"
"time"
"github.com/Dreamacro/clash/adapters/local"
C "github.com/Dreamacro/clash/constant"
@ -66,9 +67,11 @@ func relay(leftConn, rightConn net.Conn) {
go func() {
_, err := io.Copy(leftConn, rightConn)
leftConn.SetReadDeadline(time.Now())
ch <- err
}()
io.Copy(rightConn, leftConn)
rightConn.SetReadDeadline(time.Now())
<-ch
}