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
|
@ -53,7 +53,7 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
|
|||
}
|
||||
|
||||
transport := &http2.Transport{
|
||||
DialTLS: func(network string, addr string, tlsConfig *gotls.Config) (net.Conn, error) {
|
||||
DialTLSContext: func(hctx context.Context, string, addr string, tlsConfig *gotls.Config) (net.Conn, error) {
|
||||
rawHost, rawPort, err := net.SplitHostPort(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -67,18 +67,18 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
|
|||
}
|
||||
address := net.ParseAddress(rawHost)
|
||||
|
||||
dctx := context.Background()
|
||||
dctx = session.ContextWithID(dctx, session.IDFromContext(ctx))
|
||||
dctx = session.ContextWithOutbound(dctx, session.OutboundFromContext(ctx))
|
||||
hctx = session.ContextWithID(hctx, session.IDFromContext(ctx))
|
||||
hctx = session.ContextWithOutbound(hctx, session.OutboundFromContext(ctx))
|
||||
hctx = session.ContextWithTimeoutOnly(hctx, true)
|
||||
|
||||
pconn, err := internet.DialSystem(dctx, net.TCPDestination(address, port), sockopt)
|
||||
pconn, err := internet.DialSystem(hctx, net.TCPDestination(address, port), sockopt)
|
||||
if err != nil {
|
||||
newError("failed to dial to " + addr).Base(err).AtError().WriteToLog()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if realityConfigs != nil {
|
||||
return reality.UClient(pconn, realityConfigs, ctx, dest)
|
||||
return reality.UClient(pconn, realityConfigs, hctx, dest)
|
||||
}
|
||||
|
||||
var cn tls.Interface
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue