mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-10 05:52:20 +08:00
30 lines
411 B
Go
30 lines
411 B
Go
package mocknet
|
|
|
|
import (
|
|
"io"
|
|
|
|
inet "github.com/jbenet/go-ipfs/net"
|
|
)
|
|
|
|
// stream implements inet.Stream
|
|
type stream struct {
|
|
io.Reader
|
|
io.Writer
|
|
conn *conn
|
|
}
|
|
|
|
func (s *stream) Close() error {
|
|
s.conn.removeStream(s)
|
|
if r, ok := (s.Reader).(io.Closer); ok {
|
|
r.Close()
|
|
}
|
|
if w, ok := (s.Writer).(io.Closer); ok {
|
|
return w.Close()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (s *stream) Conn() inet.Conn {
|
|
return s.conn
|
|
}
|