2022-04-25 19:50:20 +08:00
|
|
|
package net
|
|
|
|
|
2023-01-16 10:50:31 +08:00
|
|
|
//import (
|
|
|
|
// "io"
|
|
|
|
// "net"
|
|
|
|
// "time"
|
|
|
|
//)
|
|
|
|
//
|
|
|
|
//// Relay copies between left and right bidirectionally.
|
|
|
|
//func Relay(leftConn, rightConn net.Conn) {
|
|
|
|
// ch := make(chan error)
|
|
|
|
//
|
|
|
|
// go func() {
|
|
|
|
// // Wrapping to avoid using *net.TCPConn.(ReadFrom)
|
2023-11-03 21:01:45 +08:00
|
|
|
// // See also https://github.com/metacubex/mihomo/pull/1209
|
2023-01-16 10:50:31 +08:00
|
|
|
// _, err := io.Copy(WriteOnlyWriter{Writer: leftConn}, ReadOnlyReader{Reader: rightConn})
|
|
|
|
// leftConn.SetReadDeadline(time.Now())
|
|
|
|
// ch <- err
|
|
|
|
// }()
|
|
|
|
//
|
|
|
|
// _, _ = io.Copy(WriteOnlyWriter{Writer: rightConn}, ReadOnlyReader{Reader: leftConn})
|
|
|
|
// rightConn.SetReadDeadline(time.Now())
|
|
|
|
// <-ch
|
|
|
|
//}
|