1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-04 08:15:21 -05:00

support packet transfer type in mux

This commit is contained in:
Darien Raymond
2017-05-02 22:23:07 +02:00
parent 96da76c5b0
commit 7a4bab4940
13 changed files with 258 additions and 161 deletions

View File

@@ -1,8 +1,11 @@
package mux
import (
"io"
"sync"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/protocol"
"v2ray.com/core/transport/ray"
)
@@ -119,6 +122,7 @@ type Session struct {
ID uint16
uplinkClosed bool
downlinkClosed bool
transferType protocol.TransferType
}
func (s *Session) CloseUplink() {
@@ -142,3 +146,10 @@ func (s *Session) CloseDownlink() {
s.parent.Remove(s.ID)
}
}
func (s *Session) NewReader(reader io.Reader) buf.Reader {
if s.transferType == protocol.TransferTypeStream {
return NewStreamReader(reader)
}
return NewPacketReader(reader)
}