mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-06-14 20:39:36 +03:00
XHTTP, WS, HU: Forbid "host" in headers
, read serverName
instead (#4142)
WebSocket's config files should be updated ASAP.
This commit is contained in:
@ -53,9 +53,10 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings *
|
||||
|
||||
var conn net.Conn
|
||||
var requestURL url.URL
|
||||
if config := tls.ConfigFromStreamSettings(streamSettings); config != nil {
|
||||
tlsConfig := config.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("http/1.1"))
|
||||
if fingerprint := tls.GetFingerprint(config.Fingerprint); fingerprint != nil {
|
||||
tConfig := tls.ConfigFromStreamSettings(streamSettings)
|
||||
if tConfig != nil {
|
||||
tlsConfig := tConfig.GetTLSConfig(tls.WithDestination(dest), tls.WithNextProto("http/1.1"))
|
||||
if fingerprint := tls.GetFingerprint(tConfig.Fingerprint); fingerprint != nil {
|
||||
conn = tls.UClient(pconn, tlsConfig, fingerprint)
|
||||
if err := conn.(*tls.UConn).WebsocketHandshakeContext(ctx); err != nil {
|
||||
return nil, err
|
||||
@ -69,12 +70,17 @@ func dialhttpUpgrade(ctx context.Context, dest net.Destination, streamSettings *
|
||||
requestURL.Scheme = "http"
|
||||
}
|
||||
|
||||
requestURL.Host = dest.NetAddr()
|
||||
requestURL.Host = transportConfiguration.Host
|
||||
if requestURL.Host == "" && tConfig != nil {
|
||||
requestURL.Host = tConfig.ServerName
|
||||
}
|
||||
if requestURL.Host == "" {
|
||||
requestURL.Host = dest.Address.String()
|
||||
}
|
||||
requestURL.Path = transportConfiguration.GetNormalizedPath()
|
||||
req := &http.Request{
|
||||
Method: http.MethodGet,
|
||||
URL: &requestURL,
|
||||
Host: transportConfiguration.Host,
|
||||
Header: make(http.Header),
|
||||
}
|
||||
for key, value := range transportConfiguration.Header {
|
||||
|
Reference in New Issue
Block a user