Skip to content

Commit

Permalink
fix: vmess xray config
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Aug 7, 2024
1 parent 6086673 commit a9df256
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions ray2sing/xrayvmess.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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),
},
Expand Down

0 comments on commit a9df256

Please sign in to comment.