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