mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-01-06 01:23:38 +08:00
feat: Converter support Xray HTTPUpgrade fast open path
This commit is contained in:
parent
72d0948224
commit
3e0bd65135
@ -330,7 +330,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
|||||||
|
|
||||||
vmess["h2-opts"] = h2Opts
|
vmess["h2-opts"] = h2Opts
|
||||||
|
|
||||||
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)
|
||||||
wsOpts["path"] = []string{"/"}
|
wsOpts["path"] = []string{"/"}
|
||||||
@ -338,7 +338,30 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
|||||||
headers["Host"] = host.(string)
|
headers["Host"] = host.(string)
|
||||||
}
|
}
|
||||||
if path, ok := values["path"]; ok && path != "" {
|
if path, ok := values["path"]; ok && path != "" {
|
||||||
wsOpts["path"] = path.(string)
|
path := path.(string)
|
||||||
|
pathURL, err := url.Parse(path)
|
||||||
|
if err == nil {
|
||||||
|
query := pathURL.Query()
|
||||||
|
if earlyData := query.Get("ed"); earlyData != "" {
|
||||||
|
med, err := strconv.Atoi(earlyData)
|
||||||
|
if err == nil {
|
||||||
|
switch network {
|
||||||
|
case "ws":
|
||||||
|
wsOpts["max-early-data"] = med
|
||||||
|
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol"
|
||||||
|
case "httpupgrade":
|
||||||
|
wsOpts["v2ray-http-upgrade-fast-open"] = true
|
||||||
|
}
|
||||||
|
query.Del("ed")
|
||||||
|
pathURL.RawQuery = query.Encode()
|
||||||
|
path = pathURL.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if earlyDataHeader := query.Get("eh"); earlyDataHeader != "" {
|
||||||
|
wsOpts["early-data-header-name"] = earlyDataHeader
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wsOpts["path"] = path
|
||||||
}
|
}
|
||||||
wsOpts["headers"] = headers
|
wsOpts["headers"] = headers
|
||||||
vmess["ws-opts"] = wsOpts
|
vmess["ws-opts"] = wsOpts
|
||||||
|
@ -100,7 +100,7 @@ func handleVShareLink(names map[string]int, url *url.URL, scheme string, proxy m
|
|||||||
h2Opts["headers"] = headers
|
h2Opts["headers"] = headers
|
||||||
proxy["h2-opts"] = h2Opts
|
proxy["h2-opts"] = h2Opts
|
||||||
|
|
||||||
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()
|
||||||
@ -113,7 +113,13 @@ func handleVShareLink(names map[string]int, url *url.URL, scheme string, proxy m
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("bad WebSocket max early data size: %v", err)
|
return fmt.Errorf("bad WebSocket max early data size: %v", err)
|
||||||
}
|
}
|
||||||
|
switch network {
|
||||||
|
case "ws":
|
||||||
wsOpts["max-early-data"] = med
|
wsOpts["max-early-data"] = med
|
||||||
|
wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol"
|
||||||
|
case "httpupgrade":
|
||||||
|
wsOpts["v2ray-http-upgrade-fast-open"] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if earlyDataHeader := query.Get("eh"); earlyDataHeader != "" {
|
if earlyDataHeader := query.Get("eh"); earlyDataHeader != "" {
|
||||||
wsOpts["early-data-header-name"] = earlyDataHeader
|
wsOpts["early-data-header-name"] = earlyDataHeader
|
||||||
|
@ -383,6 +383,7 @@ proxies: # socks5
|
|||||||
# headers:
|
# headers:
|
||||||
# custom: value
|
# custom: value
|
||||||
# v2ray-http-upgrade: false
|
# v2ray-http-upgrade: false
|
||||||
|
# v2ray-http-upgrade-fast-open: false
|
||||||
|
|
||||||
- name: "ss4-shadow-tls"
|
- name: "ss4-shadow-tls"
|
||||||
type: ss
|
type: ss
|
||||||
@ -461,6 +462,7 @@ proxies: # socks5
|
|||||||
# max-early-data: 2048
|
# max-early-data: 2048
|
||||||
# early-data-header-name: Sec-WebSocket-Protocol
|
# early-data-header-name: Sec-WebSocket-Protocol
|
||||||
# v2ray-http-upgrade: false
|
# v2ray-http-upgrade: false
|
||||||
|
# v2ray-http-upgrade-fast-open: false
|
||||||
|
|
||||||
- name: "vmess-h2"
|
- name: "vmess-h2"
|
||||||
type: vmess
|
type: vmess
|
||||||
@ -589,6 +591,7 @@ proxies: # socks5
|
|||||||
headers:
|
headers:
|
||||||
Host: example.com
|
Host: example.com
|
||||||
# v2ray-http-upgrade: false
|
# v2ray-http-upgrade: false
|
||||||
|
# v2ray-http-upgrade-fast-open: false
|
||||||
|
|
||||||
# Trojan
|
# Trojan
|
||||||
- name: "trojan"
|
- name: "trojan"
|
||||||
@ -633,6 +636,7 @@ proxies: # socks5
|
|||||||
# headers:
|
# headers:
|
||||||
# Host: example.com
|
# Host: example.com
|
||||||
# v2ray-http-upgrade: false
|
# v2ray-http-upgrade: false
|
||||||
|
# v2ray-http-upgrade-fast-open: false
|
||||||
|
|
||||||
- name: "trojan-xtls"
|
- name: "trojan-xtls"
|
||||||
type: trojan
|
type: trojan
|
||||||
|
Loading…
x
Reference in New Issue
Block a user