You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
855 B

  1. // +build !go1.10
  2. package conn
  3. import (
  4. "net"
  5. "time"
  6. )
  7. // Only Go1.10 has a proper net.Conn implementation that
  8. // has the SetDeadline method implemented as per
  9. // https://github.com/golang/go/commit/e2dd8ca946be884bb877e074a21727f1a685a706
  10. // lest we run into problems like
  11. // https://github.com/tendermint/tendermint/issues/851
  12. // so for go versions < Go1.10 use our custom net.Conn creator
  13. // that doesn't return an `Unimplemented error` for net.Conn.
  14. // Before https://github.com/tendermint/tendermint/commit/49faa79bdce5663894b3febbf4955fb1d172df04
  15. // we hadn't cared about errors from SetDeadline so swallow them up anyways.
  16. type pipe struct {
  17. net.Conn
  18. }
  19. func (p *pipe) SetDeadline(t time.Time) error {
  20. return nil
  21. }
  22. func NetPipe() (net.Conn, net.Conn) {
  23. p1, p2 := net.Pipe()
  24. return &pipe{p1}, &pipe{p2}
  25. }
  26. var _ net.Conn = (*pipe)(nil)