mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 05:06:07 +03:00
XHTTP client: Enable XMUX for download in U-D-S (#3965)
This commit is contained in:
parent
85a1c33709
commit
e3276df725
@ -7,6 +7,7 @@ type MemoryStreamConfig struct {
|
|||||||
SecurityType string
|
SecurityType string
|
||||||
SecuritySettings interface{}
|
SecuritySettings interface{}
|
||||||
SocketSettings *SocketConfig
|
SocketSettings *SocketConfig
|
||||||
|
DownloadSettings *MemoryStreamConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToMemoryStreamConfig converts a StreamConfig to MemoryStreamConfig. It returns a default non-nil MemoryStreamConfig for nil input.
|
// ToMemoryStreamConfig converts a StreamConfig to MemoryStreamConfig. It returns a default non-nil MemoryStreamConfig for nil input.
|
||||||
|
@ -252,18 +252,24 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
|||||||
requestURL.Path = transportConfiguration.GetNormalizedPath() + sessionIdUuid.String()
|
requestURL.Path = transportConfiguration.GetNormalizedPath() + sessionIdUuid.String()
|
||||||
requestURL.RawQuery = transportConfiguration.GetNormalizedQuery()
|
requestURL.RawQuery = transportConfiguration.GetNormalizedQuery()
|
||||||
|
|
||||||
httpClient, muxResource := getHTTPClient(ctx, dest, streamSettings)
|
httpClient, muxRes := getHTTPClient(ctx, dest, streamSettings)
|
||||||
|
|
||||||
var httpClient2 DialerClient
|
var httpClient2 DialerClient
|
||||||
|
var muxRes2 *muxResource
|
||||||
var requestURL2 url.URL
|
var requestURL2 url.URL
|
||||||
if transportConfiguration.DownloadSettings != nil {
|
if transportConfiguration.DownloadSettings != nil {
|
||||||
|
globalDialerAccess.Lock()
|
||||||
|
if streamSettings.DownloadSettings == nil {
|
||||||
|
streamSettings.DownloadSettings = common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig)
|
||||||
|
}
|
||||||
|
globalDialerAccess.Unlock()
|
||||||
|
memory2 := streamSettings.DownloadSettings
|
||||||
dest2 := net.Destination{
|
dest2 := net.Destination{
|
||||||
Address: transportConfiguration.DownloadSettings.Address.AsAddress(), // just panic
|
Address: transportConfiguration.DownloadSettings.Address.AsAddress(), // just panic
|
||||||
Port: net.Port(transportConfiguration.DownloadSettings.Port),
|
Port: net.Port(transportConfiguration.DownloadSettings.Port),
|
||||||
Network: net.Network_TCP,
|
Network: net.Network_TCP,
|
||||||
}
|
}
|
||||||
memory2 := common.Must2(internet.ToMemoryStreamConfig(transportConfiguration.DownloadSettings)).(*internet.MemoryStreamConfig)
|
httpClient2, muxRes2 = getHTTPClient(ctx, dest2, memory2)
|
||||||
httpClient2, _ = getHTTPClient(ctx, dest2, memory2) // no multiplex
|
|
||||||
if tls.ConfigFromStreamSettings(memory2) != nil || reality.ConfigFromStreamSettings(memory2) != nil {
|
if tls.ConfigFromStreamSettings(memory2) != nil || reality.ConfigFromStreamSettings(memory2) != nil {
|
||||||
requestURL2.Scheme = "https"
|
requestURL2.Scheme = "https"
|
||||||
} else {
|
} else {
|
||||||
@ -284,13 +290,19 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
|||||||
// uploadWriter wrapper, exact size limits can be enforced
|
// uploadWriter wrapper, exact size limits can be enforced
|
||||||
uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1))
|
uploadPipeReader, uploadPipeWriter := pipe.New(pipe.WithSizeLimit(maxUploadSize - 1))
|
||||||
|
|
||||||
if muxResource != nil {
|
if muxRes != nil {
|
||||||
muxResource.OpenRequests.Add(1)
|
muxRes.OpenRequests.Add(1)
|
||||||
|
}
|
||||||
|
if muxRes2 != nil {
|
||||||
|
muxRes2.OpenRequests.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if muxResource != nil {
|
if muxRes != nil {
|
||||||
defer muxResource.OpenRequests.Add(-1)
|
defer muxRes.OpenRequests.Add(-1)
|
||||||
|
}
|
||||||
|
if muxRes2 != nil {
|
||||||
|
defer muxRes2.OpenRequests.Add(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll()))
|
requestsLimiter := semaphore.New(int(scMaxConcurrentPosts.roll()))
|
||||||
|
Loading…
Reference in New Issue
Block a user