From 42d83a703e246755db8a45f53e0296622f7be5e5 Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 9 Feb 2018 22:29:30 +0100 Subject: [PATCH] fix transfer for mux --- common/protocol/headers.go | 9 ++++++--- proxy/vmess/encoding/client.go | 4 ++-- proxy/vmess/encoding/server.go | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/common/protocol/headers.go b/common/protocol/headers.go index 092de5ea..b8fc5885 100644 --- a/common/protocol/headers.go +++ b/common/protocol/headers.go @@ -18,11 +18,14 @@ const ( ) func (c RequestCommand) TransferType() TransferType { - if c == RequestCommandTCP { + switch c { + case RequestCommandTCP, RequestCommandMux: + return TransferTypeStream + case RequestCommandUDP: + return TransferTypePacket + default: return TransferTypeStream } - - return TransferTypePacket } const ( diff --git a/proxy/vmess/encoding/client.go b/proxy/vmess/encoding/client.go index 8352a3ee..cc930dc5 100644 --- a/proxy/vmess/encoding/client.go +++ b/proxy/vmess/encoding/client.go @@ -131,7 +131,7 @@ func (c *ClientSession) EncodeRequestBody(request *protocol.RequestHeader, write } if request.Security.Is(protocol.SecurityType_NONE) { if request.Option.Has(protocol.RequestOptionChunkStream) { - if request.Command == protocol.RequestCommandTCP { + if request.Command.TransferType() == protocol.TransferTypeStream { return crypto.NewChunkStreamWriter(sizeParser, writer) } auth := &crypto.AEADAuthenticator{ @@ -236,7 +236,7 @@ func (c *ClientSession) DecodeResponseBody(request *protocol.RequestHeader, read } if request.Security.Is(protocol.SecurityType_NONE) { if request.Option.Has(protocol.RequestOptionChunkStream) { - if request.Command == protocol.RequestCommandTCP { + if request.Command.TransferType() == protocol.TransferTypeStream { return crypto.NewChunkStreamReader(sizeParser, reader) } diff --git a/proxy/vmess/encoding/server.go b/proxy/vmess/encoding/server.go index ea6bffa6..bd691db2 100644 --- a/proxy/vmess/encoding/server.go +++ b/proxy/vmess/encoding/server.go @@ -252,7 +252,7 @@ func (s *ServerSession) DecodeRequestBody(request *protocol.RequestHeader, reade } if request.Security.Is(protocol.SecurityType_NONE) { if request.Option.Has(protocol.RequestOptionChunkStream) { - if request.Command == protocol.RequestCommandTCP { + if request.Command.TransferType() == protocol.TransferTypeStream { return crypto.NewChunkStreamReader(sizeParser, reader) } @@ -338,7 +338,7 @@ func (s *ServerSession) EncodeResponseBody(request *protocol.RequestHeader, writ } if request.Security.Is(protocol.SecurityType_NONE) { if request.Option.Has(protocol.RequestOptionChunkStream) { - if request.Command == protocol.RequestCommandTCP { + if request.Command.TransferType() == protocol.TransferTypeStream { return crypto.NewChunkStreamWriter(sizeParser, writer) }