fix: Vmess URI Scheme 解析问题
This commit is contained in:
parent
9a55213ddc
commit
94368f43eb
2 changed files with 15 additions and 11 deletions
|
@ -109,8 +109,10 @@ func (v *Vmess) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) {
|
||||||
wsOpts.TLSConfig.ServerName = host
|
wsOpts.TLSConfig.ServerName = host
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wsOpts.Headers.Set("Host", convert.RandHost())
|
if host := wsOpts.Headers.Get("Host"); host == "" {
|
||||||
convert.SetUserAgent(wsOpts.Headers)
|
wsOpts.Headers.Set("Host", convert.RandHost())
|
||||||
|
convert.SetUserAgent(wsOpts.Headers)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c, err = vmess.StreamWebsocketConn(c, wsOpts)
|
c, err = vmess.StreamWebsocketConn(c, wsOpts)
|
||||||
case "http":
|
case "http":
|
||||||
|
@ -130,9 +132,6 @@ func (v *Vmess) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
http.Header(v.option.HTTPOpts.Headers).Set("Host", convert.RandHost())
|
|
||||||
convert.SetUserAgent(v.option.HTTPOpts.Headers)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
host, _, _ := net.SplitHostPort(v.addr)
|
host, _, _ := net.SplitHostPort(v.addr)
|
||||||
|
|
|
@ -244,9 +244,13 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
||||||
vmess["udp"] = true
|
vmess["udp"] = true
|
||||||
vmess["skip-cert-verify"] = false
|
vmess["skip-cert-verify"] = false
|
||||||
|
|
||||||
|
if values["cipher"] != nil && values["cipher"] != "" {
|
||||||
|
vmess["cipher"] = values["cipher"]
|
||||||
|
}
|
||||||
|
|
||||||
sni := values["sni"]
|
sni := values["sni"]
|
||||||
if sni != "" {
|
if sni != "" {
|
||||||
vmess["sni"] = sni
|
vmess["servername"] = sni
|
||||||
}
|
}
|
||||||
|
|
||||||
host := values["host"]
|
host := values["host"]
|
||||||
|
@ -256,7 +260,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
||||||
|
|
||||||
tls := strings.ToLower(values["tls"].(string))
|
tls := strings.ToLower(values["tls"].(string))
|
||||||
if tls != "" && tls != "0" && tls != "null" {
|
if tls != "" && tls != "0" && tls != "null" {
|
||||||
if host != nil {
|
if host != "" || host != nil {
|
||||||
vmess["servername"] = host
|
vmess["servername"] = host
|
||||||
}
|
}
|
||||||
vmess["tls"] = true
|
vmess["tls"] = true
|
||||||
|
@ -267,7 +271,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
||||||
headers := make(map[string]any)
|
headers := make(map[string]any)
|
||||||
httpOpts := make(map[string]any)
|
httpOpts := make(map[string]any)
|
||||||
|
|
||||||
//headers["Host"] = RandHost()
|
headers["Host"] = RandHost()
|
||||||
headers["User-Agent"] = RandUserAgent()
|
headers["User-Agent"] = RandUserAgent()
|
||||||
httpOpts["method"] = values["method"]
|
httpOpts["method"] = values["method"]
|
||||||
httpOpts["path"] = values["path"]
|
httpOpts["path"] = values["path"]
|
||||||
|
@ -289,11 +293,12 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
||||||
case "ws":
|
case "ws":
|
||||||
headers := make(map[string]any)
|
headers := make(map[string]any)
|
||||||
wsOpts := make(map[string]any)
|
wsOpts := make(map[string]any)
|
||||||
|
if host != "" && host != nil {
|
||||||
headers["Host"] = RandHost()
|
headers["Host"] = host
|
||||||
|
}
|
||||||
headers["User-Agent"] = RandUserAgent()
|
headers["User-Agent"] = RandUserAgent()
|
||||||
|
|
||||||
if values["path"] != nil {
|
if values["path"] != nil || values["path"] != "" {
|
||||||
wsOpts["path"] = values["path"]
|
wsOpts["path"] = values["path"]
|
||||||
}
|
}
|
||||||
wsOpts["headers"] = headers
|
wsOpts["headers"] = headers
|
||||||
|
|
Loading…
Reference in a new issue