proxy: Unify timeouts of different protocols for reading the first payload

This commit is contained in:
lrh2000
2022-06-25 19:34:32 +01:00
committed by Shelikhoo
parent 17d85263e2
commit 396ee770b7
6 changed files with 16 additions and 13 deletions
+3 -4
View File
@@ -6,9 +6,6 @@ import (
"context"
"crypto/hmac"
"crypto/sha256"
"hash/crc64"
"time"
core "github.com/v2fly/v2ray-core/v5"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/common/buf"
@@ -21,10 +18,12 @@ 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/proxy/vmess"
"github.com/v2fly/v2ray-core/v5/proxy/vmess/encoding"
"github.com/v2fly/v2ray-core/v5/transport"
"github.com/v2fly/v2ray-core/v5/transport/internet"
"hash/crc64"
)
// Handler is an outbound connection handler for VMess protocol.
@@ -153,7 +152,7 @@ func (h *Handler) Process(ctx context.Context, link *transport.Link, dialer inte
if err != nil {
return newError("failed to start encoding").Base(err)
}
if err := buf.CopyOnceTimeout(input, bodyWriter, time.Millisecond*100); err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout {
if err := buf.CopyOnceTimeout(input, bodyWriter, proxy.FirstPayloadTimeout); err != nil && err != buf.ErrNotTimeoutReader && err != buf.ErrReadTimeout {
return newError("failed to write first payload").Base(err)
}