mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-19 16:30:07 +08:00
fix: websocket host and httpupgrade support for trojan and more
This commit is contained in:
parent
a9ce5da09d
commit
02c9086d9d
@ -178,15 +178,23 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch network {
|
switch network {
|
||||||
case "ws":
|
case "ws", "httpupgrade":
|
||||||
headers := make(map[string]any)
|
headers := make(map[string]any)
|
||||||
wsOpts := make(map[string]any)
|
wsOpts := make(map[string]any)
|
||||||
|
|
||||||
headers["User-Agent"] = RandUserAgent()
|
headers["User-Agent"] = RandUserAgent()
|
||||||
|
if host := query.Get("host"); host != "" {
|
||||||
|
headers["Host"] = host
|
||||||
|
}
|
||||||
|
|
||||||
wsOpts["path"] = query.Get("path")
|
wsOpts["path"] = query.Get("path")
|
||||||
wsOpts["headers"] = headers
|
wsOpts["headers"] = headers
|
||||||
|
|
||||||
|
if network == "httpupgrade" {
|
||||||
|
wsOpts["v2ray-http-upgrade"] = true
|
||||||
|
wsOpts["v2ray-http-upgrade-fast-open"] = true
|
||||||
|
}
|
||||||
|
|
||||||
trojan["ws-opts"] = wsOpts
|
trojan["ws-opts"] = wsOpts
|
||||||
|
|
||||||
case "grpc":
|
case "grpc":
|
||||||
@ -350,6 +358,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
|||||||
wsOpts["max-early-data"] = med
|
wsOpts["max-early-data"] = med
|
||||||
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol"
|
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol"
|
||||||
case "httpupgrade":
|
case "httpupgrade":
|
||||||
|
wsOpts["v2ray-http-upgrade"] = true
|
||||||
wsOpts["v2ray-http-upgrade-fast-open"] = true
|
wsOpts["v2ray-http-upgrade-fast-open"] = true
|
||||||
}
|
}
|
||||||
query.Del("ed")
|
query.Del("ed")
|
||||||
@ -443,10 +452,12 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
|||||||
} else if strings.Contains(pluginName, "v2ray-plugin") {
|
} else if strings.Contains(pluginName, "v2ray-plugin") {
|
||||||
ss["plugin"] = "v2ray-plugin"
|
ss["plugin"] = "v2ray-plugin"
|
||||||
ss["plugin-opts"] = map[string]any{
|
ss["plugin-opts"] = map[string]any{
|
||||||
"mode": pluginInfo.Get("mode"),
|
"mode": pluginInfo.Get("mode"),
|
||||||
"host": pluginInfo.Get("host"),
|
"host": pluginInfo.Get("host"),
|
||||||
"path": pluginInfo.Get("path"),
|
"path": pluginInfo.Get("path"),
|
||||||
"tls": strings.Contains(plugin, "tls"),
|
"tls": strings.Contains(plugin, "tls"),
|
||||||
|
"mux": pluginInfo.Get("mux") != "0",
|
||||||
|
"v2ray-http-upgrade": strings.Contains(plugin, "httpupgrade"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,6 +118,7 @@ func handleVShareLink(names map[string]int, url *url.URL, scheme string, proxy m
|
|||||||
wsOpts["max-early-data"] = med
|
wsOpts["max-early-data"] = med
|
||||||
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol"
|
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol"
|
||||||
case "httpupgrade":
|
case "httpupgrade":
|
||||||
|
wsOpts["v2ray-http-upgrade"] = true
|
||||||
wsOpts["v2ray-http-upgrade-fast-open"] = true
|
wsOpts["v2ray-http-upgrade-fast-open"] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user