1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-14 00:07:09 -05:00

refine reader creation in vmess inbound

This commit is contained in:
Darien Raymond 2018-07-31 19:33:54 +02:00
parent 200ce404c6
commit d665cf3e72
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -224,17 +224,7 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
return newError("unable to set read deadline").Base(err).AtWarning()
}
var reader *buf.BufferedReader
{
var r buf.Reader
if sessionPolicy.Buffer.PerConnection == 0 {
r = &buf.SingleReader{Reader: connection}
} else {
r = buf.NewReader(connection)
}
reader = &buf.BufferedReader{Reader: r}
}
reader := &buf.BufferedReader{Reader: &buf.SingleReader{Reader: connection}}
svrSession := encoding.NewServerSession(h.clients, h.sessionHistory)
request, err := svrSession.DecodeRequestHeader(reader)
@ -290,6 +280,9 @@ func (h *Handler) Process(ctx context.Context, network net.Network, connection i
requestDone := func() error {
defer timer.SetTimeout(sessionPolicy.Timeouts.DownlinkOnly)
if sessionPolicy.Buffer.PerConnection > 0 {
reader.Reader = buf.NewReader(connection)
}
return transferRequest(timer, svrSession, request, reader, link.Writer)
}