diff --git a/adapter/outbound/vmess.go b/adapter/outbound/vmess.go index 0d65b31e..1ad5036f 100644 --- a/adapter/outbound/vmess.go +++ b/adapter/outbound/vmess.go @@ -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) diff --git a/common/convert/converter.go b/common/convert/converter.go index 7a96743e..23fdf652 100644 --- a/common/convert/converter.go +++ b/common/convert/converter.go @@ -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