mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2024-11-14 05:11:17 +08:00
fix: v2ray http upgrade Hosts
header not working
This commit is contained in:
parent
ef303b11f2
commit
885ee7a820
@ -376,6 +376,10 @@ func streamWebsocketConn(ctx context.Context, conn net.Conn, c *WebsocketConfig,
|
||||
}
|
||||
request.Header.Set("Connection", "Upgrade")
|
||||
request.Header.Set("Upgrade", "websocket")
|
||||
if host := request.Header.Get("Host"); host != "" {
|
||||
request.Header.Del("Host")
|
||||
request.Host = host
|
||||
}
|
||||
err = request.Write(conn)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -415,16 +419,16 @@ func streamWebsocketConn(ctx context.Context, conn net.Conn, c *WebsocketConfig,
|
||||
if secProtocol := headers.Get("Sec-WebSocket-Protocol"); len(secProtocol) > 0 {
|
||||
// gobwas/ws will set "Sec-Websocket-Protocol" according dialer.Protocols
|
||||
// to avoid send repeatedly don't set it to headers
|
||||
headers.Del("Sec-WebSocket-Protocol")
|
||||
dialer.Protocols = []string{secProtocol}
|
||||
}
|
||||
headers.Del("Sec-WebSocket-Protocol")
|
||||
|
||||
// gobwas/ws send "Host" directly in Upgrade() by `httpWriteHeader(bw, headerHost, u.Host)`
|
||||
// if headers has "Host" will send repeatedly
|
||||
if host := headers.Get("Host"); host != "" {
|
||||
headers.Del("Host")
|
||||
uri.Host = host
|
||||
}
|
||||
headers.Del("Host")
|
||||
|
||||
dialer.Header = ws.HandshakeHeaderHTTP(headers)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user