pull/432/head
Darien Raymond 8 years ago
parent 73c4696e00
commit 3161c56aba
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -113,7 +113,7 @@ func (m *Client) Closed() bool {
func (m *Client) fetchInput(ctx context.Context, s *session) {
dest, _ := proxy.TargetFromContext(ctx)
writer := &MuxWriter{
writer := &Writer{
dest: dest,
id: s.id,
writer: m.inboundRay.InboundInput(),

@ -20,7 +20,7 @@ func TestReaderWriter(t *testing.T) {
payload := buf.New()
payload.AppendBytes('a', 'b', 'c', 'd')
writer.Write(payload)
assert.Error(writer.Write(payload)).IsNil()
writer.Close()

@ -7,20 +7,20 @@ import (
"v2ray.com/core/common/serial"
)
type MuxReader struct {
type Reader struct {
reader io.Reader
remainingLength int
buffer *buf.Buffer
}
func NewReader(reader buf.Reader) *MuxReader {
return &MuxReader{
func NewReader(reader buf.Reader) *Reader {
return &Reader{
reader: buf.ToBytesReader(reader),
buffer: buf.NewLocal(1024),
}
}
func (r *MuxReader) ReadMetadata() (*FrameMetadata, error) {
func (r *Reader) ReadMetadata() (*FrameMetadata, error) {
b := r.buffer
b.Clear()
@ -35,7 +35,7 @@ func (r *MuxReader) ReadMetadata() (*FrameMetadata, error) {
return ReadFrameFrom(b.Bytes())
}
func (r *MuxReader) Read() (*buf.Buffer, bool, error) {
func (r *Reader) Read() (*buf.Buffer, bool, error) {
b := buf.New()
var dataLen int
if r.remainingLength > 0 {

@ -6,22 +6,22 @@ import (
"v2ray.com/core/common/serial"
)
type MuxWriter struct {
type Writer struct {
id uint16
dest net.Destination
writer buf.Writer
followup bool
}
func NewWriter(id uint16, dest net.Destination, writer buf.Writer) *MuxWriter {
return &MuxWriter{
func NewWriter(id uint16, dest net.Destination, writer buf.Writer) *Writer {
return &Writer{
id: id,
dest: dest,
writer: writer,
}
}
func (w *MuxWriter) writeInternal(b *buf.Buffer) error {
func (w *Writer) writeInternal(b *buf.Buffer) error {
meta := FrameMetadata{
SessionID: w.id,
Target: w.dest,
@ -57,7 +57,7 @@ func (w *MuxWriter) writeInternal(b *buf.Buffer) error {
return w.writer.Write(frame)
}
func (w *MuxWriter) Write(b *buf.Buffer) error {
func (w *Writer) Write(b *buf.Buffer) error {
defer b.Release()
if err := w.writeInternal(b); err != nil {
@ -71,7 +71,7 @@ func (w *MuxWriter) Write(b *buf.Buffer) error {
return nil
}
func (w *MuxWriter) Close() {
func (w *Writer) Close() {
meta := FrameMetadata{
SessionID: w.id,
Target: w.dest,

Loading…
Cancel
Save