fix: Vmess URI Scheme 解析问题
This commit is contained in:
parent
4ce556c2a3
commit
0bd925db78
2 changed files with 15 additions and 11 deletions
|
@ -109,9 +109,11 @@ func (v *Vmess) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) {
|
||||||
wsOpts.TLSConfig.ServerName = host
|
wsOpts.TLSConfig.ServerName = host
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if host := wsOpts.Headers.Get("Host"); host == "" {
|
||||||
wsOpts.Headers.Set("Host", convert.RandHost())
|
wsOpts.Headers.Set("Host", convert.RandHost())
|
||||||
convert.SetUserAgent(wsOpts.Headers)
|
convert.SetUserAgent(wsOpts.Headers)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
c, err = vmess.StreamWebsocketConn(c, wsOpts)
|
c, err = vmess.StreamWebsocketConn(c, wsOpts)
|
||||||
case "http":
|
case "http":
|
||||||
// readability first, so just copy default TLS logic
|
// readability first, so just copy default TLS logic
|
||||||
|
@ -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