mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 17:38:41 +00:00
Dialer: Set TimeoutOnly for gctx
and hctx
https://github.com/XTLS/Xray-core/issues/2232#issuecomment-1694570914 Thank @cty123 for testing Fixes https://github.com/XTLS/Xray-core/issues/2232 BTW: Use `uConn.HandshakeContext(ctx)` in REALITY
This commit is contained in:
parent
b24a4028f1
commit
d92002ad12
3 changed files with 14 additions and 12 deletions
|
@ -98,16 +98,13 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in
|
|||
MinConnectTimeout: 5 * time.Second,
|
||||
}),
|
||||
grpc.WithContextDialer(func(gctx context.Context, s string) (gonet.Conn, error) {
|
||||
gctx = session.ContextWithID(gctx, session.IDFromContext(ctx))
|
||||
gctx = session.ContextWithOutbound(gctx, session.OutboundFromContext(ctx))
|
||||
|
||||
rawHost, rawPort, err := net.SplitHostPort(s)
|
||||
select {
|
||||
case <-gctx.Done():
|
||||
return nil, gctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
rawHost, rawPort, err := net.SplitHostPort(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -119,9 +116,14 @@ func getGrpcClient(ctx context.Context, dest net.Destination, streamSettings *in
|
|||
return nil, err
|
||||
}
|
||||
address := net.ParseAddress(rawHost)
|
||||
|
||||
gctx = session.ContextWithID(gctx, session.IDFromContext(ctx))
|
||||
gctx = session.ContextWithOutbound(gctx, session.OutboundFromContext(ctx))
|
||||
gctx = session.ContextWithTimeoutOnly(gctx, true)
|
||||
|
||||
c, err := internet.DialSystem(gctx, net.TCPDestination(address, port), sockopt)
|
||||
if err == nil && realityConfig != nil {
|
||||
return reality.UClient(c, realityConfig, ctx, dest)
|
||||
return reality.UClient(c, realityConfig, gctx, dest)
|
||||
}
|
||||
return c, err
|
||||
}),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue