diff --git a/client/main.go b/client/main.go index 4903aff..26fcfbc 100644 --- a/client/main.go +++ b/client/main.go @@ -1760,8 +1760,8 @@ func (r *relayPacketConn) SetWriteDeadline(t time.Time) error { return r.relay.S func pipe(ctx context.Context, c1, c2 net.Conn) { ctx2, cancel := context.WithCancel(ctx) context.AfterFunc(ctx2, func() { - c1.SetDeadline(time.Now()) - c2.SetDeadline(time.Now()) + _ = c1.SetDeadline(time.Now()) + _ = c2.SetDeadline(time.Now()) }) var wg sync.WaitGroup @@ -1769,14 +1769,14 @@ func pipe(ctx context.Context, c1, c2 net.Conn) { go func() { defer wg.Done() defer cancel() - io.Copy(c1, c2) + _, _ = io.Copy(c1, c2) }() go func() { defer wg.Done() defer cancel() - io.Copy(c2, c1) + _, _ = io.Copy(c2, c1) }() wg.Wait() - c1.SetDeadline(time.Time{}) - c2.SetDeadline(time.Time{}) + _ = c1.SetDeadline(time.Time{}) + _ = c2.SetDeadline(time.Time{}) } diff --git a/server/main.go b/server/main.go index aac6a41..ad4b368 100644 --- a/server/main.go +++ b/server/main.go @@ -270,8 +270,8 @@ func handleTCPConnection(ctx context.Context, dtlsConn net.Conn, connectAddr str func pipeConn(ctx context.Context, c1, c2 net.Conn) { ctx2, cancel := context.WithCancel(ctx) context.AfterFunc(ctx2, func() { - c1.SetDeadline(time.Now()) - c2.SetDeadline(time.Now()) + _ = c1.SetDeadline(time.Now()) + _ = c2.SetDeadline(time.Now()) }) var wg sync.WaitGroup @@ -279,14 +279,14 @@ func pipeConn(ctx context.Context, c1, c2 net.Conn) { go func() { defer wg.Done() defer cancel() - io.Copy(c1, c2) + _, _ = io.Copy(c1, c2) }() go func() { defer wg.Done() defer cancel() - io.Copy(c2, c1) + _, _ = io.Copy(c2, c1) }() wg.Wait() - c1.SetDeadline(time.Time{}) - c2.SetDeadline(time.Time{}) + _ = c1.SetDeadline(time.Time{}) + _ = c2.SetDeadline(time.Time{}) } diff --git a/tcputil/tcputil.go b/tcputil/tcputil.go index 260cce3..f36bbdc 100644 --- a/tcputil/tcputil.go +++ b/tcputil/tcputil.go @@ -63,7 +63,9 @@ func NewKCPOverDTLS(dtlsConn net.Conn, isServer bool) (*kcp.UDPSession, error) { if err != nil { return nil, err } - listener.SetDeadline(time.Now().Add(30 * time.Second)) + if err = listener.SetDeadline(time.Now().Add(30 * time.Second)); err != nil { + return nil, err + } sess, err = listener.AcceptKCP() if err != nil { return nil, err @@ -83,7 +85,6 @@ func NewKCPOverDTLS(dtlsConn net.Conn, isServer bool) (*kcp.UDPSession, error) { sess.SetWindowSize(256, 256) sess.SetMtu(1200) // conservative MTU to fit inside DTLS+TURN sess.SetACKNoDelay(true) - sess.SetStreamMode(true) return sess, nil }