mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-05-08 14:13:22 +00:00
Browser Dialer: Potential optimized IP and non-standard port
Fixes https://github.com/2dust/v2rayNG/issues/5519#issuecomment-4335112057
This commit is contained in:
@@ -373,6 +373,12 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
|||||||
if requestURL.Host == "" {
|
if requestURL.Host == "" {
|
||||||
requestURL.Host = dest.Address.String()
|
requestURL.Host = dest.Address.String()
|
||||||
}
|
}
|
||||||
|
if browser_dialer.HasBrowserDialer() && realityConfig == nil {
|
||||||
|
// For Browser Dialer's optimized IP and non-standard port
|
||||||
|
if !(requestURL.Scheme == "http" && dest.Port == 80) && !(requestURL.Scheme == "https" && dest.Port == 443) {
|
||||||
|
requestURL.Host += ":" + dest.Port.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
requestURL.Path = transportConfiguration.GetNormalizedPath()
|
requestURL.Path = transportConfiguration.GetNormalizedPath()
|
||||||
requestURL.RawQuery = transportConfiguration.GetNormalizedQuery()
|
requestURL.RawQuery = transportConfiguration.GetNormalizedQuery()
|
||||||
@@ -434,6 +440,12 @@ func Dial(ctx context.Context, dest net.Destination, streamSettings *internet.Me
|
|||||||
if requestURL2.Host == "" {
|
if requestURL2.Host == "" {
|
||||||
requestURL2.Host = dest2.Address.String()
|
requestURL2.Host = dest2.Address.String()
|
||||||
}
|
}
|
||||||
|
if browser_dialer.HasBrowserDialer() && realityConfig2 == nil {
|
||||||
|
// For Browser Dialer's optimized IP and non-standard port
|
||||||
|
if !(requestURL2.Scheme == "http" && dest2.Port == 80) && !(requestURL2.Scheme == "https" && dest2.Port == 443) {
|
||||||
|
requestURL2.Host += ":" + dest2.Port.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
requestURL2.Path = config2.GetNormalizedPath()
|
requestURL2.Path = config2.GetNormalizedPath()
|
||||||
requestURL2.RawQuery = config2.GetNormalizedQuery()
|
requestURL2.RawQuery = config2.GetNormalizedQuery()
|
||||||
httpClient2, xmuxClient2 = getHTTPClient(ctx, dest2, memory2)
|
httpClient2, xmuxClient2 = getHTTPClient(ctx, dest2, memory2)
|
||||||
|
|||||||
@@ -111,13 +111,20 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
host := dest.NetAddr()
|
if browser_dialer.HasBrowserDialer() {
|
||||||
if (protocol == "ws" && dest.Port == 80) || (protocol == "wss" && dest.Port == 443) {
|
// For Browser Dialer's optimized IP and non-standard port
|
||||||
|
host := wsSettings.Host
|
||||||
|
if host == "" && tConfig.ServerName != "" {
|
||||||
|
host = tConfig.ServerName
|
||||||
|
}
|
||||||
|
if host == "" {
|
||||||
host = dest.Address.String()
|
host = dest.Address.String()
|
||||||
}
|
}
|
||||||
|
if !(protocol == "ws" && dest.Port == 80) && !(protocol == "wss" && dest.Port == 443) {
|
||||||
|
host += ":" + dest.Port.String()
|
||||||
|
}
|
||||||
uri := protocol + "://" + host + wsSettings.GetNormalizedPath()
|
uri := protocol + "://" + host + wsSettings.GetNormalizedPath()
|
||||||
|
|
||||||
if browser_dialer.HasBrowserDialer() {
|
|
||||||
conn, err := browser_dialer.DialWS(uri, ed)
|
conn, err := browser_dialer.DialWS(uri, ed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -126,6 +133,12 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in
|
|||||||
return NewConnection(conn, conn.RemoteAddr(), nil, wsSettings.HeartbeatPeriod), nil
|
return NewConnection(conn, conn.RemoteAddr(), nil, wsSettings.HeartbeatPeriod), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
host := dest.Address.String()
|
||||||
|
if !(protocol == "ws" && dest.Port == 80) && !(protocol == "wss" && dest.Port == 443) {
|
||||||
|
host += ":" + dest.Port.String()
|
||||||
|
}
|
||||||
|
uri := protocol + "://" + host + wsSettings.GetNormalizedPath()
|
||||||
|
|
||||||
header := wsSettings.GetRequestHeader()
|
header := wsSettings.GetRequestHeader()
|
||||||
// See dialer.DialContext()
|
// See dialer.DialContext()
|
||||||
header.Set("Host", wsSettings.Host)
|
header.Set("Host", wsSettings.Host)
|
||||||
|
|||||||
Reference in New Issue
Block a user