relay.go 620 B

123456789101112131415161718192021222324
  1. package net
  2. //import (
  3. // "io"
  4. // "net"
  5. // "time"
  6. //)
  7. //
  8. //// Relay copies between left and right bidirectionally.
  9. //func Relay(leftConn, rightConn net.Conn) {
  10. // ch := make(chan error)
  11. //
  12. // go func() {
  13. // // Wrapping to avoid using *net.TCPConn.(ReadFrom)
  14. // // See also https://github.com/metacubex/mihomo/pull/1209
  15. // _, err := io.Copy(WriteOnlyWriter{Writer: leftConn}, ReadOnlyReader{Reader: rightConn})
  16. // leftConn.SetReadDeadline(time.Now())
  17. // ch <- err
  18. // }()
  19. //
  20. // _, _ = io.Copy(WriteOnlyWriter{Writer: rightConn}, ReadOnlyReader{Reader: leftConn})
  21. // rightConn.SetReadDeadline(time.Now())
  22. // <-ch
  23. //}