mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-25 10:01:28 +00:00
Fix SplitHTTP H3 didn't always reuse QUIC connection
https://github.com/XTLS/Xray-core/issues/3560#issuecomment-2241531502
This commit is contained in:
parent
529f206d33
commit
22535d8643
|
@ -41,6 +41,10 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
|
||||||
return &BrowserDialerClient{}
|
return &BrowserDialerClient{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tlsConfig := tls.ConfigFromStreamSettings(streamSettings)
|
||||||
|
isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1")
|
||||||
|
isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3")
|
||||||
|
|
||||||
globalDialerAccess.Lock()
|
globalDialerAccess.Lock()
|
||||||
defer globalDialerAccess.Unlock()
|
defer globalDialerAccess.Unlock()
|
||||||
|
|
||||||
|
@ -48,14 +52,13 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
|
||||||
globalDialerMap = make(map[dialerConf]DialerClient)
|
globalDialerMap = make(map[dialerConf]DialerClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isH3 {
|
||||||
|
dest.Network = net.Network_UDP
|
||||||
|
}
|
||||||
if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found {
|
if client, found := globalDialerMap[dialerConf{dest, streamSettings}]; found {
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsConfig := tls.ConfigFromStreamSettings(streamSettings)
|
|
||||||
isH2 := tlsConfig != nil && !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1")
|
|
||||||
isH3 := tlsConfig != nil && (len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3")
|
|
||||||
|
|
||||||
var gotlsConfig *gotls.Config
|
var gotlsConfig *gotls.Config
|
||||||
|
|
||||||
if tlsConfig != nil {
|
if tlsConfig != nil {
|
||||||
|
@ -86,7 +89,6 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
|
||||||
var uploadTransport http.RoundTripper
|
var uploadTransport http.RoundTripper
|
||||||
|
|
||||||
if isH3 {
|
if isH3 {
|
||||||
dest.Network = net.Network_UDP
|
|
||||||
roundTripper := &http3.RoundTripper{
|
roundTripper := &http3.RoundTripper{
|
||||||
TLSClientConfig: gotlsConfig,
|
TLSClientConfig: gotlsConfig,
|
||||||
Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
|
Dial: func(ctx context.Context, addr string, tlsCfg *gotls.Config, cfg *quic.Config) (quic.EarlyConnection, error) {
|
||||||
|
|
Loading…
Reference in a new issue