Skip to content

Commit 00a5561

Browse files
committed
Fix hysteria2 handshake timeout
1 parent e3c2b20 commit 00a5561

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

hysteria2/client.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030
aTLS "github.com/sagernet/sing/common/tls"
3131
)
3232

33+
const handshakeTimeout = 15 * time.Second
34+
3335
type ClientOptions struct {
3436
Context context.Context
3537
Dialer N.Dialer
@@ -161,6 +163,8 @@ func (c *Client) offerNew(ctx context.Context) (*clientQUICConnection, error) {
161163
Header: make(http.Header),
162164
}
163165
protocol.AuthRequestToHeader(request.Header, protocol.AuthRequest{Auth: c.password, Rx: c.receiveBPS})
166+
ctx, cancel := context.WithTimeout(ctx, handshakeTimeout)
167+
defer cancel()
164168
response, err := http3Transport.RoundTrip(request.WithContext(ctx))
165169
if err != nil {
166170
if quicConn != nil {

0 commit comments

Comments
 (0)