mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-21 09:36:34 -05:00
fix timeout reader usage
This commit is contained in:
parent
8ce6e741f1
commit
14824c8451
@ -1,13 +1,15 @@
|
||||
package buf
|
||||
|
||||
type MergingReader struct {
|
||||
reader Reader
|
||||
leftover *Buffer
|
||||
reader Reader
|
||||
timeoutReader TimeoutReader
|
||||
leftover *Buffer
|
||||
}
|
||||
|
||||
func NewMergingReader(reader Reader) Reader {
|
||||
return &MergingReader{
|
||||
reader: reader,
|
||||
reader: reader,
|
||||
timeoutReader: reader.(TimeoutReader),
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,7 +27,11 @@ func (r *MergingReader) Read() (*Buffer, error) {
|
||||
return b, nil
|
||||
}
|
||||
|
||||
b2, err := r.reader.Read()
|
||||
if r.timeoutReader == nil {
|
||||
return b, nil
|
||||
}
|
||||
|
||||
b2, err := r.timeoutReader.ReadTimeout(0)
|
||||
if err != nil {
|
||||
return b, nil
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay, dial
|
||||
|
||||
bodyWriter := session.EncodeRequestBody(request, writer)
|
||||
firstPayload, err := input.ReadTimeout(time.Millisecond * 500)
|
||||
if err != nil && err != ray.ErrReadTimeout {
|
||||
if err != nil && err != buf.ErrReadTimeout {
|
||||
return errors.Base(err).Message("VMess|Outbound: Failed to get first payload.")
|
||||
}
|
||||
if !firstPayload.IsEmpty() {
|
||||
|
@ -89,7 +89,7 @@ func (v *Stream) ReadTimeout(timeout time.Duration) (*buf.Buffer, error) {
|
||||
return b, nil
|
||||
default:
|
||||
if timeout == 0 {
|
||||
return nil, ErrReadTimeout
|
||||
return nil, buf.ErrReadTimeout
|
||||
}
|
||||
|
||||
select {
|
||||
|
Loading…
Reference in New Issue
Block a user