|
|
|
@ -19,6 +19,7 @@ import (
|
|
|
|
|
"github.com/xtls/xray-core/common/uuid"
|
|
|
|
|
"github.com/xtls/xray-core/transport/internet"
|
|
|
|
|
"github.com/xtls/xray-core/transport/internet/browser_dialer"
|
|
|
|
|
"github.com/xtls/xray-core/transport/internet/reality"
|
|
|
|
|
"github.com/xtls/xray-core/transport/internet/stat"
|
|
|
|
|
"github.com/xtls/xray-core/transport/internet/tls"
|
|
|
|
|
"github.com/xtls/xray-core/transport/pipe"
|
|
|
|
@ -46,7 +47,9 @@ var (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *internet.MemoryStreamConfig) (DialerClient, *muxResource) {
|
|
|
|
|
if browser_dialer.HasBrowserDialer() {
|
|
|
|
|
realityConfig := reality.ConfigFromStreamSettings(streamSettings)
|
|
|
|
|
|
|
|
|
|
if browser_dialer.HasBrowserDialer() && realityConfig != nil {
|
|
|
|
|
return &BrowserDialerClient{}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -80,8 +83,18 @@ func getHTTPClient(ctx context.Context, dest net.Destination, streamSettings *in
|
|
|
|
|
|
|
|
|
|
func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStreamConfig) DialerClient {
|
|
|
|
|
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")
|
|
|
|
|
realityConfig := reality.ConfigFromStreamSettings(streamSettings)
|
|
|
|
|
|
|
|
|
|
isH2 := false
|
|
|
|
|
isH3 := false
|
|
|
|
|
|
|
|
|
|
if tlsConfig != nil {
|
|
|
|
|
isH2 = !(len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "http/1.1")
|
|
|
|
|
isH3 = len(tlsConfig.NextProtocol) == 1 && tlsConfig.NextProtocol[0] == "h3"
|
|
|
|
|
} else if realityConfig != nil {
|
|
|
|
|
isH2 = true
|
|
|
|
|
isH3 = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if isH3 {
|
|
|
|
|
dest.Network = net.Network_UDP
|
|
|
|
@ -101,6 +114,10 @@ func createHTTPClient(dest net.Destination, streamSettings *internet.MemoryStrea
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if realityConfig != nil {
|
|
|
|
|
return reality.UClient(conn, realityConfig, ctxInner, dest)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if gotlsConfig != nil {
|
|
|
|
|
if fingerprint := tls.GetFingerprint(tlsConfig.Fingerprint); fingerprint != nil {
|
|
|
|
|
conn = tls.UClient(conn, gotlsConfig, fingerprint)
|
|
|
|
@ -215,12 +232,13 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
|
|
|
|
|
|
|
|
|
transportConfiguration := streamSettings.ProtocolSettings.(*Config)
|
|
|
|
|
tlsConfig := tls.ConfigFromStreamSettings(streamSettings)
|
|
|
|
|
realityConfig := reality.ConfigFromStreamSettings(streamSettings)
|
|
|
|
|
|
|
|
|
|
scMaxConcurrentPosts := transportConfiguration.GetNormalizedScMaxConcurrentPosts()
|
|
|
|
|
scMaxEachPostBytes := transportConfiguration.GetNormalizedScMaxEachPostBytes()
|
|
|
|
|
scMinPostsIntervalMs := transportConfiguration.GetNormalizedScMinPostsIntervalMs()
|
|
|
|
|
|
|
|
|
|
if tlsConfig != nil {
|
|
|
|
|
if tlsConfig != nil || realityConfig != nil {
|
|
|
|
|
requestURL.Scheme = "https"
|
|
|
|
|
} else {
|
|
|
|
|
requestURL.Scheme = "http"
|
|
|
|
|