mirror of
https://github.com/v2fly/v2ray-core
synced 2024-02-27 03:18:06 +00:00
proxy: Unify timeouts of different protocols for reading the first payload
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/http2"
|
||||
|
||||
@@ -23,6 +22,7 @@ import (
|
||||
"github.com/v2fly/v2ray-core/v5/common/signal"
|
||||
"github.com/v2fly/v2ray-core/v5/common/task"
|
||||
"github.com/v2fly/v2ray-core/v5/features/policy"
|
||||
"github.com/v2fly/v2ray-core/v5/proxy"
|
||||
"github.com/v2fly/v2ray-core/v5/transport"
|
||||
"github.com/v2fly/v2ray-core/v5/transport/internet"
|
||||
"github.com/v2fly/v2ray-core/v5/transport/internet/tls"
|
||||
@@ -83,11 +83,11 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
|
||||
var firstPayload []byte
|
||||
|
||||
if reader, ok := link.Reader.(buf.TimeoutReader); ok {
|
||||
// 0-RTT optimization for HTTP/2: If the payload comes within 50 ms, it can be
|
||||
// 0-RTT optimization for HTTP/2: If the payload comes very soon, it can be
|
||||
// transmitted together. Note we should not get stuck here, as the payload may
|
||||
// not exist (considering to access MySQL database via a HTTP proxy, where the
|
||||
// server sends hello to the client first).
|
||||
if mbuf, _ := reader.ReadMultiBufferTimeout(50 * time.Millisecond); mbuf != nil {
|
||||
if mbuf, _ := reader.ReadMultiBufferTimeout(proxy.FirstPayloadTimeout); mbuf != nil {
|
||||
mlen := mbuf.Len()
|
||||
firstPayload = bytespool.Alloc(mlen)
|
||||
mbuf, _ = buf.SplitBytes(mbuf, firstPayload)
|
||||
|
||||
Reference in New Issue
Block a user