mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-01 01:44:15 +00: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:
parent
9cb6816383
commit
a2b773135a
7 changed files with 61 additions and 45 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue