mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-12 19:39:35 +03: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:
@ -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
|
||||
}),
|
||||
|
Reference in New Issue
Block a user