1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-02 15:25:28 -05:00

multi reader

This commit is contained in:
Darien Raymond
2017-04-15 22:22:29 +02:00
parent ed7b22622c
commit abe790181e
5 changed files with 61 additions and 5 deletions

View File

@@ -128,8 +128,9 @@ type Connection struct {
localAddr net.Addr
remoteAddr net.Addr
reader io.Reader
writer buf.Writer
bytesReader io.Reader
reader buf.Reader
writer buf.Writer
}
func NewConnection(stream ray.Ray) *Connection {
@@ -143,8 +144,9 @@ func NewConnection(stream ray.Ray) *Connection {
IP: []byte{0, 0, 0, 0},
Port: 0,
},
reader: buf.ToBytesReader(stream.InboundOutput()),
writer: stream.InboundInput(),
bytesReader: buf.ToBytesReader(stream.InboundOutput()),
reader: stream.InboundOutput(),
writer: stream.InboundInput(),
}
}
@@ -153,7 +155,11 @@ func (v *Connection) Read(b []byte) (int, error) {
if v.closed {
return 0, io.EOF
}
return v.reader.Read(b)
return v.bytesReader.Read(b)
}
func (v *Connection) ReadMultiBuffer() (buf.MultiBuffer, error) {
return v.reader.Read()
}
// Write implements net.Conn.Write().