mirror of https://github.com/v2ray/v2ray-core
force chunked stream
parent
ea6ccb88af
commit
58530e6920
|
@ -6,6 +6,7 @@ import (
|
|||
"github.com/v2ray/v2ray-core/app"
|
||||
"github.com/v2ray/v2ray-core/app/dispatcher"
|
||||
"github.com/v2ray/v2ray-core/app/proxyman"
|
||||
"github.com/v2ray/v2ray-core/common/alloc"
|
||||
v2io "github.com/v2ray/v2ray-core/common/io"
|
||||
"github.com/v2ray/v2ray-core/common/log"
|
||||
v2net "github.com/v2ray/v2ray-core/common/net"
|
||||
|
@ -185,6 +186,9 @@ func (this *VMessInboundHandler) HandleConnection(connection hub.Connection) {
|
|||
writer = vmessio.NewAuthChunkWriter(writer)
|
||||
}
|
||||
v2io.Pipe(output, writer)
|
||||
if request.Option.IsChunkStream() {
|
||||
writer.Write(alloc.NewSmallBuffer().Clear())
|
||||
}
|
||||
output.Release()
|
||||
writer.Release()
|
||||
finish.Unlock()
|
||||
|
@ -192,8 +196,8 @@ func (this *VMessInboundHandler) HandleConnection(connection hub.Connection) {
|
|||
writeFinish.Lock()
|
||||
}
|
||||
|
||||
connection.CloseWrite()
|
||||
readFinish.Lock()
|
||||
writeFinish.Lock()
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -27,6 +27,9 @@ func (this *AuthChunkReader) Read() (*alloc.Buffer, error) {
|
|||
}
|
||||
|
||||
length := serial.BytesLiteral(buffer.Value[:2]).Uint16Value()
|
||||
if length == 4 { // Length of authentication bytes.
|
||||
return nil, io.EOF
|
||||
}
|
||||
if _, err := io.ReadFull(this.reader, buffer.Value[:length]); err != nil {
|
||||
buffer.Release()
|
||||
return nil, err
|
||||
|
|
|
@ -35,9 +35,7 @@ func (this *VMessOutboundHandler) Dispatch(target v2net.Destination, payload *al
|
|||
Command: command,
|
||||
Address: target.Address(),
|
||||
Port: target.Port(),
|
||||
}
|
||||
if command == proto.RequestCommandUDP {
|
||||
request.Option |= proto.RequestOptionChunkStream
|
||||
Option: proto.RequestOptionChunkStream,
|
||||
}
|
||||
|
||||
conn, err := dialer.Dial(destination)
|
||||
|
@ -65,10 +63,6 @@ func (this *VMessOutboundHandler) Dispatch(target v2net.Destination, payload *al
|
|||
go this.handleResponse(session, conn, request, destination, output, &responseFinish)
|
||||
|
||||
requestFinish.Lock()
|
||||
if tcpConn, ok := conn.(*net.TCPConn); ok {
|
||||
tcpConn.CloseWrite()
|
||||
}
|
||||
|
||||
responseFinish.Lock()
|
||||
output.Close()
|
||||
input.Release()
|
||||
|
@ -97,6 +91,9 @@ func (this *VMessOutboundHandler) handleRequest(session *raw.ClientSession, conn
|
|||
streamWriter = vmessio.NewAuthChunkWriter(streamWriter)
|
||||
}
|
||||
v2io.Pipe(input, streamWriter)
|
||||
if request.Option.IsChunkStream() {
|
||||
streamWriter.Write(alloc.NewSmallBuffer().Clear())
|
||||
}
|
||||
streamWriter.Release()
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue