Tuple <JObject, JToken> VeeToConfig(Models.VeeShareLinks.Vmess0a vee) { if (vee == null) { return(null); } var outVmess = cache.tpl.LoadTemplate("outbVeeVmess"); outVmess["streamSettings"] = Comm.GenStreamSetting(cache, vee); var node = outVmess["settings"]["vnext"][0]; node["address"] = vee.address; node["port"] = vee.port; node["users"][0]["id"] = vee.uuid; if (vee.alterId > 0) { node["users"][0]["alterId"] = vee.alterId; } var tpl = cache.tpl.LoadTemplate("tplImportVmess") as JObject; tpl["v2raygcon"]["alias"] = vee.alias; tpl["v2raygcon"]["description"] = vee.description; return(new Tuple <JObject, JToken>(tpl, outVmess)); }
Models.VeeShareLinks.Vmess0a Config2Vee(JObject config) { var bs = Comm.ExtractBasicConfig(config, @"vmess", @"vnext", out bool isUseV4, out string root); if (bs == null) { return(null); } var GetStr = Misc.Utils.GetStringByPrefixAndKeyHelper(config); var vmess = new Models.VeeShareLinks.Vmess0a(bs); var userInfoPrefix = root + ".settings.vnext.0.users.0"; vmess.alterId = VgcApis.Misc.Utils.Str2Int(GetStr(userInfoPrefix, "alterId")); vmess.uuid = Guid.Parse(GetStr(userInfoPrefix, "id")); return(vmess); }
public void Ver001NormalTest() { for (int i = 0; i < 10; i++) { var v1 = new Models.VeeShareLinks.Vmess0a { address = "::1", alias = "中文abc 123", description = "描述abc123", isUseTls = true, streamParam1 = "/v2ray?#abc", streamParam2 = Misc.Utils.RandomHex(7), streamParam3 = Misc.Utils.RandomHex(7), streamType = Misc.Utils.RandomHex(7), port = 123, uuid = Guid.NewGuid(), }; var bytes = v1.ToBytes(); var v2 = new Models.VeeShareLinks.Vmess0a(bytes); Assert.AreEqual(true, v1.EqTo(v2)); } }
public Tuple <JObject, JToken> Bytes2Config(byte[] bytes) { var veeLink = new Models.VeeShareLinks.Vmess0a(bytes); return(VeeToConfig(veeLink)); }