diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 578547dc..9a1b57d8 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -1371,7 +1371,7 @@ class Inbound extends XrayCommonClass { params.set("spx", this.stream.reality.settings.spiderX); } if (this.stream.network === 'tcp') { - params.set("flow", this.settings.vlesses[clientIndex].flow); + params.set("flow", this.settings.trojans[clientIndex].flow); } } diff --git a/web/service/sub.go b/web/service/sub.go index 35ec4990..b3f707ce 100644 --- a/web/service/sub.go +++ b/web/service/sub.go @@ -311,41 +311,36 @@ func (s *SubService) genVlessLink(inbound *model.Inbound, email string) string { } } - if security == "xtls" { - params["security"] = "xtls" - xtlsSetting, _ := stream["xtlsSettings"].(map[string]interface{}) - alpns, _ := xtlsSetting["alpn"].([]interface{}) - var alpn []string - for _, a := range alpns { - alpn = append(alpn, a.(string)) - } - if len(alpn) > 0 { - params["alpn"] = strings.Join(alpn, ",") - } - - xtlsSettings, _ := searchKey(xtlsSetting, "settings") - if xtlsSetting != nil { - if sniValue, ok := searchKey(xtlsSettings, "serverName"); ok { - params["sni"], _ = sniValue.(string) + if security == "reality" { + params["security"] = "reality" + realitySetting, _ := stream["realitySettings"].(map[string]interface{}) + realitySettings, _ := searchKey(realitySetting, "settings") + if realitySetting != nil { + if sniValue, ok := searchKey(realitySetting, "serverNames"); ok { + sNames, _ := sniValue.([]interface{}) + params["sni"], _ = sNames[0].(string) } - if fpValue, ok := searchKey(xtlsSettings, "fingerprint"); ok { + if pbkValue, ok := searchKey(realitySettings, "publicKey"); ok { + params["pbk"], _ = pbkValue.(string) + } + if sidValue, ok := searchKey(realitySettings, "shortIds"); ok { + shortIds, _ := sidValue.([]interface{}) + params["sid"], _ = shortIds[0].(string) + } + if fpValue, ok := searchKey(realitySettings, "fingerprint"); ok { params["fp"], _ = fpValue.(string) } - if insecure, ok := searchKey(xtlsSettings, "allowInsecure"); ok { - if insecure.(bool) { - params["allowInsecure"] = "1" - } + if spxValue, ok := searchKey(realitySettings, "spiderX"); ok { + params["spx"], _ = spxValue.(string) + } + if serverName, ok := searchKey(realitySettings, "serverName"); ok { + address, _ = serverName.(string) } } if streamNetwork == "tcp" && len(clients[clientIndex].Flow) > 0 { params["flow"] = clients[clientIndex].Flow } - - serverName, _ := xtlsSetting["serverName"].(string) - if serverName != "" { - address = serverName - } } link := fmt.Sprintf("vless://%s@%s:%d", uuid, address, port) @@ -455,41 +450,36 @@ func (s *SubService) genTrojanLink(inbound *model.Inbound, email string) string } } - if security == "xtls" { - params["security"] = "xtls" - xtlsSetting, _ := stream["xtlsSettings"].(map[string]interface{}) - alpns, _ := xtlsSetting["alpn"].([]interface{}) - var alpn []string - for _, a := range alpns { - alpn = append(alpn, a.(string)) - } - if len(alpn) > 0 { - params["alpn"] = strings.Join(alpn, ",") - } - - xtlsSettings, _ := searchKey(xtlsSetting, "settings") - if xtlsSetting != nil { - if sniValue, ok := searchKey(xtlsSettings, "serverName"); ok { - params["sni"], _ = sniValue.(string) + if security == "reality" { + params["security"] = "reality" + realitySetting, _ := stream["realitySettings"].(map[string]interface{}) + realitySettings, _ := searchKey(realitySetting, "settings") + if realitySetting != nil { + if sniValue, ok := searchKey(realitySetting, "serverNames"); ok { + sNames, _ := sniValue.([]interface{}) + params["sni"], _ = sNames[0].(string) } - if fpValue, ok := searchKey(xtlsSettings, "fingerprint"); ok { + if pbkValue, ok := searchKey(realitySettings, "publicKey"); ok { + params["pbk"], _ = pbkValue.(string) + } + if sidValue, ok := searchKey(realitySettings, "shortIds"); ok { + shortIds, _ := sidValue.([]interface{}) + params["sid"], _ = shortIds[0].(string) + } + if fpValue, ok := searchKey(realitySettings, "fingerprint"); ok { params["fp"], _ = fpValue.(string) } - if insecure, ok := searchKey(xtlsSettings, "allowInsecure"); ok { - if insecure.(bool) { - params["allowInsecure"] = "1" - } + if spxValue, ok := searchKey(realitySettings, "spiderX"); ok { + params["spx"], _ = spxValue.(string) + } + if serverName, ok := searchKey(realitySettings, "serverName"); ok { + address, _ = serverName.(string) } } if streamNetwork == "tcp" && len(clients[clientIndex].Flow) > 0 { params["flow"] = clients[clientIndex].Flow } - - serverName, _ := xtlsSetting["serverName"].(string) - if serverName != "" { - address = serverName - } } link := fmt.Sprintf("trojan://%s@%s:%d", password, address, port)