mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-12 03:52:11 +08:00
fix: set RequestTimeout in earlyConn
This commit is contained in:
parent
a58234f0cd
commit
cd53e2d4a7
@ -291,10 +291,7 @@ func (t *Client) DialContext(ctx context.Context, metadata *C.Metadata) (net.Con
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.RequestTimeout > 0 {
|
conn := &earlyConn{BufferedConn: N.NewBufferedConn(stream), RequestTimeout: t.RequestTimeout}
|
||||||
_ = stream.SetReadDeadline(time.Now().Add(time.Duration(t.RequestTimeout) * time.Millisecond))
|
|
||||||
}
|
|
||||||
conn := &earlyConn{BufferedConn: N.NewBufferedConn(stream)}
|
|
||||||
if !t.FastOpen {
|
if !t.FastOpen {
|
||||||
err = conn.Response()
|
err = conn.Response()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -308,9 +305,14 @@ type earlyConn struct {
|
|||||||
*N.BufferedConn
|
*N.BufferedConn
|
||||||
resOnce sync.Once
|
resOnce sync.Once
|
||||||
resErr error
|
resErr error
|
||||||
|
|
||||||
|
RequestTimeout int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conn *earlyConn) response() error {
|
func (conn *earlyConn) response() error {
|
||||||
|
if conn.RequestTimeout > 0 {
|
||||||
|
_ = conn.SetReadDeadline(time.Now().Add(time.Duration(conn.RequestTimeout) * time.Millisecond))
|
||||||
|
}
|
||||||
response, err := ReadResponse(conn)
|
response, err := ReadResponse(conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = conn.Close()
|
_ = conn.Close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user