diff --git a/ray2sing/xrayvmess.go b/ray2sing/xrayvmess.go index 3c67c47..2cb5a53 100644 --- a/ray2sing/xrayvmess.go +++ b/ray2sing/xrayvmess.go @@ -4,14 +4,21 @@ import ( T "github.com/sagernet/sing-box/option" ) -func VmessXray(vlessURL string) (*T.Outbound, error) { - u, err := ParseUrl(vlessURL, 443) +func VmessXray(vmessURL string) (*T.Outbound, error) { + decoded, err := decodeVmess(vmessURL) if err != nil { return nil, err } - decoded := u.Params + + port := toInt16(decoded["port"], 443) + + if err != nil { + return nil, err + } + // fmt.Printf("Port %v deco=%v", port, decoded) streamSettings, err := getStreamSettingsXray(decoded) + if err != nil { return nil, err } @@ -20,31 +27,34 @@ func VmessXray(vlessURL string) (*T.Outbound, error) { // if packetEncoding==""{ // packetEncoding="xudp" // } + security := "auto" + if decoded["scy"] != "" { + security = decoded["scy"] + } return &T.Outbound{ - Tag: u.Name, + Tag: decoded["ps"], Type: "xray", XrayOptions: T.XrayOutboundOptions{ // DialerOptions: getDialerOptions(decoded), - Fragment:getXrayFragmentOptions(decoded), + Fragment: getXrayFragmentOptions(decoded), XrayOutboundJson: &map[string]any{ - "protocol": "vmess", "settings": map[string]any{ "vnext": []any{ map[string]any{ - "address": u.Hostname, - "port": u.Port, + "address": decoded["add"], + "port": port, "users": []any{ map[string]any{ - "id": u.Username, // Change to your UUID. - "security": decoded["encryption"], + "id": decoded["id"], // Change to your UUID. + "security": security, }, }, }, }, }, - "tag": u.Name, + "tag": decoded["ps"], "streamSettings": streamSettings, "mux": getMuxOptionsXray(decoded), },