fix: Vmess URI Scheme 解析问题
This commit is contained in:
parent
4ce556c2a3
commit
0bd925db78
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
|
||||
}
|
||||
} else {
|
||||
wsOpts.Headers.Set("Host", convert.RandHost())
|
||||
convert.SetUserAgent(wsOpts.Headers)
|
||||
if host := wsOpts.Headers.Get("Host"); host == "" {
|
||||
wsOpts.Headers.Set("Host", convert.RandHost())
|
||||
convert.SetUserAgent(wsOpts.Headers)
|
||||
}
|
||||
}
|
||||
c, err = vmess.StreamWebsocketConn(c, wsOpts)
|
||||
case "http":
|
||||
|
@ -130,9 +132,6 @@ func (v *Vmess) StreamConn(c net.Conn, metadata *C.Metadata) (net.Conn, error) {
|
|||
if err != nil {
|
||||
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)
|
||||
|
|
|
@ -244,9 +244,13 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
|||
vmess["udp"] = true
|
||||
vmess["skip-cert-verify"] = false
|
||||
|
||||
if values["cipher"] != nil && values["cipher"] != "" {
|
||||
vmess["cipher"] = values["cipher"]
|
||||
}
|
||||
|
||||
sni := values["sni"]
|
||||
if sni != "" {
|
||||
vmess["sni"] = sni
|
||||
vmess["servername"] = sni
|
||||
}
|
||||
|
||||
host := values["host"]
|
||||
|
@ -256,7 +260,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
|||
|
||||
tls := strings.ToLower(values["tls"].(string))
|
||||
if tls != "" && tls != "0" && tls != "null" {
|
||||
if host != nil {
|
||||
if host != "" || host != nil {
|
||||
vmess["servername"] = host
|
||||
}
|
||||
vmess["tls"] = true
|
||||
|
@ -267,7 +271,7 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
|||
headers := make(map[string]any)
|
||||
httpOpts := make(map[string]any)
|
||||
|
||||
//headers["Host"] = RandHost()
|
||||
headers["Host"] = RandHost()
|
||||
headers["User-Agent"] = RandUserAgent()
|
||||
httpOpts["method"] = values["method"]
|
||||
httpOpts["path"] = values["path"]
|
||||
|
@ -289,11 +293,12 @@ func ConvertsV2Ray(buf []byte) ([]map[string]any, error) {
|
|||
case "ws":
|
||||
headers := make(map[string]any)
|
||||
wsOpts := make(map[string]any)
|
||||
|
||||
headers["Host"] = RandHost()
|
||||
if host != "" && host != nil {
|
||||
headers["Host"] = host
|
||||
}
|
||||
headers["User-Agent"] = RandUserAgent()
|
||||
|
||||
if values["path"] != nil {
|
||||
if values["path"] != nil || values["path"] != "" {
|
||||
wsOpts["path"] = values["path"]
|
||||
}
|
||||
wsOpts["headers"] = headers
|
||||
|
|
Loading…
Reference in a new issue