mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-03 02:08:45 +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:
@@ -111,13 +111,20 @@ func dialWebSocket(ctx context.Context, dest net.Destination, streamSettings *in
|
||||
}
|
||||
}
|
||||
|
||||
host := dest.NetAddr()
|
||||
if (protocol == "ws" && dest.Port == 80) || (protocol == "wss" && dest.Port == 443) {
|
||||
host = dest.Address.String()
|
||||
}
|
||||
uri := protocol + "://" + host + wsSettings.GetNormalizedPath()
|
||||
|
||||
if browser_dialer.HasBrowserDialer() {
|
||||
// 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()
|
||||
}
|
||||
if !(protocol == "ws" && dest.Port == 80) && !(protocol == "wss" && dest.Port == 443) {
|
||||
host += ":" + dest.Port.String()
|
||||
}
|
||||
uri := protocol + "://" + host + wsSettings.GetNormalizedPath()
|
||||
|
||||
conn, err := browser_dialer.DialWS(uri, ed)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
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()
|
||||
// See dialer.DialContext()
|
||||
header.Set("Host", wsSettings.Host)
|
||||
|
||||
Reference in New Issue
Block a user