diff --git a/v2rayN/ServiceLib/Enums/EServerColName.cs b/v2rayN/ServiceLib/Enums/EServerColName.cs index 448f4cdc..ef981b74 100644 --- a/v2rayN/ServiceLib/Enums/EServerColName.cs +++ b/v2rayN/ServiceLib/Enums/EServerColName.cs @@ -2,20 +2,20 @@ { public enum EServerColName { - def = 0, - configType, - remarks, - address, - port, - network, - streamSecurity, - subRemarks, - delayVal, - speedVal, + Def = 0, + ConfigType, + Remarks, + Address, + Port, + Network, + StreamSecurity, + SubRemarks, + DelayVal, + SpeedVal, - todayDown, - todayUp, - totalDown, - totalUp + TodayDown, + TodayUp, + TotalDown, + TotalUp } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Handler/AppHandler.cs b/v2rayN/ServiceLib/Handler/AppHandler.cs index 167fe4eb..e0eae64a 100644 --- a/v2rayN/ServiceLib/Handler/AppHandler.cs +++ b/v2rayN/ServiceLib/Handler/AppHandler.cs @@ -104,12 +104,12 @@ public async Task> SubItems() { - return await SQLiteHelper.Instance.TableAsync().OrderBy(t => t.sort).ToListAsync(); + return await SQLiteHelper.Instance.TableAsync().OrderBy(t => t.Sort).ToListAsync(); } public async Task GetSubItem(string subid) { - return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(t => t.id == subid); + return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(t => t.Id == subid); } public async Task> ProfileItems(string subid) @@ -120,7 +120,7 @@ } else { - return await SQLiteHelper.Instance.TableAsync().Where(t => t.subid == subid).ToListAsync(); + return await SQLiteHelper.Instance.TableAsync().Where(t => t.Subid == subid).ToListAsync(); } } @@ -129,13 +129,13 @@ if (Utils.IsNullOrEmpty(subid)) { return (await SQLiteHelper.Instance.TableAsync().ToListAsync()) - .Select(t => t.indexId) + .Select(t => t.IndexId) .ToList(); } else { - return (await SQLiteHelper.Instance.TableAsync().Where(t => t.subid == subid).ToListAsync()) - .Select(t => t.indexId) + return (await SQLiteHelper.Instance.TableAsync().Where(t => t.Subid == subid).ToListAsync()) + .Select(t => t.IndexId) .ToList(); } } @@ -172,32 +172,32 @@ var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? []; var lstProfileExs = ProfileExHandler.Instance.ProfileExs; lstModel = (from t in lstModel - join t2 in lstServerStat on t.indexId equals t2.indexId into t2b + join t2 in lstServerStat on t.IndexId equals t2.IndexId into t2b from t22 in t2b.DefaultIfEmpty() - join t3 in lstProfileExs on t.indexId equals t3.indexId into t3b + join t3 in lstProfileExs on t.IndexId equals t3.IndexId into t3b from t33 in t3b.DefaultIfEmpty() select new ProfileItemModel { - indexId = t.indexId, - configType = t.configType, - remarks = t.remarks, - address = t.address, - port = t.port, - security = t.security, - network = t.network, - streamSecurity = t.streamSecurity, - subid = t.subid, - subRemarks = t.subRemarks, - isActive = t.indexId == _config.IndexId, - sort = t33 == null ? 0 : t33.sort, - delay = t33 == null ? 0 : t33.delay, - delayVal = t33?.delay != 0 ? $"{t33?.delay} {Global.DelayUnit}" : string.Empty, - speedVal = t33?.speed != 0 ? $"{t33?.speed} {Global.SpeedUnit}" : string.Empty, - todayDown = t22 == null ? "" : Utils.HumanFy(t22.todayDown), - todayUp = t22 == null ? "" : Utils.HumanFy(t22.todayUp), - totalDown = t22 == null ? "" : Utils.HumanFy(t22.totalDown), - totalUp = t22 == null ? "" : Utils.HumanFy(t22.totalUp) - }).OrderBy(t => t.sort).ToList(); + IndexId = t.IndexId, + ConfigType = t.ConfigType, + Remarks = t.Remarks, + Address = t.Address, + Port = t.Port, + Security = t.Security, + Network = t.Network, + StreamSecurity = t.StreamSecurity, + Subid = t.Subid, + SubRemarks = t.SubRemarks, + IsActive = t.IndexId == _config.IndexId, + Sort = t33 == null ? 0 : t33.Sort, + Delay = t33 == null ? 0 : t33.Delay, + DelayVal = t33?.Delay != 0 ? $"{t33?.Delay} {Global.DelayUnit}" : string.Empty, + SpeedVal = t33?.Speed != 0 ? $"{t33?.Speed} {Global.SpeedUnit}" : string.Empty, + TodayDown = t22 == null ? "" : Utils.HumanFy(t22.TodayDown), + TodayUp = t22 == null ? "" : Utils.HumanFy(t22.TodayUp), + TotalDown = t22 == null ? "" : Utils.HumanFy(t22.TotalDown), + TotalUp = t22 == null ? "" : Utils.HumanFy(t22.TotalUp) + }).OrderBy(t => t.Sort).ToList(); return lstModel; } @@ -208,7 +208,7 @@ { return null; } - return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.indexId == indexId); + return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.IndexId == indexId); } public async Task GetProfileItemViaRemarks(string? remarks) @@ -217,17 +217,17 @@ { return null; } - return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.remarks == remarks); + return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.Remarks == remarks); } public async Task> RoutingItems() { - return await SQLiteHelper.Instance.TableAsync().Where(it => it.locked == false).OrderBy(t => t.sort).ToListAsync(); + return await SQLiteHelper.Instance.TableAsync().Where(it => it.Locked == false).OrderBy(t => t.Sort).ToListAsync(); } public async Task GetRoutingItem(string id) { - return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.locked == false && it.id == id); + return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.Locked == false && it.Id == id); } public async Task> DNSItems() @@ -237,7 +237,7 @@ public async Task GetDNSItem(ECoreType eCoreType) { - return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.coreType == eCoreType); + return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.CoreType == eCoreType); } #endregion SqliteHelper @@ -263,9 +263,9 @@ public ECoreType GetCoreType(ProfileItem profileItem, EConfigType eConfigType) { - if (profileItem?.coreType != null) + if (profileItem?.CoreType != null) { - return (ECoreType)profileItem.coreType; + return (ECoreType)profileItem.CoreType; } if (_config.CoreTypeItem == null) diff --git a/v2rayN/ServiceLib/Handler/ConfigHandler.cs b/v2rayN/ServiceLib/Handler/ConfigHandler.cs index ab58463c..52283f63 100644 --- a/v2rayN/ServiceLib/Handler/ConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/ConfigHandler.cs @@ -107,10 +107,8 @@ namespace ServiceLib.Handler { EnableAutoAdjustMainLvColWidth = true }; - if (config.UiItem.MainColumnItem == null) - { - config.UiItem.MainColumnItem = new(); - } + config.UiItem.MainColumnItem ??= new(); + if (Utils.IsNullOrEmpty(config.UiItem.CurrentLanguage)) { if (Thread.CurrentThread.CurrentCulture.Name.Equals("zh-cn", StringComparison.CurrentCultureIgnoreCase)) @@ -218,40 +216,40 @@ namespace ServiceLib.Handler public static async Task AddServer(Config config, ProfileItem profileItem) { - var item = await AppHandler.Instance.GetProfileItem(profileItem.indexId); + var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId); if (item is null) { item = profileItem; } else { - item.coreType = profileItem.coreType; - item.remarks = profileItem.remarks; - item.address = profileItem.address; - item.port = profileItem.port; + item.CoreType = profileItem.CoreType; + item.Remarks = profileItem.Remarks; + item.Address = profileItem.Address; + item.Port = profileItem.Port; - item.id = profileItem.id; - item.alterId = profileItem.alterId; - item.security = profileItem.security; - item.flow = profileItem.flow; + item.Id = profileItem.Id; + item.AlterId = profileItem.AlterId; + item.Security = profileItem.Security; + item.Flow = profileItem.Flow; - item.network = profileItem.network; - item.headerType = profileItem.headerType; - item.requestHost = profileItem.requestHost; - item.path = profileItem.path; + item.Network = profileItem.Network; + item.HeaderType = profileItem.HeaderType; + item.RequestHost = profileItem.RequestHost; + item.Path = profileItem.Path; - item.streamSecurity = profileItem.streamSecurity; - item.sni = profileItem.sni; - item.allowInsecure = profileItem.allowInsecure; - item.fingerprint = profileItem.fingerprint; - item.alpn = profileItem.alpn; + item.StreamSecurity = profileItem.StreamSecurity; + item.Sni = profileItem.Sni; + item.AllowInsecure = profileItem.AllowInsecure; + item.Fingerprint = profileItem.Fingerprint; + item.Alpn = profileItem.Alpn; - item.publicKey = profileItem.publicKey; - item.shortId = profileItem.shortId; - item.spiderX = profileItem.spiderX; + item.PublicKey = profileItem.PublicKey; + item.ShortId = profileItem.ShortId; + item.SpiderX = profileItem.SpiderX; } - var ret = item.configType switch + var ret = item.ConfigType switch { EConfigType.VMess => await AddVMessServer(config, item), EConfigType.Shadowsocks => await AddShadowsocksServer(config, item), @@ -275,22 +273,22 @@ namespace ServiceLib.Handler /// public static async Task AddVMessServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.VMess; + profileItem.ConfigType = EConfigType.VMess; - profileItem.address = profileItem.address.TrimEx(); - profileItem.id = profileItem.id.TrimEx(); - profileItem.security = profileItem.security.TrimEx(); - profileItem.network = profileItem.network.TrimEx(); - profileItem.headerType = profileItem.headerType.TrimEx(); - profileItem.requestHost = profileItem.requestHost.TrimEx(); - profileItem.path = profileItem.path.TrimEx(); - profileItem.streamSecurity = profileItem.streamSecurity.TrimEx(); + profileItem.Address = profileItem.Address.TrimEx(); + profileItem.Id = profileItem.Id.TrimEx(); + profileItem.Security = profileItem.Security.TrimEx(); + profileItem.Network = profileItem.Network.TrimEx(); + profileItem.HeaderType = profileItem.HeaderType.TrimEx(); + profileItem.RequestHost = profileItem.RequestHost.TrimEx(); + profileItem.Path = profileItem.Path.TrimEx(); + profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx(); - if (!Global.VmessSecurities.Contains(profileItem.security)) + if (!Global.VmessSecurities.Contains(profileItem.Security)) { return -1; } - if (profileItem.id.IsNullOrEmpty()) + if (profileItem.Id.IsNullOrEmpty()) { return -1; } @@ -311,7 +309,7 @@ namespace ServiceLib.Handler var subid = "TempRemoveSubId"; foreach (var item in indexes) { - item.subid = subid; + item.Subid = subid; } await SQLiteHelper.Instance.UpdateAllAsync(indexes); @@ -330,19 +328,19 @@ namespace ServiceLib.Handler { foreach (var it in indexes) { - var item = await AppHandler.Instance.GetProfileItem(it.indexId); + var item = await AppHandler.Instance.GetProfileItem(it.IndexId); if (item is null) { continue; } var profileItem = JsonUtils.DeepCopy(item); - profileItem.indexId = string.Empty; - profileItem.remarks = $"{item.remarks}-clone"; + profileItem.IndexId = string.Empty; + profileItem.Remarks = $"{item.Remarks}-clone"; - if (profileItem.configType == EConfigType.Custom) + if (profileItem.ConfigType == EConfigType.Custom) { - profileItem.address = Utils.GetConfigPath(profileItem.address); + profileItem.Address = Utils.GetConfigPath(profileItem.Address); if (await AddCustomServer(config, profileItem, false) == 0) { } @@ -378,22 +376,22 @@ namespace ServiceLib.Handler public static async Task SetDefaultServer(Config config, List lstProfile) { - if (lstProfile.Exists(t => t.indexId == config.IndexId)) + if (lstProfile.Exists(t => t.IndexId == config.IndexId)) { return 0; } - var count = await SQLiteHelper.Instance.TableAsync().CountAsync(t => t.indexId == config.IndexId); + var count = await SQLiteHelper.Instance.TableAsync().CountAsync(t => t.IndexId == config.IndexId); if (count > 0) { return 0; } if (lstProfile.Count > 0) { - return await SetDefaultServerIndex(config, lstProfile.FirstOrDefault(t => t.port > 0)?.indexId); + return await SetDefaultServerIndex(config, lstProfile.FirstOrDefault(t => t.Port > 0)?.IndexId); } - var item = await SQLiteHelper.Instance.TableAsync().Where(t => t.port > 0).FirstOrDefaultAsync(); - return await SetDefaultServerIndex(config, item.indexId); + var item = await SQLiteHelper.Instance.TableAsync().Where(t => t.Port > 0).FirstOrDefaultAsync(); + return await SetDefaultServerIndex(config, item.IndexId); } public static async Task GetDefaultServer(Config config) @@ -402,7 +400,7 @@ namespace ServiceLib.Handler if (item is null) { var item2 = await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(); - await SetDefaultServerIndex(config, item2?.indexId); + await SetDefaultServerIndex(config, item2?.IndexId); return item2; } @@ -427,7 +425,7 @@ namespace ServiceLib.Handler for (int i = 0; i < lstProfile.Count; i++) { - ProfileExHandler.Instance.SetSort(lstProfile[i].indexId, (i + 1) * 10); + ProfileExHandler.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10); } var sort = 0; @@ -439,7 +437,7 @@ namespace ServiceLib.Handler { return 0; } - sort = ProfileExHandler.Instance.GetSort(lstProfile[0].indexId) - 1; + sort = ProfileExHandler.Instance.GetSort(lstProfile[0].IndexId) - 1; break; } @@ -449,7 +447,7 @@ namespace ServiceLib.Handler { return 0; } - sort = ProfileExHandler.Instance.GetSort(lstProfile[index - 1].indexId) - 1; + sort = ProfileExHandler.Instance.GetSort(lstProfile[index - 1].IndexId) - 1; break; } @@ -460,7 +458,7 @@ namespace ServiceLib.Handler { return 0; } - sort = ProfileExHandler.Instance.GetSort(lstProfile[index + 1].indexId) + 1; + sort = ProfileExHandler.Instance.GetSort(lstProfile[index + 1].IndexId) + 1; break; } @@ -470,7 +468,7 @@ namespace ServiceLib.Handler { return 0; } - sort = ProfileExHandler.Instance.GetSort(lstProfile[^1].indexId) + 1; + sort = ProfileExHandler.Instance.GetSort(lstProfile[^1].IndexId) + 1; break; } @@ -479,7 +477,7 @@ namespace ServiceLib.Handler break; } - ProfileExHandler.Instance.SetSort(lstProfile[index].indexId, sort); + ProfileExHandler.Instance.SetSort(lstProfile[index].IndexId, sort); return 0; } @@ -491,7 +489,7 @@ namespace ServiceLib.Handler /// public static async Task AddCustomServer(Config config, ProfileItem profileItem, bool blDelete) { - var fileName = profileItem.address; + var fileName = profileItem.Address; if (!File.Exists(fileName)) { return -1; @@ -514,11 +512,11 @@ namespace ServiceLib.Handler return -1; } - profileItem.address = newFileName; - profileItem.configType = EConfigType.Custom; - if (Utils.IsNullOrEmpty(profileItem.remarks)) + profileItem.Address = newFileName; + profileItem.ConfigType = EConfigType.Custom; + if (Utils.IsNullOrEmpty(profileItem.Remarks)) { - profileItem.remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}"; + profileItem.Remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}"; } await AddServerCommon(config, profileItem, true); @@ -534,18 +532,18 @@ namespace ServiceLib.Handler /// public static async Task EditCustomServer(Config config, ProfileItem profileItem) { - var item = await AppHandler.Instance.GetProfileItem(profileItem.indexId); + var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId); if (item is null) { item = profileItem; } else { - item.remarks = profileItem.remarks; - item.address = profileItem.address; - item.coreType = profileItem.coreType; - item.displayLog = profileItem.displayLog; - item.preSocksPort = profileItem.preSocksPort; + item.Remarks = profileItem.Remarks; + item.Address = profileItem.Address; + item.CoreType = profileItem.CoreType; + item.DisplayLog = profileItem.DisplayLog; + item.PreSocksPort = profileItem.PreSocksPort; } if (await SQLiteHelper.Instance.UpdateAsync(item) > 0) @@ -568,17 +566,17 @@ namespace ServiceLib.Handler /// public static async Task AddShadowsocksServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.Shadowsocks; + profileItem.ConfigType = EConfigType.Shadowsocks; - profileItem.address = profileItem.address.TrimEx(); - profileItem.id = profileItem.id.TrimEx(); - profileItem.security = profileItem.security.TrimEx(); + profileItem.Address = profileItem.Address.TrimEx(); + profileItem.Id = profileItem.Id.TrimEx(); + profileItem.Security = profileItem.Security.TrimEx(); - if (!AppHandler.Instance.GetShadowsocksSecurities(profileItem).Contains(profileItem.security)) + if (!AppHandler.Instance.GetShadowsocksSecurities(profileItem).Contains(profileItem.Security)) { return -1; } - if (profileItem.id.IsNullOrEmpty()) + if (profileItem.Id.IsNullOrEmpty()) { return -1; } @@ -596,9 +594,9 @@ namespace ServiceLib.Handler /// public static async Task AddSocksServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.SOCKS; + profileItem.ConfigType = EConfigType.SOCKS; - profileItem.address = profileItem.address.TrimEx(); + profileItem.Address = profileItem.Address.TrimEx(); await AddServerCommon(config, profileItem, toFile); @@ -613,9 +611,9 @@ namespace ServiceLib.Handler /// public static async Task AddHttpServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.HTTP; + profileItem.ConfigType = EConfigType.HTTP; - profileItem.address = profileItem.address.TrimEx(); + profileItem.Address = profileItem.Address.TrimEx(); await AddServerCommon(config, profileItem, toFile); @@ -630,15 +628,15 @@ namespace ServiceLib.Handler /// public static async Task AddTrojanServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.Trojan; + profileItem.ConfigType = EConfigType.Trojan; - profileItem.address = profileItem.address.TrimEx(); - profileItem.id = profileItem.id.TrimEx(); - if (Utils.IsNullOrEmpty(profileItem.streamSecurity)) + profileItem.Address = profileItem.Address.TrimEx(); + profileItem.Id = profileItem.Id.TrimEx(); + if (Utils.IsNullOrEmpty(profileItem.StreamSecurity)) { - profileItem.streamSecurity = Global.StreamSecurity; + profileItem.StreamSecurity = Global.StreamSecurity; } - if (profileItem.id.IsNullOrEmpty()) + if (profileItem.Id.IsNullOrEmpty()) { return -1; } @@ -656,19 +654,19 @@ namespace ServiceLib.Handler /// public static async Task AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.Hysteria2; - profileItem.coreType = ECoreType.sing_box; + profileItem.ConfigType = EConfigType.Hysteria2; + profileItem.CoreType = ECoreType.sing_box; - profileItem.address = profileItem.address.TrimEx(); - profileItem.id = profileItem.id.TrimEx(); - profileItem.path = profileItem.path.TrimEx(); - profileItem.network = string.Empty; + profileItem.Address = profileItem.Address.TrimEx(); + profileItem.Id = profileItem.Id.TrimEx(); + profileItem.Path = profileItem.Path.TrimEx(); + profileItem.Network = string.Empty; - if (Utils.IsNullOrEmpty(profileItem.streamSecurity)) + if (Utils.IsNullOrEmpty(profileItem.StreamSecurity)) { - profileItem.streamSecurity = Global.StreamSecurity; + profileItem.StreamSecurity = Global.StreamSecurity; } - if (profileItem.id.IsNullOrEmpty()) + if (profileItem.Id.IsNullOrEmpty()) { return -1; } @@ -686,28 +684,28 @@ namespace ServiceLib.Handler /// public static async Task AddTuicServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.TUIC; - profileItem.coreType = ECoreType.sing_box; + profileItem.ConfigType = EConfigType.TUIC; + profileItem.CoreType = ECoreType.sing_box; - profileItem.address = profileItem.address.TrimEx(); - profileItem.id = profileItem.id.TrimEx(); - profileItem.security = profileItem.security.TrimEx(); - profileItem.network = string.Empty; + profileItem.Address = profileItem.Address.TrimEx(); + profileItem.Id = profileItem.Id.TrimEx(); + profileItem.Security = profileItem.Security.TrimEx(); + profileItem.Network = string.Empty; - if (!Global.TuicCongestionControls.Contains(profileItem.headerType)) + if (!Global.TuicCongestionControls.Contains(profileItem.HeaderType)) { - profileItem.headerType = Global.TuicCongestionControls.FirstOrDefault()!; + profileItem.HeaderType = Global.TuicCongestionControls.FirstOrDefault()!; } - if (Utils.IsNullOrEmpty(profileItem.streamSecurity)) + if (Utils.IsNullOrEmpty(profileItem.StreamSecurity)) { - profileItem.streamSecurity = Global.StreamSecurity; + profileItem.StreamSecurity = Global.StreamSecurity; } - if (Utils.IsNullOrEmpty(profileItem.alpn)) + if (Utils.IsNullOrEmpty(profileItem.Alpn)) { - profileItem.alpn = "h3"; + profileItem.Alpn = "h3"; } - if (profileItem.id.IsNullOrEmpty()) + if (profileItem.Id.IsNullOrEmpty()) { return -1; } @@ -725,21 +723,21 @@ namespace ServiceLib.Handler /// public static async Task AddWireguardServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.WireGuard; - profileItem.coreType = ECoreType.sing_box; + profileItem.ConfigType = EConfigType.WireGuard; + profileItem.CoreType = ECoreType.sing_box; - profileItem.address = profileItem.address.TrimEx(); - profileItem.id = profileItem.id.TrimEx(); - profileItem.publicKey = profileItem.publicKey.TrimEx(); - profileItem.path = profileItem.path.TrimEx(); - profileItem.requestHost = profileItem.requestHost.TrimEx(); - profileItem.network = string.Empty; - if (profileItem.shortId.IsNullOrEmpty()) + profileItem.Address = profileItem.Address.TrimEx(); + profileItem.Id = profileItem.Id.TrimEx(); + profileItem.PublicKey = profileItem.PublicKey.TrimEx(); + profileItem.Path = profileItem.Path.TrimEx(); + profileItem.RequestHost = profileItem.RequestHost.TrimEx(); + profileItem.Network = string.Empty; + if (profileItem.ShortId.IsNullOrEmpty()) { - profileItem.shortId = Global.TunMtus.FirstOrDefault(); + profileItem.ShortId = Global.TunMtus.FirstOrDefault(); } - if (profileItem.id.IsNullOrEmpty()) + if (profileItem.Id.IsNullOrEmpty()) { return -1; } @@ -758,46 +756,46 @@ namespace ServiceLib.Handler } var lstProfileExs = ProfileExHandler.Instance.ProfileExs; var lstProfile = (from t in lstModel - join t3 in lstProfileExs on t.indexId equals t3.indexId into t3b + join t3 in lstProfileExs on t.IndexId equals t3.IndexId into t3b from t33 in t3b.DefaultIfEmpty() select new ProfileItemModel { - indexId = t.indexId, - configType = t.configType, - remarks = t.remarks, - address = t.address, - port = t.port, - security = t.security, - network = t.network, - streamSecurity = t.streamSecurity, - delay = t33 == null ? 0 : t33.delay, - speed = t33 == null ? 0 : t33.speed, - sort = t33 == null ? 0 : t33.sort + IndexId = t.IndexId, + ConfigType = t.ConfigType, + Remarks = t.Remarks, + Address = t.Address, + Port = t.Port, + Security = t.Security, + Network = t.Network, + StreamSecurity = t.StreamSecurity, + Delay = t33 == null ? 0 : t33.Delay, + Speed = t33 == null ? 0 : t33.Speed, + Sort = t33 == null ? 0 : t33.Sort }).ToList(); Enum.TryParse(colName, true, out EServerColName name); var propertyName = string.Empty; switch (name) { - case EServerColName.configType: - case EServerColName.remarks: - case EServerColName.address: - case EServerColName.port: - case EServerColName.network: - case EServerColName.streamSecurity: + case EServerColName.ConfigType: + case EServerColName.Remarks: + case EServerColName.Address: + case EServerColName.Port: + case EServerColName.Network: + case EServerColName.StreamSecurity: propertyName = name.ToString(); break; - case EServerColName.delayVal: - propertyName = "delay"; + case EServerColName.DelayVal: + propertyName = "Delay"; break; - case EServerColName.speedVal: - propertyName = "speed"; + case EServerColName.SpeedVal: + propertyName = "Speed"; break; - case EServerColName.subRemarks: - propertyName = "subid"; + case EServerColName.SubRemarks: + propertyName = "Subid"; break; default: @@ -816,27 +814,27 @@ namespace ServiceLib.Handler } for (int i = 0; i < lstProfile.Count; i++) { - ProfileExHandler.Instance.SetSort(lstProfile[i].indexId, (i + 1) * 10); + ProfileExHandler.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10); } - if (name == EServerColName.delayVal) + if (name == EServerColName.DelayVal) { - var maxSort = lstProfile.Max(t => t.sort) + 10; + var maxSort = lstProfile.Max(t => t.Sort) + 10; foreach (var item in lstProfile) { - if (item.delay <= 0) + if (item.Delay <= 0) { - ProfileExHandler.Instance.SetSort(item.indexId, maxSort); + ProfileExHandler.Instance.SetSort(item.IndexId, maxSort); } } } - if (name == EServerColName.speedVal) + if (name == EServerColName.SpeedVal) { - var maxSort = lstProfile.Max(t => t.sort) + 10; + var maxSort = lstProfile.Max(t => t.Sort) + 10; foreach (var item in lstProfile) { - if (item.speed <= 0) + if (item.Speed <= 0) { - ProfileExHandler.Instance.SetSort(item.indexId, maxSort); + ProfileExHandler.Instance.SetSort(item.IndexId, maxSort); } } } @@ -852,28 +850,28 @@ namespace ServiceLib.Handler /// public static async Task AddVlessServer(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configType = EConfigType.VLESS; + profileItem.ConfigType = EConfigType.VLESS; - profileItem.address = profileItem.address.TrimEx(); - profileItem.id = profileItem.id.TrimEx(); - profileItem.security = profileItem.security.TrimEx(); - profileItem.network = profileItem.network.TrimEx(); - profileItem.headerType = profileItem.headerType.TrimEx(); - profileItem.requestHost = profileItem.requestHost.TrimEx(); - profileItem.path = profileItem.path.TrimEx(); - profileItem.streamSecurity = profileItem.streamSecurity.TrimEx(); + profileItem.Address = profileItem.Address.TrimEx(); + profileItem.Id = profileItem.Id.TrimEx(); + profileItem.Security = profileItem.Security.TrimEx(); + profileItem.Network = profileItem.Network.TrimEx(); + profileItem.HeaderType = profileItem.HeaderType.TrimEx(); + profileItem.RequestHost = profileItem.RequestHost.TrimEx(); + profileItem.Path = profileItem.Path.TrimEx(); + profileItem.StreamSecurity = profileItem.StreamSecurity.TrimEx(); - if (!Global.Flows.Contains(profileItem.flow)) + if (!Global.Flows.Contains(profileItem.Flow)) { - profileItem.flow = Global.Flows.First(); + profileItem.Flow = Global.Flows.First(); } - if (profileItem.id.IsNullOrEmpty()) + if (profileItem.Id.IsNullOrEmpty()) { return -1; } - if (Utils.IsNotEmpty(profileItem.security) && profileItem.security != Global.None) + if (Utils.IsNotEmpty(profileItem.Security) && profileItem.Security != Global.None) { - profileItem.security = Global.None; + profileItem.Security = Global.None; } await AddServerCommon(config, profileItem, toFile); @@ -907,37 +905,37 @@ namespace ServiceLib.Handler public static async Task AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true) { - profileItem.configVersion = 2; + profileItem.ConfigVersion = 2; - if (Utils.IsNotEmpty(profileItem.streamSecurity)) + if (Utils.IsNotEmpty(profileItem.StreamSecurity)) { - if (profileItem.streamSecurity != Global.StreamSecurity - && profileItem.streamSecurity != Global.StreamSecurityReality) + if (profileItem.StreamSecurity != Global.StreamSecurity + && profileItem.StreamSecurity != Global.StreamSecurityReality) { - profileItem.streamSecurity = string.Empty; + profileItem.StreamSecurity = string.Empty; } else { - if (Utils.IsNullOrEmpty(profileItem.allowInsecure)) + if (Utils.IsNullOrEmpty(profileItem.AllowInsecure)) { - profileItem.allowInsecure = config.CoreBasicItem.DefAllowInsecure.ToString().ToLower(); + profileItem.AllowInsecure = config.CoreBasicItem.DefAllowInsecure.ToString().ToLower(); } - if (Utils.IsNullOrEmpty(profileItem.fingerprint) && profileItem.streamSecurity == Global.StreamSecurityReality) + if (Utils.IsNullOrEmpty(profileItem.Fingerprint) && profileItem.StreamSecurity == Global.StreamSecurityReality) { - profileItem.fingerprint = config.CoreBasicItem.DefFingerprint; + profileItem.Fingerprint = config.CoreBasicItem.DefFingerprint; } } } - if (Utils.IsNotEmpty(profileItem.network) && !Global.Networks.Contains(profileItem.network)) + if (Utils.IsNotEmpty(profileItem.Network) && !Global.Networks.Contains(profileItem.Network)) { - profileItem.network = Global.DefaultNetwork; + profileItem.Network = Global.DefaultNetwork; } var maxSort = -1; - if (Utils.IsNullOrEmpty(profileItem.indexId)) + if (Utils.IsNullOrEmpty(profileItem.IndexId)) { - profileItem.indexId = Utils.GetGuid(false); + profileItem.IndexId = Utils.GetGuid(false); maxSort = ProfileExHandler.Instance.GetMaxSort(); } if (!toFile && maxSort < 0) @@ -946,7 +944,7 @@ namespace ServiceLib.Handler } if (maxSort > 0) { - ProfileExHandler.Instance.SetSort(profileItem.indexId, maxSort + 1); + ProfileExHandler.Instance.SetSort(profileItem.IndexId, maxSort + 1); } if (toFile) @@ -963,20 +961,20 @@ namespace ServiceLib.Handler return false; } - return o.configType == n.configType - && o.address == n.address - && o.port == n.port - && o.id == n.id - && o.alterId == n.alterId - && o.security == n.security - && o.network == n.network - && o.headerType == n.headerType - && o.requestHost == n.requestHost - && o.path == n.path - && (o.configType == EConfigType.Trojan || o.streamSecurity == n.streamSecurity) - && o.flow == n.flow - && o.sni == n.sni - && (!remarks || o.remarks == n.remarks); + return o.ConfigType == n.ConfigType + && o.Address == n.Address + && o.Port == n.Port + && o.Id == n.Id + && o.AlterId == n.AlterId + && o.Security == n.Security + && o.Network == n.Network + && o.HeaderType == n.HeaderType + && o.RequestHost == n.RequestHost + && o.Path == n.Path + && (o.ConfigType == EConfigType.Trojan || o.StreamSecurity == n.StreamSecurity) + && o.Flow == n.Flow + && o.Sni == n.Sni + && (!remarks || o.Remarks == n.Remarks); } private static async Task RemoveProfileItem(Config config, string indexId) @@ -988,9 +986,9 @@ namespace ServiceLib.Handler { return 0; } - if (item.configType == EConfigType.Custom) + if (item.ConfigType == EConfigType.Custom) { - File.Delete(Utils.GetConfigPath(item.address)); + File.Delete(Utils.GetConfigPath(item.Address)); } await SQLiteHelper.Instance.DeleteAsync(item); @@ -1021,11 +1019,11 @@ namespace ServiceLib.Handler } var profileItem = await AppHandler.Instance.GetProfileItem(indexId) ?? new(); - profileItem.indexId = indexId; - profileItem.remarks = coreType == ECoreType.sing_box ? ResUI.menuSetDefaultMultipleServer : ResUI.menuSetDefaultLoadBalanceServer; - profileItem.address = Global.CoreMultipleLoadConfigFileName; - profileItem.configType = EConfigType.Custom; - profileItem.coreType = coreType; + profileItem.IndexId = indexId; + profileItem.Remarks = coreType == ECoreType.sing_box ? ResUI.menuSetDefaultMultipleServer : ResUI.menuSetDefaultLoadBalanceServer; + profileItem.Address = Global.CoreMultipleLoadConfigFileName; + profileItem.ConfigType = EConfigType.Custom; + profileItem.CoreType = coreType; await AddServerCommon(config, profileItem, true); @@ -1056,7 +1054,7 @@ namespace ServiceLib.Handler if (isSub && Utils.IsNotEmpty(subid)) { await RemoveServerViaSubid(config, subid, isSub); - subFilter = (await AppHandler.Instance.GetSubItem(subid))?.filter ?? ""; + subFilter = (await AppHandler.Instance.GetSubItem(subid))?.Filter ?? ""; } int countServers = 0; @@ -1088,8 +1086,8 @@ namespace ServiceLib.Handler //exist sub items if (isSub && Utils.IsNotEmpty(subid)) { - var existItem = lstOriSub?.FirstOrDefault(t => t.isSub == isSub - && config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.remarks == profileItem.remarks : CompareProfileItem(t, profileItem, true)); + var existItem = lstOriSub?.FirstOrDefault(t => t.IsSub == isSub + && config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == profileItem.Remarks : CompareProfileItem(t, profileItem, true)); if (existItem != null) { //Check for duplicate indexId @@ -1097,29 +1095,29 @@ namespace ServiceLib.Handler { lstDbIndexId = await AppHandler.Instance.ProfileItemIndexes(""); } - if (lstAdd.Any(t => t.indexId == existItem.indexId) - || lstDbIndexId.Any(t => t == existItem.indexId)) + if (lstAdd.Any(t => t.IndexId == existItem.IndexId) + || lstDbIndexId.Any(t => t == existItem.IndexId)) { - profileItem.indexId = string.Empty; + profileItem.IndexId = string.Empty; } else { - profileItem.indexId = existItem.indexId; + profileItem.IndexId = existItem.IndexId; } } //filter if (Utils.IsNotEmpty(subFilter)) { - if (!Regex.IsMatch(profileItem.remarks, subFilter)) + if (!Regex.IsMatch(profileItem.Remarks, subFilter)) { continue; } } } - profileItem.subid = subid; - profileItem.isSub = isSub; + profileItem.Subid = subid; + profileItem.IsSub = isSub; - var addStatus = profileItem.configType switch + var addStatus = profileItem.ConfigType switch { EConfigType.VMess => await AddVMessServer(config, profileItem, false), EConfigType.Shadowsocks => await AddShadowsocksServer(config, profileItem, false), @@ -1156,8 +1154,8 @@ namespace ServiceLib.Handler } var subItem = await AppHandler.Instance.GetSubItem(subid); - var subRemarks = subItem?.remarks; - var preSocksPort = subItem?.preSocksPort; + var subRemarks = subItem?.Remarks; + var preSocksPort = subItem?.PreSocksPort; List? lstProfiles = null; //Is sing-box array configuration @@ -1179,9 +1177,9 @@ namespace ServiceLib.Handler int count = 0; foreach (var it in lstProfiles) { - it.subid = subid; - it.isSub = isSub; - it.preSocksPort = preSocksPort; + it.Subid = subid; + it.IsSub = isSub; + it.PreSocksPort = preSocksPort; if (await AddCustomServer(config, it, true) == 0) { count++; @@ -1223,7 +1221,7 @@ namespace ServiceLib.Handler { profileItem = NaiveproxyFmt.ResolveFull(strData, subRemarks); } - if (profileItem is null || Utils.IsNullOrEmpty(profileItem.address)) + if (profileItem is null || Utils.IsNullOrEmpty(profileItem.Address)) { return -1; } @@ -1234,11 +1232,11 @@ namespace ServiceLib.Handler } if (isSub && lstOriSub?.Count == 1) { - profileItem.indexId = lstOriSub[0].indexId; + profileItem.IndexId = lstOriSub[0].IndexId; } - profileItem.subid = subid; - profileItem.isSub = isSub; - profileItem.preSocksPort = preSocksPort; + profileItem.Subid = subid; + profileItem.IsSub = isSub; + profileItem.PreSocksPort = preSocksPort; if (await AddCustomServer(config, profileItem, true) == 0) { return 1; @@ -1267,8 +1265,8 @@ namespace ServiceLib.Handler int counter = 0; foreach (var ssItem in lstSsServer) { - ssItem.subid = subid; - ssItem.isSub = isSub; + ssItem.Subid = subid; + ssItem.IsSub = isSub; if (await AddShadowsocksServer(config, ssItem) == 0) { counter++; @@ -1334,22 +1332,22 @@ namespace ServiceLib.Handler public static async Task AddSubItem(Config config, string url) { //already exists - var count = await SQLiteHelper.Instance.TableAsync().CountAsync(e => e.url == url); + var count = await SQLiteHelper.Instance.TableAsync().CountAsync(e => e.Url == url); if (count > 0) { return 0; } SubItem subItem = new() { - id = string.Empty, - url = url + Id = string.Empty, + Url = url }; try { var uri = new Uri(url); var queryVars = Utils.ParseQueryString(uri.Query); - subItem.remarks = queryVars["remarks"] ?? "import_sub"; + subItem.Remarks = queryVars["remarks"] ?? "import_sub"; } catch (UriFormatException) { @@ -1361,41 +1359,41 @@ namespace ServiceLib.Handler public static async Task AddSubItem(Config config, SubItem subItem) { - var item = await AppHandler.Instance.GetSubItem(subItem.id); + var item = await AppHandler.Instance.GetSubItem(subItem.Id); if (item is null) { item = subItem; } else { - item.remarks = subItem.remarks; - item.url = subItem.url; - item.moreUrl = subItem.moreUrl; - item.enabled = subItem.enabled; - item.autoUpdateInterval = subItem.autoUpdateInterval; - item.userAgent = subItem.userAgent; - item.sort = subItem.sort; - item.filter = subItem.filter; - item.updateTime = subItem.updateTime; - item.convertTarget = subItem.convertTarget; - item.prevProfile = subItem.prevProfile; - item.nextProfile = subItem.nextProfile; - item.preSocksPort = subItem.preSocksPort; + item.Remarks = subItem.Remarks; + item.Url = subItem.Url; + item.MoreUrl = subItem.MoreUrl; + item.Enabled = subItem.Enabled; + item.AutoUpdateInterval = subItem.AutoUpdateInterval; + item.UserAgent = subItem.UserAgent; + item.Sort = subItem.Sort; + item.Filter = subItem.Filter; + item.UpdateTime = subItem.UpdateTime; + item.ConvertTarget = subItem.ConvertTarget; + item.PrevProfile = subItem.PrevProfile; + item.NextProfile = subItem.NextProfile; + item.PreSocksPort = subItem.PreSocksPort; } - if (Utils.IsNullOrEmpty(item.id)) + if (Utils.IsNullOrEmpty(item.Id)) { - item.id = Utils.GetGuid(false); + item.Id = Utils.GetGuid(false); - if (item.sort <= 0) + if (item.Sort <= 0) { var maxSort = 0; if (await SQLiteHelper.Instance.TableAsync().CountAsync() > 0) { var lstSubs = (await AppHandler.Instance.SubItems()); - maxSort = lstSubs.LastOrDefault()?.sort ?? 0; + maxSort = lstSubs.LastOrDefault()?.Sort ?? 0; } - item.sort = maxSort + 1; + item.Sort = maxSort + 1; } } if (await SQLiteHelper.Instance.ReplaceAsync(item) > 0) @@ -1420,7 +1418,7 @@ namespace ServiceLib.Handler { return -1; } - var customProfile = await SQLiteHelper.Instance.TableAsync().Where(t => t.subid == subid && t.configType == EConfigType.Custom).ToListAsync(); + var customProfile = await SQLiteHelper.Instance.TableAsync().Where(t => t.Subid == subid && t.ConfigType == EConfigType.Custom).ToListAsync(); if (isSub) { await SQLiteHelper.Instance.ExecuteAsync($"delete from ProfileItem where isSub = 1 and subid = '{subid}'"); @@ -1431,7 +1429,7 @@ namespace ServiceLib.Handler } foreach (var item in customProfile) { - File.Delete(Utils.GetConfigPath(item.address)); + File.Delete(Utils.GetConfigPath(item.Address)); } return 0; @@ -1454,7 +1452,7 @@ namespace ServiceLib.Handler { foreach (var item in lstProfile) { - item.subid = subid; + item.Subid = subid; } await SQLiteHelper.Instance.UpdateAllAsync(lstProfile); @@ -1467,9 +1465,9 @@ namespace ServiceLib.Handler public static async Task SaveRoutingItem(Config config, RoutingItem item) { - if (Utils.IsNullOrEmpty(item.id)) + if (Utils.IsNullOrEmpty(item.Id)) { - item.id = Utils.GetGuid(false); + item.Id = Utils.GetGuid(false); } if (await SQLiteHelper.Instance.ReplaceAsync(item) > 0) @@ -1505,12 +1503,12 @@ namespace ServiceLib.Handler { item.id = Utils.GetGuid(false); } - routingItem.ruleNum = lstRules.Count; - routingItem.ruleSet = JsonUtils.Serialize(lstRules, false); + routingItem.RuleNum = lstRules.Count; + routingItem.RuleSet = JsonUtils.Serialize(lstRules, false); - if (Utils.IsNullOrEmpty(routingItem.id)) + if (Utils.IsNullOrEmpty(routingItem.Id)) { - routingItem.id = Utils.GetGuid(false); + routingItem.Id = Utils.GetGuid(false); } if (await SQLiteHelper.Instance.ReplaceAsync(routingItem) > 0) @@ -1602,9 +1600,9 @@ namespace ServiceLib.Handler public static async Task SetDefaultRouting(Config config, RoutingItem routingItem) { - if (await SQLiteHelper.Instance.TableAsync().Where(t => t.id == routingItem.id).CountAsync() > 0) + if (await SQLiteHelper.Instance.TableAsync().Where(t => t.Id == routingItem.Id).CountAsync() > 0) { - config.RoutingBasicItem.RoutingIndexId = routingItem.id; + config.RoutingBasicItem.RoutingIndexId = routingItem.Id; } await ToJsonFile(config); @@ -1617,7 +1615,7 @@ namespace ServiceLib.Handler var item = await AppHandler.Instance.GetRoutingItem(config.RoutingBasicItem.RoutingIndexId); if (item is null) { - var item2 = await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(t => t.locked == false); + var item2 = await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(t => t.Locked == false); await SetDefaultRouting(config, item2); return item2; } @@ -1652,7 +1650,7 @@ namespace ServiceLib.Handler var items = await AppHandler.Instance.RoutingItems(); var maxSort = items.Count; - if (!blImportAdvancedRules && items.Where(t => t.remarks.StartsWith(template.version)).ToList().Count > 0) + if (!blImportAdvancedRules && items.Where(t => t.Remarks.StartsWith(template.version)).ToList().Count > 0) { return 0; } @@ -1660,20 +1658,20 @@ namespace ServiceLib.Handler { var item = template.routingItems[i]; - if (string.IsNullOrEmpty(item.url) && string.IsNullOrEmpty(item.ruleSet)) + if (string.IsNullOrEmpty(item.Url) && string.IsNullOrEmpty(item.RuleSet)) continue; - var ruleSetsString = !string.IsNullOrEmpty(item.ruleSet) - ? item.ruleSet - : await downloadHandle.TryDownloadString(item.url, true, ""); + var ruleSetsString = !string.IsNullOrEmpty(item.RuleSet) + ? item.RuleSet + : await downloadHandle.TryDownloadString(item.Url, true, ""); if (string.IsNullOrEmpty(ruleSetsString)) continue; - item.remarks = $"{template.version}-{item.remarks}"; - item.enabled = true; - item.sort = ++maxSort; - item.url = string.Empty; + item.Remarks = $"{template.version}-{item.Remarks}"; + item.Enabled = true; + item.Sort = ++maxSort; + item.Url = string.Empty; await AddBatchRoutingRules(item, ruleSetsString); @@ -1691,7 +1689,7 @@ namespace ServiceLib.Handler { var ver = "V3-"; var items = await AppHandler.Instance.RoutingItems(); - if (!blImportAdvancedRules && items.Where(t => t.remarks.StartsWith(ver)).ToList().Count > 0) + if (!blImportAdvancedRules && items.Where(t => t.Remarks.StartsWith(ver)).ToList().Count > 0) { return 0; } @@ -1700,27 +1698,27 @@ namespace ServiceLib.Handler //Bypass the mainland var item2 = new RoutingItem() { - remarks = $"{ver}绕过大陆(Whitelist)", - url = string.Empty, - sort = maxSort + 1, + Remarks = $"{ver}绕过大陆(Whitelist)", + Url = string.Empty, + Sort = maxSort + 1, }; await AddBatchRoutingRules(item2, Utils.GetEmbedText(Global.CustomRoutingFileName + "white")); //Blacklist var item3 = new RoutingItem() { - remarks = $"{ver}黑名单(Blacklist)", - url = string.Empty, - sort = maxSort + 2, + Remarks = $"{ver}黑名单(Blacklist)", + Url = string.Empty, + Sort = maxSort + 2, }; await AddBatchRoutingRules(item3, Utils.GetEmbedText(Global.CustomRoutingFileName + "black")); //Global var item1 = new RoutingItem() { - remarks = $"{ver}全局(Global)", - url = string.Empty, - sort = maxSort + 3, + Remarks = $"{ver}全局(Global)", + Url = string.Empty, + Sort = maxSort + 3, }; await AddBatchRoutingRules(item1, Utils.GetEmbedText(Global.CustomRoutingFileName + "global")); @@ -1733,7 +1731,7 @@ namespace ServiceLib.Handler public static async Task GetLockedRoutingItem(Config config) { - return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.locked == true); + return await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.Locked == true); } public static async Task RemoveRoutingItem(RoutingItem routingItem) @@ -1752,15 +1750,15 @@ namespace ServiceLib.Handler { var item = new DNSItem() { - remarks = "V2ray", - coreType = ECoreType.Xray, + Remarks = "V2ray", + CoreType = ECoreType.Xray, }; await SaveDNSItems(config, item); var item2 = new DNSItem() { - remarks = "sing-box", - coreType = ECoreType.sing_box, + Remarks = "sing-box", + CoreType = ECoreType.sing_box, }; await SaveDNSItems(config, item2); } @@ -1775,9 +1773,9 @@ namespace ServiceLib.Handler return -1; } - if (Utils.IsNullOrEmpty(item.id)) + if (Utils.IsNullOrEmpty(item.Id)) { - item.id = Utils.GetGuid(false); + item.Id = Utils.GetGuid(false); } if (await SQLiteHelper.Instance.ReplaceAsync(item) > 0) @@ -1803,16 +1801,16 @@ namespace ServiceLib.Handler if (template == null) return currentItem; - if (!string.IsNullOrEmpty(template.normalDNS)) - template.normalDNS = await downloadHandle.TryDownloadString(template.normalDNS, true, ""); + if (!string.IsNullOrEmpty(template.NormalDNS)) + template.NormalDNS = await downloadHandle.TryDownloadString(template.NormalDNS, true, ""); - if (!string.IsNullOrEmpty(template.tunDNS)) - template.tunDNS = await downloadHandle.TryDownloadString(template.tunDNS, true, ""); + if (!string.IsNullOrEmpty(template.TunDNS)) + template.TunDNS = await downloadHandle.TryDownloadString(template.TunDNS, true, ""); - template.id = currentItem.id; - template.enabled = currentItem.enabled; - template.remarks = currentItem.remarks; - template.coreType = type; + template.Id = currentItem.Id; + template.Enabled = currentItem.Enabled; + template.Remarks = currentItem.Remarks; + template.CoreType = type; return template; } diff --git a/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs b/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs index 40c00992..cfe05360 100644 --- a/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreConfigHandler.cs @@ -10,13 +10,13 @@ var config = AppHandler.Instance.Config; var result = new RetResult(); - if (node.configType == EConfigType.Custom) + if (node.ConfigType == EConfigType.Custom) { - if (node.coreType is ECoreType.mihomo) + if (node.CoreType is ECoreType.mihomo) { result = await new CoreConfigClashService(config).GenerateClientCustomConfig(node, fileName); } - if (node.coreType is ECoreType.sing_box) + if (node.CoreType is ECoreType.sing_box) { result = await new CoreConfigSingboxService(config).GenerateClientCustomConfig(node, fileName); } @@ -25,7 +25,7 @@ result = await GenerateClientCustomConfig(node, fileName); } } - else if (AppHandler.Instance.GetCoreType(node, node.configType) == ECoreType.sing_box) + else if (AppHandler.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box) { result = await new CoreConfigSingboxService(config).GenerateClientConfigContent(node); } @@ -62,7 +62,7 @@ File.Delete(fileName); } - string addressFileName = node.address; + string addressFileName = node.Address; if (!File.Exists(addressFileName)) { addressFileName = Utils.GetConfigPath(addressFileName); diff --git a/v2rayN/ServiceLib/Handler/CoreHandler.cs b/v2rayN/ServiceLib/Handler/CoreHandler.cs index a2f85d02..a260db01 100644 --- a/v2rayN/ServiceLib/Handler/CoreHandler.cs +++ b/v2rayN/ServiceLib/Handler/CoreHandler.cs @@ -181,11 +181,11 @@ namespace ServiceLib.Handler //{ // coreType = LazyConfig.Instance.GetCoreType(node, node.configType); //} - var coreType = AppHandler.Instance.GetCoreType(node, node.configType); + var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType); _config.RunningCoreType = coreType; var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); - var displayLog = node.configType != EConfigType.Custom || node.displayLog; + var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog; var proc = RunProcess(node, coreInfo, "", displayLog); if (proc is null) { @@ -198,26 +198,26 @@ namespace ServiceLib.Handler { ProfileItem? itemSocks = null; var preCoreType = ECoreType.sing_box; - if (node.configType != EConfigType.Custom && coreType != ECoreType.sing_box && _config.TunModeItem.EnableTun) + if (node.ConfigType != EConfigType.Custom && coreType != ECoreType.sing_box && _config.TunModeItem.EnableTun) { itemSocks = new ProfileItem() { - coreType = preCoreType, - configType = EConfigType.SOCKS, - address = Global.Loopback, - sni = node.address, //Tun2SocksAddress - port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks) + CoreType = preCoreType, + ConfigType = EConfigType.SOCKS, + Address = Global.Loopback, + Sni = node.Address, //Tun2SocksAddress + Port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks) }; } - else if ((node.configType == EConfigType.Custom && node.preSocksPort > 0)) + else if ((node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0)) { preCoreType = _config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray; itemSocks = new ProfileItem() { - coreType = preCoreType, - configType = EConfigType.SOCKS, - address = Global.Loopback, - port = node.preSocksPort.Value, + CoreType = preCoreType, + ConfigType = EConfigType.SOCKS, + Address = Global.Loopback, + Port = node.PreSocksPort.Value, }; _config.RunningCoreType = preCoreType; } diff --git a/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs index 96b5245b..6520ca64 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/BaseFmt.cs @@ -16,14 +16,14 @@ namespace ServiceLib.Handler.Fmt protected static int GetStdTransport(ProfileItem item, string? securityDef, ref Dictionary dicQuery) { - if (Utils.IsNotEmpty(item.flow)) + if (Utils.IsNotEmpty(item.Flow)) { - dicQuery.Add("flow", item.flow); + dicQuery.Add("flow", item.Flow); } - if (Utils.IsNotEmpty(item.streamSecurity)) + if (Utils.IsNotEmpty(item.StreamSecurity)) { - dicQuery.Add("security", item.streamSecurity); + dicQuery.Add("security", item.StreamSecurity); } else { @@ -32,95 +32,95 @@ namespace ServiceLib.Handler.Fmt dicQuery.Add("security", securityDef); } } - if (Utils.IsNotEmpty(item.sni)) + if (Utils.IsNotEmpty(item.Sni)) { - dicQuery.Add("sni", item.sni); + dicQuery.Add("sni", item.Sni); } - if (Utils.IsNotEmpty(item.alpn)) + if (Utils.IsNotEmpty(item.Alpn)) { - dicQuery.Add("alpn", Utils.UrlEncode(item.alpn)); + dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn)); } - if (Utils.IsNotEmpty(item.fingerprint)) + if (Utils.IsNotEmpty(item.Fingerprint)) { - dicQuery.Add("fp", Utils.UrlEncode(item.fingerprint)); + dicQuery.Add("fp", Utils.UrlEncode(item.Fingerprint)); } - if (Utils.IsNotEmpty(item.publicKey)) + if (Utils.IsNotEmpty(item.PublicKey)) { - dicQuery.Add("pbk", Utils.UrlEncode(item.publicKey)); + dicQuery.Add("pbk", Utils.UrlEncode(item.PublicKey)); } - if (Utils.IsNotEmpty(item.shortId)) + if (Utils.IsNotEmpty(item.ShortId)) { - dicQuery.Add("sid", Utils.UrlEncode(item.shortId)); + dicQuery.Add("sid", Utils.UrlEncode(item.ShortId)); } - if (Utils.IsNotEmpty(item.spiderX)) + if (Utils.IsNotEmpty(item.SpiderX)) { - dicQuery.Add("spx", Utils.UrlEncode(item.spiderX)); + dicQuery.Add("spx", Utils.UrlEncode(item.SpiderX)); } - if (item.allowInsecure.Equals("true")) + if (item.AllowInsecure.Equals("true")) { dicQuery.Add("allowInsecure", "1"); } - dicQuery.Add("type", Utils.IsNotEmpty(item.network) ? item.network : nameof(ETransport.tcp)); + dicQuery.Add("type", Utils.IsNotEmpty(item.Network) ? item.Network : nameof(ETransport.tcp)); - switch (item.network) + switch (item.Network) { case nameof(ETransport.tcp): - dicQuery.Add("headerType", Utils.IsNotEmpty(item.headerType) ? item.headerType : Global.None); - if (Utils.IsNotEmpty(item.requestHost)) + dicQuery.Add("headerType", Utils.IsNotEmpty(item.HeaderType) ? item.HeaderType : Global.None); + if (Utils.IsNotEmpty(item.RequestHost)) { - dicQuery.Add("host", Utils.UrlEncode(item.requestHost)); + dicQuery.Add("host", Utils.UrlEncode(item.RequestHost)); } break; case nameof(ETransport.kcp): - dicQuery.Add("headerType", Utils.IsNotEmpty(item.headerType) ? item.headerType : Global.None); - if (Utils.IsNotEmpty(item.path)) + dicQuery.Add("headerType", Utils.IsNotEmpty(item.HeaderType) ? item.HeaderType : Global.None); + if (Utils.IsNotEmpty(item.Path)) { - dicQuery.Add("seed", Utils.UrlEncode(item.path)); + dicQuery.Add("seed", Utils.UrlEncode(item.Path)); } break; case nameof(ETransport.ws): case nameof(ETransport.httpupgrade): case nameof(ETransport.splithttp): - if (Utils.IsNotEmpty(item.requestHost)) + if (Utils.IsNotEmpty(item.RequestHost)) { - dicQuery.Add("host", Utils.UrlEncode(item.requestHost)); + dicQuery.Add("host", Utils.UrlEncode(item.RequestHost)); } - if (Utils.IsNotEmpty(item.path)) + if (Utils.IsNotEmpty(item.Path)) { - dicQuery.Add("path", Utils.UrlEncode(item.path)); + dicQuery.Add("path", Utils.UrlEncode(item.Path)); } break; case nameof(ETransport.http): case nameof(ETransport.h2): dicQuery["type"] = nameof(ETransport.http); - if (Utils.IsNotEmpty(item.requestHost)) + if (Utils.IsNotEmpty(item.RequestHost)) { - dicQuery.Add("host", Utils.UrlEncode(item.requestHost)); + dicQuery.Add("host", Utils.UrlEncode(item.RequestHost)); } - if (Utils.IsNotEmpty(item.path)) + if (Utils.IsNotEmpty(item.Path)) { - dicQuery.Add("path", Utils.UrlEncode(item.path)); + dicQuery.Add("path", Utils.UrlEncode(item.Path)); } break; case nameof(ETransport.quic): - dicQuery.Add("headerType", Utils.IsNotEmpty(item.headerType) ? item.headerType : Global.None); - dicQuery.Add("quicSecurity", Utils.UrlEncode(item.requestHost)); - dicQuery.Add("key", Utils.UrlEncode(item.path)); + dicQuery.Add("headerType", Utils.IsNotEmpty(item.HeaderType) ? item.HeaderType : Global.None); + dicQuery.Add("quicSecurity", Utils.UrlEncode(item.RequestHost)); + dicQuery.Add("key", Utils.UrlEncode(item.Path)); break; case nameof(ETransport.grpc): - if (Utils.IsNotEmpty(item.path)) + if (Utils.IsNotEmpty(item.Path)) { - dicQuery.Add("authority", Utils.UrlEncode(item.requestHost)); - dicQuery.Add("serviceName", Utils.UrlEncode(item.path)); - if (item.headerType is Global.GrpcGunMode or Global.GrpcMultiMode) + dicQuery.Add("authority", Utils.UrlEncode(item.RequestHost)); + dicQuery.Add("serviceName", Utils.UrlEncode(item.Path)); + if (item.HeaderType is Global.GrpcGunMode or Global.GrpcMultiMode) { - dicQuery.Add("mode", Utils.UrlEncode(item.headerType)); + dicQuery.Add("mode", Utils.UrlEncode(item.HeaderType)); } } break; @@ -130,54 +130,54 @@ namespace ServiceLib.Handler.Fmt protected static int ResolveStdTransport(NameValueCollection query, ref ProfileItem item) { - item.flow = query["flow"] ?? ""; - item.streamSecurity = query["security"] ?? ""; - item.sni = query["sni"] ?? ""; - item.alpn = Utils.UrlDecode(query["alpn"] ?? ""); - item.fingerprint = Utils.UrlDecode(query["fp"] ?? ""); - item.publicKey = Utils.UrlDecode(query["pbk"] ?? ""); - item.shortId = Utils.UrlDecode(query["sid"] ?? ""); - item.spiderX = Utils.UrlDecode(query["spx"] ?? ""); - item.allowInsecure = (query["allowInsecure"] ?? "") == "1" ? "true" : ""; + item.Flow = query["flow"] ?? ""; + item.StreamSecurity = query["security"] ?? ""; + item.Sni = query["sni"] ?? ""; + item.Alpn = Utils.UrlDecode(query["alpn"] ?? ""); + item.Fingerprint = Utils.UrlDecode(query["fp"] ?? ""); + item.PublicKey = Utils.UrlDecode(query["pbk"] ?? ""); + item.ShortId = Utils.UrlDecode(query["sid"] ?? ""); + item.SpiderX = Utils.UrlDecode(query["spx"] ?? ""); + item.AllowInsecure = (query["allowInsecure"] ?? "") == "1" ? "true" : ""; - item.network = query["type"] ?? nameof(ETransport.tcp); - switch (item.network) + item.Network = query["type"] ?? nameof(ETransport.tcp); + switch (item.Network) { case nameof(ETransport.tcp): - item.headerType = query["headerType"] ?? Global.None; - item.requestHost = Utils.UrlDecode(query["host"] ?? ""); + item.HeaderType = query["headerType"] ?? Global.None; + item.RequestHost = Utils.UrlDecode(query["host"] ?? ""); break; case nameof(ETransport.kcp): - item.headerType = query["headerType"] ?? Global.None; - item.path = Utils.UrlDecode(query["seed"] ?? ""); + item.HeaderType = query["headerType"] ?? Global.None; + item.Path = Utils.UrlDecode(query["seed"] ?? ""); break; case nameof(ETransport.ws): case nameof(ETransport.httpupgrade): case nameof(ETransport.splithttp): - item.requestHost = Utils.UrlDecode(query["host"] ?? ""); - item.path = Utils.UrlDecode(query["path"] ?? "/"); + item.RequestHost = Utils.UrlDecode(query["host"] ?? ""); + item.Path = Utils.UrlDecode(query["path"] ?? "/"); break; case nameof(ETransport.http): case nameof(ETransport.h2): - item.network = nameof(ETransport.h2); - item.requestHost = Utils.UrlDecode(query["host"] ?? ""); - item.path = Utils.UrlDecode(query["path"] ?? "/"); + item.Network = nameof(ETransport.h2); + item.RequestHost = Utils.UrlDecode(query["host"] ?? ""); + item.Path = Utils.UrlDecode(query["path"] ?? "/"); break; case nameof(ETransport.quic): - item.headerType = query["headerType"] ?? Global.None; - item.requestHost = query["quicSecurity"] ?? Global.None; - item.path = Utils.UrlDecode(query["key"] ?? ""); + item.HeaderType = query["headerType"] ?? Global.None; + item.RequestHost = query["quicSecurity"] ?? Global.None; + item.Path = Utils.UrlDecode(query["key"] ?? ""); break; case nameof(ETransport.grpc): - item.requestHost = Utils.UrlDecode(query["authority"] ?? ""); - item.path = Utils.UrlDecode(query["serviceName"] ?? ""); - item.headerType = Utils.UrlDecode(query["mode"] ?? Global.GrpcGunMode); + item.RequestHost = Utils.UrlDecode(query["authority"] ?? ""); + item.Path = Utils.UrlDecode(query["serviceName"] ?? ""); + item.HeaderType = Utils.UrlDecode(query["mode"] ?? Global.GrpcGunMode); break; default: diff --git a/v2rayN/ServiceLib/Handler/Fmt/ClashFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/ClashFmt.cs index f68c2474..ed6faf37 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/ClashFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/ClashFmt.cs @@ -10,9 +10,9 @@ var profileItem = new ProfileItem { - coreType = ECoreType.mihomo, - address = fileName, - remarks = subRemarks ?? "clash_custom" + CoreType = ECoreType.mihomo, + Address = fileName, + Remarks = subRemarks ?? "clash_custom" }; return profileItem; } diff --git a/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs b/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs index 95742f77..4e95b129 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs @@ -6,7 +6,7 @@ { try { - var url = item.configType switch + var url = item.ConfigType switch { EConfigType.VMess => VmessFmt.ToUri(item), EConfigType.Shadowsocks => ShadowsocksFmt.ToUri(item), diff --git a/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs b/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs index 146d2d74..e6b155cb 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/Hysteria2Fmt.cs @@ -7,20 +7,20 @@ msg = ResUI.ConfigurationFormatIncorrect; ProfileItem item = new() { - configType = EConfigType.Hysteria2 + ConfigType = EConfigType.Hysteria2 }; Uri url = new(str); - item.address = url.IdnHost; - item.port = url.Port; - item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); - item.id = Utils.UrlDecode(url.UserInfo); + item.Address = url.IdnHost; + item.Port = url.Port; + item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); + item.Id = Utils.UrlDecode(url.UserInfo); var query = Utils.ParseQueryString(url.Query); ResolveStdTransport(query, ref item); - item.path = Utils.UrlDecode(query["obfs-password"] ?? ""); - item.allowInsecure = (query["insecure"] ?? "") == "1" ? "true" : "false"; + item.Path = Utils.UrlDecode(query["obfs-password"] ?? ""); + item.AllowInsecure = (query["insecure"] ?? "") == "1" ? "true" : "false"; return item; } @@ -31,27 +31,27 @@ string url = string.Empty; string remark = string.Empty; - if (Utils.IsNotEmpty(item.remarks)) + if (Utils.IsNotEmpty(item.Remarks)) { - remark = "#" + Utils.UrlEncode(item.remarks); + remark = "#" + Utils.UrlEncode(item.Remarks); } var dicQuery = new Dictionary(); - if (Utils.IsNotEmpty(item.sni)) + if (Utils.IsNotEmpty(item.Sni)) { - dicQuery.Add("sni", item.sni); + dicQuery.Add("sni", item.Sni); } - if (Utils.IsNotEmpty(item.alpn)) + if (Utils.IsNotEmpty(item.Alpn)) { - dicQuery.Add("alpn", Utils.UrlEncode(item.alpn)); + dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn)); } - if (Utils.IsNotEmpty(item.path)) + if (Utils.IsNotEmpty(item.Path)) { dicQuery.Add("obfs", "salamander"); - dicQuery.Add("obfs-password", Utils.UrlEncode(item.path)); + dicQuery.Add("obfs-password", Utils.UrlEncode(item.Path)); } - dicQuery.Add("insecure", item.allowInsecure.ToLower() == "true" ? "1" : "0"); + dicQuery.Add("insecure", item.AllowInsecure.ToLower() == "true" ? "1" : "0"); - return ToUri(EConfigType.Hysteria2, item.address, item.port, item.id, dicQuery, remark); + return ToUri(EConfigType.Hysteria2, item.Address, item.Port, item.Id, dicQuery, remark); } public static ProfileItem? ResolveFull(string strData, string? subRemarks) @@ -62,9 +62,9 @@ var profileItem = new ProfileItem { - coreType = ECoreType.hysteria, - address = fileName, - remarks = subRemarks ?? "hysteria_custom" + CoreType = ECoreType.hysteria, + Address = fileName, + Remarks = subRemarks ?? "hysteria_custom" }; return profileItem; } @@ -80,9 +80,9 @@ var profileItem = new ProfileItem { - coreType = ECoreType.hysteria2, - address = fileName, - remarks = subRemarks ?? "hysteria2_custom" + CoreType = ECoreType.hysteria2, + Address = fileName, + Remarks = subRemarks ?? "hysteria2_custom" }; return profileItem; } diff --git a/v2rayN/ServiceLib/Handler/Fmt/NaiveproxyFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/NaiveproxyFmt.cs index 325cf9b6..3846c3af 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/NaiveproxyFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/NaiveproxyFmt.cs @@ -10,9 +10,9 @@ var profileItem = new ProfileItem { - coreType = ECoreType.naiveproxy, - address = fileName, - remarks = subRemarks ?? "naiveproxy_custom" + CoreType = ECoreType.naiveproxy, + Address = fileName, + Remarks = subRemarks ?? "naiveproxy_custom" }; return profileItem; } diff --git a/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs index 57f8e1bc..39d4fd67 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs @@ -14,12 +14,12 @@ namespace ServiceLib.Handler.Fmt { return null; } - if (item.address.Length == 0 || item.port == 0 || item.security.Length == 0 || item.id.Length == 0) + if (item.Address.Length == 0 || item.Port == 0 || item.Security.Length == 0 || item.Id.Length == 0) { return null; } - item.configType = EConfigType.Shadowsocks; + item.ConfigType = EConfigType.Shadowsocks; return item; } @@ -30,9 +30,9 @@ namespace ServiceLib.Handler.Fmt string url = string.Empty; string remark = string.Empty; - if (Utils.IsNotEmpty(item.remarks)) + if (Utils.IsNotEmpty(item.Remarks)) { - remark = "#" + Utils.UrlEncode(item.remarks); + remark = "#" + Utils.UrlEncode(item.Remarks); } //url = string.Format("{0}:{1}@{2}:{3}", // item.security, @@ -41,8 +41,8 @@ namespace ServiceLib.Handler.Fmt // item.port); //url = Utile.Base64Encode(url); //new Sip002 - var pw = Utils.Base64Encode($"{item.security}:{item.id}"); - return ToUri(EConfigType.Shadowsocks, item.address, item.port, pw, null, remark); + var pw = Utils.Base64Encode($"{item.Security}:{item.Id}"); + return ToUri(EConfigType.Shadowsocks, item.Address, item.Port, pw, null, remark); } private static readonly Regex UrlFinder = new(@"ss://(?[A-Za-z0-9+-/=_]+)(?:#(?\S+))?", RegexOptions.IgnoreCase | RegexOptions.Compiled); @@ -59,7 +59,7 @@ namespace ServiceLib.Handler.Fmt var tag = match.Groups["tag"].Value; if (Utils.IsNotEmpty(tag)) { - item.remarks = Utils.UrlDecode(tag); + item.Remarks = Utils.UrlDecode(tag); } Match details; try @@ -72,10 +72,10 @@ namespace ServiceLib.Handler.Fmt } if (!details.Success) return null; - item.security = details.Groups["method"].Value; - item.id = details.Groups["password"].Value; - item.address = details.Groups["hostname"].Value; - item.port = Utils.ToInt(details.Groups["port"].Value); + item.Security = details.Groups["method"].Value; + item.Id = details.Groups["password"].Value; + item.Address = details.Groups["hostname"].Value; + item.Port = Utils.ToInt(details.Groups["port"].Value); return item; } @@ -92,9 +92,9 @@ namespace ServiceLib.Handler.Fmt } ProfileItem item = new() { - remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped), - address = parsedUrl.IdnHost, - port = parsedUrl.Port, + Remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped), + Address = parsedUrl.IdnHost, + Port = parsedUrl.Port, }; var rawUserInfo = Utils.UrlDecode(parsedUrl.UserInfo); //2022-blake3 @@ -105,8 +105,8 @@ namespace ServiceLib.Handler.Fmt { return null; } - item.security = userInfoParts[0]; - item.id = Utils.UrlDecode(userInfoParts[1]); + item.Security = userInfoParts[0]; + item.Id = Utils.UrlDecode(userInfoParts[1]); } else { @@ -117,8 +117,8 @@ namespace ServiceLib.Handler.Fmt { return null; } - item.security = userInfoParts[0]; - item.id = userInfoParts[1]; + item.Security = userInfoParts[0]; + item.Id = userInfoParts[1]; } var queryParameters = Utils.ParseQueryString(parsedUrl.Query); @@ -129,9 +129,9 @@ namespace ServiceLib.Handler.Fmt if (queryParameters["plugin"].Contains("obfs=http") && Utils.IsNotEmpty(obfsHost)) { obfsHost = obfsHost?.Replace("obfs-host=", ""); - item.network = Global.DefaultNetwork; - item.headerType = Global.TcpHeaderHttp; - item.requestHost = obfsHost ?? ""; + item.Network = Global.DefaultNetwork; + item.HeaderType = Global.TcpHeaderHttp; + item.RequestHost = obfsHost ?? ""; } else { @@ -162,11 +162,11 @@ namespace ServiceLib.Handler.Fmt { var ssItem = new ProfileItem() { - remarks = it.remarks, - security = it.method, - id = it.password, - address = it.server, - port = Utils.ToInt(it.server_port) + Remarks = it.remarks, + Security = it.method, + Id = it.password, + Address = it.server, + Port = Utils.ToInt(it.server_port) }; lst.Add(ssItem); } diff --git a/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs index c6d4ad78..e3540872 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/SingboxFmt.cs @@ -20,9 +20,9 @@ var profileIt = new ProfileItem { - coreType = ECoreType.sing_box, - address = fileName, - remarks = subRemarks ?? "singbox_custom", + CoreType = ECoreType.sing_box, + Address = fileName, + Remarks = subRemarks ?? "singbox_custom", }; lstResult.Add(profileIt); } @@ -42,9 +42,9 @@ var fileName = WriteAllText(strData); var profileItem = new ProfileItem { - coreType = ECoreType.sing_box, - address = fileName, - remarks = subRemarks ?? "singbox_custom" + CoreType = ECoreType.sing_box, + Address = fileName, + Remarks = subRemarks ?? "singbox_custom" }; return profileItem; diff --git a/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs index cbf24fcc..1159dfe4 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs @@ -12,12 +12,12 @@ { return null; } - if (item.address.Length == 0 || item.port == 0) + if (item.Address.Length == 0 || item.Port == 0) { return null; } - item.configType = EConfigType.SOCKS; + item.ConfigType = EConfigType.SOCKS; return item; } @@ -28,9 +28,9 @@ string url = string.Empty; string remark = string.Empty; - if (Utils.IsNotEmpty(item.remarks)) + if (Utils.IsNotEmpty(item.Remarks)) { - remark = "#" + Utils.UrlEncode(item.remarks); + remark = "#" + Utils.UrlEncode(item.Remarks); } //url = string.Format("{0}:{1}@{2}:{3}", // item.security, @@ -39,15 +39,15 @@ // item.port); //url = Utile.Base64Encode(url); //new - var pw = Utils.Base64Encode($"{item.security}:{item.id}"); - return ToUri(EConfigType.SOCKS, item.address, item.port, pw, null, remark); + var pw = Utils.Base64Encode($"{item.Security}:{item.Id}"); + return ToUri(EConfigType.SOCKS, item.Address, item.Port, pw, null, remark); } private static ProfileItem? ResolveSocks(string result) { ProfileItem item = new() { - configType = EConfigType.SOCKS + ConfigType = EConfigType.SOCKS }; result = result[Global.ProtocolShares[EConfigType.SOCKS].Length..]; //remark @@ -56,7 +56,7 @@ { try { - item.remarks = Utils.UrlDecode(result.Substring(indexRemark + 1, result.Length - indexRemark - 1)); + item.Remarks = Utils.UrlDecode(result.Substring(indexRemark + 1, result.Length - indexRemark - 1)); } catch { } result = result[..indexRemark]; @@ -83,10 +83,10 @@ { return null; } - item.address = arr1[1][..indexPort]; - item.port = Utils.ToInt(arr1[1][(indexPort + 1)..]); - item.security = arr21[0]; - item.id = arr21[1]; + item.Address = arr1[1][..indexPort]; + item.Port = Utils.ToInt(arr1[1][(indexPort + 1)..]); + item.Security = arr21[0]; + item.Id = arr21[1]; return item; } @@ -104,9 +104,9 @@ } ProfileItem item = new() { - remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped), - address = parsedUrl.IdnHost, - port = parsedUrl.Port, + Remarks = parsedUrl.GetComponents(UriComponents.Fragment, UriFormat.Unescaped), + Address = parsedUrl.IdnHost, + Port = parsedUrl.Port, }; // parse base64 UserInfo @@ -115,8 +115,8 @@ var userInfoParts = userInfo.Split(new[] { ':' }, 2); if (userInfoParts.Length == 2) { - item.security = userInfoParts[0]; - item.id = userInfoParts[1]; + item.Security = userInfoParts[0]; + item.Id = userInfoParts[1]; } return item; diff --git a/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs index 129ba9f3..e098a4f6 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/TrojanFmt.cs @@ -8,15 +8,15 @@ ProfileItem item = new() { - configType = EConfigType.Trojan + ConfigType = EConfigType.Trojan }; Uri url = new(str); - item.address = url.IdnHost; - item.port = url.Port; - item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); - item.id = Utils.UrlDecode(url.UserInfo); + item.Address = url.IdnHost; + item.Port = url.Port; + item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); + item.Id = Utils.UrlDecode(url.UserInfo); var query = Utils.ParseQueryString(url.Query); ResolveStdTransport(query, ref item); @@ -30,14 +30,14 @@ string url = string.Empty; string remark = string.Empty; - if (Utils.IsNotEmpty(item.remarks)) + if (Utils.IsNotEmpty(item.Remarks)) { - remark = "#" + Utils.UrlEncode(item.remarks); + remark = "#" + Utils.UrlEncode(item.Remarks); } var dicQuery = new Dictionary(); GetStdTransport(item, null, ref dicQuery); - return ToUri(EConfigType.Trojan, item.address, item.port, item.id, dicQuery, remark); + return ToUri(EConfigType.Trojan, item.Address, item.Port, item.Id, dicQuery, remark); } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs index e8da3ada..6e357e40 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/TuicFmt.cs @@ -8,25 +8,25 @@ ProfileItem item = new() { - configType = EConfigType.TUIC + ConfigType = EConfigType.TUIC }; Uri url = new(str); - item.address = url.IdnHost; - item.port = url.Port; - item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); + item.Address = url.IdnHost; + item.Port = url.Port; + item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); var rawUserInfo = Utils.UrlDecode(url.UserInfo); var userInfoParts = rawUserInfo.Split(new[] { ':' }, 2); if (userInfoParts.Length == 2) { - item.id = userInfoParts[0]; - item.security = userInfoParts[1]; + item.Id = userInfoParts[0]; + item.Security = userInfoParts[1]; } var query = Utils.ParseQueryString(url.Query); ResolveStdTransport(query, ref item); - item.headerType = query["congestion_control"] ?? ""; + item.HeaderType = query["congestion_control"] ?? ""; return item; } @@ -37,22 +37,22 @@ string url = string.Empty; string remark = string.Empty; - if (Utils.IsNotEmpty(item.remarks)) + if (Utils.IsNotEmpty(item.Remarks)) { - remark = "#" + Utils.UrlEncode(item.remarks); + remark = "#" + Utils.UrlEncode(item.Remarks); } var dicQuery = new Dictionary(); - if (Utils.IsNotEmpty(item.sni)) + if (Utils.IsNotEmpty(item.Sni)) { - dicQuery.Add("sni", item.sni); + dicQuery.Add("sni", item.Sni); } - if (Utils.IsNotEmpty(item.alpn)) + if (Utils.IsNotEmpty(item.Alpn)) { - dicQuery.Add("alpn", Utils.UrlEncode(item.alpn)); + dicQuery.Add("alpn", Utils.UrlEncode(item.Alpn)); } - dicQuery.Add("congestion_control", item.headerType); + dicQuery.Add("congestion_control", item.HeaderType); - return ToUri(EConfigType.TUIC, item.address, item.port, $"{item.id}:{item.security}", dicQuery, remark); + return ToUri(EConfigType.TUIC, item.Address, item.Port, $"{item.Id}:{item.Security}", dicQuery, remark); } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs index 770166e1..cc2ec7bf 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/V2rayFmt.cs @@ -20,9 +20,9 @@ var profileIt = new ProfileItem { - coreType = ECoreType.Xray, - address = fileName, - remarks = v2rayCon.remarks ?? subRemarks ?? "v2ray_custom", + CoreType = ECoreType.Xray, + Address = fileName, + Remarks = v2rayCon.remarks ?? subRemarks ?? "v2ray_custom", }; lstResult.Add(profileIt); } @@ -43,9 +43,9 @@ var profileItem = new ProfileItem { - coreType = ECoreType.Xray, - address = fileName, - remarks = v2rayConfig.remarks ?? subRemarks ?? "v2ray_custom" + CoreType = ECoreType.Xray, + Address = fileName, + Remarks = v2rayConfig.remarks ?? subRemarks ?? "v2ray_custom" }; return profileItem; diff --git a/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs index aa26af15..f699d320 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/VLESSFmt.cs @@ -8,20 +8,20 @@ ProfileItem item = new() { - configType = EConfigType.VLESS, - security = Global.None + ConfigType = EConfigType.VLESS, + Security = Global.None }; Uri url = new(str); - item.address = url.IdnHost; - item.port = url.Port; - item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); - item.id = Utils.UrlDecode(url.UserInfo); + item.Address = url.IdnHost; + item.Port = url.Port; + item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); + item.Id = Utils.UrlDecode(url.UserInfo); var query = Utils.ParseQueryString(url.Query); - item.security = query["encryption"] ?? Global.None; - item.streamSecurity = query["security"] ?? ""; + item.Security = query["encryption"] ?? Global.None; + item.StreamSecurity = query["security"] ?? ""; ResolveStdTransport(query, ref item); return item; @@ -33,14 +33,14 @@ string url = string.Empty; string remark = string.Empty; - if (Utils.IsNotEmpty(item.remarks)) + if (Utils.IsNotEmpty(item.Remarks)) { - remark = "#" + Utils.UrlEncode(item.remarks); + remark = "#" + Utils.UrlEncode(item.Remarks); } var dicQuery = new Dictionary(); - if (Utils.IsNotEmpty(item.security)) + if (Utils.IsNotEmpty(item.Security)) { - dicQuery.Add("encryption", item.security); + dicQuery.Add("encryption", item.Security); } else { @@ -48,7 +48,7 @@ } GetStdTransport(item, Global.None, ref dicQuery); - return ToUri(EConfigType.VLESS, item.address, item.port, item.id, dicQuery, remark); + return ToUri(EConfigType.VLESS, item.Address, item.Port, item.Id, dicQuery, remark); } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs index 4d81b650..fe3e9fa4 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/VmessFmt.cs @@ -24,21 +24,21 @@ VmessQRCode vmessQRCode = new() { - v = item.configVersion, - ps = item.remarks.TrimEx(), - add = item.address, - port = item.port, - id = item.id, - aid = item.alterId, - scy = item.security, - net = item.network, - type = item.headerType, - host = item.requestHost, - path = item.path, - tls = item.streamSecurity, - sni = item.sni, - alpn = item.alpn, - fp = item.fingerprint + v = item.ConfigVersion, + ps = item.Remarks.TrimEx(), + add = item.Address, + port = item.Port, + id = item.Id, + aid = item.AlterId, + scy = item.Security, + net = item.Network, + type = item.HeaderType, + host = item.RequestHost, + path = item.Path, + tls = item.StreamSecurity, + sni = item.Sni, + alpn = item.Alpn, + fp = item.Fingerprint }; url = JsonUtils.Serialize(vmessQRCode); @@ -53,7 +53,7 @@ msg = string.Empty; var item = new ProfileItem { - configType = EConfigType.VMess + ConfigType = EConfigType.VMess }; result = result[Global.ProtocolShares[EConfigType.VMess].Length..]; @@ -66,33 +66,33 @@ return null; } - item.network = Global.DefaultNetwork; - item.headerType = Global.None; + item.Network = Global.DefaultNetwork; + item.HeaderType = Global.None; - item.configVersion = vmessQRCode.v; - item.remarks = Utils.ToString(vmessQRCode.ps); - item.address = Utils.ToString(vmessQRCode.add); - item.port = vmessQRCode.port; - item.id = Utils.ToString(vmessQRCode.id); - item.alterId = vmessQRCode.aid; - item.security = Utils.ToString(vmessQRCode.scy); + item.ConfigVersion = vmessQRCode.v; + item.Remarks = Utils.ToString(vmessQRCode.ps); + item.Address = Utils.ToString(vmessQRCode.add); + item.Port = vmessQRCode.port; + item.Id = Utils.ToString(vmessQRCode.id); + item.AlterId = vmessQRCode.aid; + item.Security = Utils.ToString(vmessQRCode.scy); - item.security = Utils.IsNotEmpty(vmessQRCode.scy) ? vmessQRCode.scy : Global.DefaultSecurity; + item.Security = Utils.IsNotEmpty(vmessQRCode.scy) ? vmessQRCode.scy : Global.DefaultSecurity; if (Utils.IsNotEmpty(vmessQRCode.net)) { - item.network = vmessQRCode.net; + item.Network = vmessQRCode.net; } if (Utils.IsNotEmpty(vmessQRCode.type)) { - item.headerType = vmessQRCode.type; + item.HeaderType = vmessQRCode.type; } - item.requestHost = Utils.ToString(vmessQRCode.host); - item.path = Utils.ToString(vmessQRCode.path); - item.streamSecurity = Utils.ToString(vmessQRCode.tls); - item.sni = Utils.ToString(vmessQRCode.sni); - item.alpn = Utils.ToString(vmessQRCode.alpn); - item.fingerprint = Utils.ToString(vmessQRCode.fp); + item.RequestHost = Utils.ToString(vmessQRCode.host); + item.Path = Utils.ToString(vmessQRCode.path); + item.StreamSecurity = Utils.ToString(vmessQRCode.tls); + item.Sni = Utils.ToString(vmessQRCode.sni); + item.Alpn = Utils.ToString(vmessQRCode.alpn); + item.Fingerprint = Utils.ToString(vmessQRCode.fp); return item; } @@ -101,16 +101,16 @@ { ProfileItem item = new() { - configType = EConfigType.VMess, - security = "auto" + ConfigType = EConfigType.VMess, + Security = "auto" }; Uri url = new(str); - item.address = url.IdnHost; - item.port = url.Port; - item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); - item.id = Utils.UrlDecode(url.UserInfo); + item.Address = url.IdnHost; + item.Port = url.Port; + item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); + item.Id = Utils.UrlDecode(url.UserInfo); var query = Utils.ParseQueryString(url.Query); ResolveStdTransport(query, ref item); diff --git a/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs index b6c980a0..285ddb32 100644 --- a/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs +++ b/v2rayN/ServiceLib/Handler/Fmt/WireguardFmt.cs @@ -8,22 +8,22 @@ ProfileItem item = new() { - configType = EConfigType.WireGuard + ConfigType = EConfigType.WireGuard }; Uri url = new(str); - item.address = url.IdnHost; - item.port = url.Port; - item.remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); - item.id = Utils.UrlDecode(url.UserInfo); + item.Address = url.IdnHost; + item.Port = url.Port; + item.Remarks = url.GetComponents(UriComponents.Fragment, UriFormat.Unescaped); + item.Id = Utils.UrlDecode(url.UserInfo); var query = Utils.ParseQueryString(url.Query); - item.publicKey = Utils.UrlDecode(query["publickey"] ?? ""); - item.path = Utils.UrlDecode(query["reserved"] ?? ""); - item.requestHost = Utils.UrlDecode(query["address"] ?? ""); - item.shortId = Utils.UrlDecode(query["mtu"] ?? ""); + item.PublicKey = Utils.UrlDecode(query["publickey"] ?? ""); + item.Path = Utils.UrlDecode(query["reserved"] ?? ""); + item.RequestHost = Utils.UrlDecode(query["address"] ?? ""); + item.ShortId = Utils.UrlDecode(query["mtu"] ?? ""); return item; } @@ -34,29 +34,29 @@ string url = string.Empty; string remark = string.Empty; - if (Utils.IsNotEmpty(item.remarks)) + if (Utils.IsNotEmpty(item.Remarks)) { - remark = "#" + Utils.UrlEncode(item.remarks); + remark = "#" + Utils.UrlEncode(item.Remarks); } var dicQuery = new Dictionary(); - if (Utils.IsNotEmpty(item.publicKey)) + if (Utils.IsNotEmpty(item.PublicKey)) { - dicQuery.Add("publickey", Utils.UrlEncode(item.publicKey)); + dicQuery.Add("publickey", Utils.UrlEncode(item.PublicKey)); } - if (Utils.IsNotEmpty(item.path)) + if (Utils.IsNotEmpty(item.Path)) { - dicQuery.Add("reserved", Utils.UrlEncode(item.path)); + dicQuery.Add("reserved", Utils.UrlEncode(item.Path)); } - if (Utils.IsNotEmpty(item.requestHost)) + if (Utils.IsNotEmpty(item.RequestHost)) { - dicQuery.Add("address", Utils.UrlEncode(item.requestHost)); + dicQuery.Add("address", Utils.UrlEncode(item.RequestHost)); } - if (Utils.IsNotEmpty(item.shortId)) + if (Utils.IsNotEmpty(item.ShortId)) { - dicQuery.Add("mtu", Utils.UrlEncode(item.shortId)); + dicQuery.Add("mtu", Utils.UrlEncode(item.ShortId)); } - return ToUri(EConfigType.WireGuard, item.address, item.port, item.id, dicQuery, remark); + return ToUri(EConfigType.WireGuard, item.Address, item.Port, item.Id, dicQuery, remark); } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Handler/ProfileExHandler.cs b/v2rayN/ServiceLib/Handler/ProfileExHandler.cs index 6503cc7c..3d52f930 100644 --- a/v2rayN/ServiceLib/Handler/ProfileExHandler.cs +++ b/v2rayN/ServiceLib/Handler/ProfileExHandler.cs @@ -57,8 +57,8 @@ namespace ServiceLib.Handler for (int i = 0; i < cnt; i++) { var id = _queIndexIds.Dequeue(); - var item = lstExists.FirstOrDefault(t => t.indexId == id); - var itemNew = _lstProfileEx?.FirstOrDefault(t => t.indexId == id); + var item = lstExists.FirstOrDefault(t => t.IndexId == id); + var itemNew = _lstProfileEx?.FirstOrDefault(t => t.IndexId == id); if (itemNew is null) { continue; @@ -92,10 +92,10 @@ namespace ServiceLib.Handler { profileEx = new() { - indexId = indexId, - delay = 0, - speed = 0, - sort = 0 + IndexId = indexId, + Delay = 0, + Speed = 0, + Sort = 0 }; _lstProfileEx.Add(profileEx); IndexIdEnqueue(indexId); @@ -121,49 +121,49 @@ namespace ServiceLib.Handler public void SetTestDelay(string indexId, string delayVal) { - var profileEx = _lstProfileEx.FirstOrDefault(t => t.indexId == indexId); + var profileEx = _lstProfileEx.FirstOrDefault(t => t.IndexId == indexId); if (profileEx == null) { AddProfileEx(indexId, ref profileEx); } int.TryParse(delayVal, out int delay); - profileEx.delay = delay; + profileEx.Delay = delay; IndexIdEnqueue(indexId); } public void SetTestSpeed(string indexId, string speedVal) { - var profileEx = _lstProfileEx.FirstOrDefault(t => t.indexId == indexId); + var profileEx = _lstProfileEx.FirstOrDefault(t => t.IndexId == indexId); if (profileEx == null) { AddProfileEx(indexId, ref profileEx); } decimal.TryParse(speedVal, out decimal speed); - profileEx.speed = speed; + profileEx.Speed = speed; IndexIdEnqueue(indexId); } public void SetSort(string indexId, int sort) { - var profileEx = _lstProfileEx.FirstOrDefault(t => t.indexId == indexId); + var profileEx = _lstProfileEx.FirstOrDefault(t => t.IndexId == indexId); if (profileEx == null) { AddProfileEx(indexId, ref profileEx); } - profileEx.sort = sort; + profileEx.Sort = sort; IndexIdEnqueue(indexId); } public int GetSort(string indexId) { - var profileEx = _lstProfileEx.FirstOrDefault(t => t.indexId == indexId); + var profileEx = _lstProfileEx.FirstOrDefault(t => t.IndexId == indexId); if (profileEx == null) { return 0; } - return profileEx.sort; + return profileEx.Sort; } public int GetMaxSort() @@ -172,7 +172,7 @@ namespace ServiceLib.Handler { return 0; } - return _lstProfileEx.Max(t => t == null ? 0 : t.sort); + return _lstProfileEx.Max(t => t == null ? 0 : t.Sort); } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs index 3cb55f47..6a631a7d 100644 --- a/v2rayN/ServiceLib/Handler/StatisticsHandler.cs +++ b/v2rayN/ServiceLib/Handler/StatisticsHandler.cs @@ -89,52 +89,52 @@ } if (server.proxyUp != 0 || server.proxyDown != 0) { - _serverStatItem.todayUp += server.proxyUp; - _serverStatItem.todayDown += server.proxyDown; - _serverStatItem.totalUp += server.proxyUp; - _serverStatItem.totalDown += server.proxyDown; + _serverStatItem.TodayUp += server.proxyUp; + _serverStatItem.TodayDown += server.proxyDown; + _serverStatItem.TotalUp += server.proxyUp; + _serverStatItem.TotalDown += server.proxyDown; } - server.indexId = _config.IndexId; - server.todayUp = _serverStatItem.todayUp; - server.todayDown = _serverStatItem.todayDown; - server.totalUp = _serverStatItem.totalUp; - server.totalDown = _serverStatItem.totalDown; + server.IndexId = _config.IndexId; + server.TodayUp = _serverStatItem.TodayUp; + server.TodayDown = _serverStatItem.TodayDown; + server.TotalUp = _serverStatItem.TotalUp; + server.TotalDown = _serverStatItem.TotalDown; _updateFunc?.Invoke(server); } private async Task GetServerStatItem(string indexId) { long ticks = DateTime.Now.Date.Ticks; - if (_serverStatItem != null && _serverStatItem.indexId != indexId) + if (_serverStatItem != null && _serverStatItem.IndexId != indexId) { _serverStatItem = null; } if (_serverStatItem == null) { - _serverStatItem = _lstServerStat.FirstOrDefault(t => t.indexId == indexId); + _serverStatItem = _lstServerStat.FirstOrDefault(t => t.IndexId == indexId); if (_serverStatItem == null) { _serverStatItem = new ServerStatItem { - indexId = indexId, - totalUp = 0, - totalDown = 0, - todayUp = 0, - todayDown = 0, - dateNow = ticks + IndexId = indexId, + TotalUp = 0, + TotalDown = 0, + TodayUp = 0, + TodayDown = 0, + DateNow = ticks }; await SQLiteHelper.Instance.ReplaceAsync(_serverStatItem); _lstServerStat.Add(_serverStatItem); } } - if (_serverStatItem.dateNow != ticks) + if (_serverStatItem.DateNow != ticks) { - _serverStatItem.todayUp = 0; - _serverStatItem.todayDown = 0; - _serverStatItem.dateNow = ticks; + _serverStatItem.TodayUp = 0; + _serverStatItem.TodayDown = 0; + _serverStatItem.DateNow = ticks; } } } diff --git a/v2rayN/ServiceLib/Handler/TaskHandler.cs b/v2rayN/ServiceLib/Handler/TaskHandler.cs index 2fef0c50..3d04a33d 100644 --- a/v2rayN/ServiceLib/Handler/TaskHandler.cs +++ b/v2rayN/ServiceLib/Handler/TaskHandler.cs @@ -21,19 +21,19 @@ { var updateTime = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds(); var lstSubs = (await AppHandler.Instance.SubItems()) - .Where(t => t.autoUpdateInterval > 0) - .Where(t => updateTime - t.updateTime >= t.autoUpdateInterval * 60) + .Where(t => t.AutoUpdateInterval > 0) + .Where(t => updateTime - t.UpdateTime >= t.AutoUpdateInterval * 60) .ToList(); foreach (var item in lstSubs) { - await updateHandle.UpdateSubscriptionProcess(config, item.id, true, (bool success, string msg) => + await updateHandle.UpdateSubscriptionProcess(config, item.Id, true, (bool success, string msg) => { updateFunc?.Invoke(success, msg); if (success) Logging.SaveLog("subscription" + msg); }); - item.updateTime = updateTime; + item.UpdateTime = updateTime; await ConfigHandler.AddSubItem(config, item); await Task.Delay(5000); diff --git a/v2rayN/ServiceLib/Models/ClashProxyModel.cs b/v2rayN/ServiceLib/Models/ClashProxyModel.cs index d3a9e0b0..8f5936da 100644 --- a/v2rayN/ServiceLib/Models/ClashProxyModel.cs +++ b/v2rayN/ServiceLib/Models/ClashProxyModel.cs @@ -13,6 +13,6 @@ public string? delayName { get; set; } - public bool isActive { get; set; } + public bool IsActive { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/ConfigItems.cs b/v2rayN/ServiceLib/Models/ConfigItems.cs index aea3eab9..42333bce 100644 --- a/v2rayN/ServiceLib/Models/ConfigItems.cs +++ b/v2rayN/ServiceLib/Models/ConfigItems.cs @@ -62,10 +62,10 @@ [Serializable] public class GrpcItem { - public int IdleTimeout { get; set; } - public int HealthCheckTimeout { get; set; } - public bool PermitWithoutStream { get; set; } - public int InitialWindowsSize { get; set; } + public int? IdleTimeout { get; set; } + public int? HealthCheckTimeout { get; set; } + public bool? PermitWithoutStream { get; set; } + public int? InitialWindowsSize { get; set; } } [Serializable] diff --git a/v2rayN/ServiceLib/Models/DNSItem.cs b/v2rayN/ServiceLib/Models/DNSItem.cs index d40bad55..44acb4fb 100644 --- a/v2rayN/ServiceLib/Models/DNSItem.cs +++ b/v2rayN/ServiceLib/Models/DNSItem.cs @@ -6,15 +6,15 @@ namespace ServiceLib.Models public class DNSItem { [PrimaryKey] - public string id { get; set; } + public string Id { get; set; } - public string remarks { get; set; } - public bool enabled { get; set; } = true; - public ECoreType coreType { get; set; } - public bool useSystemHosts { get; set; } - public string? normalDNS { get; set; } - public string? tunDNS { get; set; } - public string? domainStrategy4Freedom { get; set; } - public string? domainDNSAddress { get; set; } + public string Remarks { get; set; } + public bool Enabled { get; set; } = true; + public ECoreType CoreType { get; set; } + public bool UseSystemHosts { get; set; } + public string? NormalDNS { get; set; } + public string? TunDNS { get; set; } + public string? DomainStrategy4Freedom { get; set; } + public string? DomainDNSAddress { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/ProfileExItem.cs b/v2rayN/ServiceLib/Models/ProfileExItem.cs index ba3f97c2..afa7918d 100644 --- a/v2rayN/ServiceLib/Models/ProfileExItem.cs +++ b/v2rayN/ServiceLib/Models/ProfileExItem.cs @@ -6,10 +6,10 @@ namespace ServiceLib.Models public class ProfileExItem { [PrimaryKey] - public string indexId { get; set; } + public string IndexId { get; set; } - public int delay { get; set; } - public decimal speed { get; set; } - public int sort { get; set; } + public int Delay { get; set; } + public decimal Speed { get; set; } + public int Sort { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/ProfileItem.cs b/v2rayN/ServiceLib/Models/ProfileItem.cs index 954f491b..b6e9aa6a 100644 --- a/v2rayN/ServiceLib/Models/ProfileItem.cs +++ b/v2rayN/ServiceLib/Models/ProfileItem.cs @@ -7,31 +7,31 @@ namespace ServiceLib.Models { public ProfileItem() { - indexId = string.Empty; - configType = EConfigType.VMess; - configVersion = 2; - address = string.Empty; - port = 0; - id = string.Empty; - alterId = 0; - security = string.Empty; - network = string.Empty; - remarks = string.Empty; - headerType = string.Empty; - requestHost = string.Empty; - path = string.Empty; - streamSecurity = string.Empty; - allowInsecure = string.Empty; - subid = string.Empty; - flow = string.Empty; + IndexId = string.Empty; + ConfigType = EConfigType.VMess; + ConfigVersion = 2; + Address = string.Empty; + Port = 0; + Id = string.Empty; + AlterId = 0; + Security = string.Empty; + Network = string.Empty; + Remarks = string.Empty; + HeaderType = string.Empty; + RequestHost = string.Empty; + Path = string.Empty; + StreamSecurity = string.Empty; + AllowInsecure = string.Empty; + Subid = string.Empty; + Flow = string.Empty; } #region function public string GetSummary() { - string summary = string.Format("[{0}] ", (configType).ToString()); - string[] arrAddr = address.Split('.'); + string summary = string.Format("[{0}] ", (ConfigType).ToString()); + string[] arrAddr = Address.Split('.'); string addr; if (arrAddr.Length > 2) { @@ -43,16 +43,16 @@ namespace ServiceLib.Models } else { - addr = address; + addr = Address; } - switch (configType) + switch (ConfigType) { case EConfigType.Custom: - summary += string.Format("[{1}]{0}", remarks, coreType.ToString()); + summary += string.Format("[{1}]{0}", Remarks, CoreType.ToString()); break; default: - summary += string.Format("{0}({1}:{2})", remarks, addr, port); + summary += string.Format("{0}({1}:{2})", Remarks, addr, Port); break; } return summary; @@ -60,131 +60,55 @@ namespace ServiceLib.Models public List? GetAlpn() { - if (Utils.IsNullOrEmpty(alpn)) + if (Utils.IsNullOrEmpty(Alpn)) { return null; } else { - return Utils.String2List(alpn); + return Utils.String2List(Alpn); } } public string GetNetwork() { - if (Utils.IsNullOrEmpty(network) || !Global.Networks.Contains(network)) + if (Utils.IsNullOrEmpty(Network) || !Global.Networks.Contains(Network)) { return Global.DefaultNetwork; } - return network.TrimEx(); + return Network.TrimEx(); } #endregion function [PrimaryKey] - public string indexId { get; set; } + public string IndexId { get; set; } - /// - /// config type(1=normal,2=custom) - /// - public EConfigType configType { get; set; } - - /// - /// 版本(现在=2) - /// - public int configVersion { get; set; } - - /// - /// 远程服务器地址 - /// - public string address { get; set; } - - /// - /// 远程服务器端口 - /// - public int port { get; set; } - - /// - /// 远程服务器ID - /// - public string id { get; set; } - - /// - /// 远程服务器额外ID - /// - public int alterId { get; set; } - - /// - /// 本地安全策略 - /// - public string security { get; set; } - - /// - /// tcp,kcp,ws,h2,quic - /// - public string network { get; set; } - - /// - /// - /// - public string remarks { get; set; } - - /// - /// 伪装类型 - /// - public string headerType { get; set; } - - /// - /// 伪装的域名 - /// - public string requestHost { get; set; } - - /// - /// ws h2 path - /// - public string path { get; set; } - - /// - /// 传输层安全 - /// - public string streamSecurity { get; set; } - - /// - /// 是否允许不安全连接(用于客户端) - /// - public string allowInsecure { get; set; } - - /// - /// SubItem id - /// - public string subid { get; set; } - - public bool isSub { get; set; } = true; - - /// - /// VLESS flow - /// - public string flow { get; set; } - - /// - /// tls sni - /// - public string sni { get; set; } - - /// - /// tls alpn - /// - public string alpn { get; set; } = string.Empty; - - public ECoreType? coreType { get; set; } - - public int? preSocksPort { get; set; } - - public string fingerprint { get; set; } - - public bool displayLog { get; set; } = true; - public string publicKey { get; set; } - public string shortId { get; set; } - public string spiderX { get; set; } + public EConfigType ConfigType { get; set; } + public int ConfigVersion { get; set; } + public string Address { get; set; } + public int Port { get; set; } + public string Id { get; set; } + public int AlterId { get; set; } + public string Security { get; set; } + public string Network { get; set; } + public string Remarks { get; set; } + public string HeaderType { get; set; } + public string RequestHost { get; set; } + public string Path { get; set; } + public string StreamSecurity { get; set; } + public string AllowInsecure { get; set; } + public string Subid { get; set; } + public bool IsSub { get; set; } = true; + public string Flow { get; set; } + public string Sni { get; set; } + public string Alpn { get; set; } = string.Empty; + public ECoreType? CoreType { get; set; } + public int? PreSocksPort { get; set; } + public string Fingerprint { get; set; } + public bool DisplayLog { get; set; } = true; + public string PublicKey { get; set; } + public string ShortId { get; set; } + public string SpiderX { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/ProfileItemModel.cs b/v2rayN/ServiceLib/Models/ProfileItemModel.cs index 750a8d91..731316fe 100644 --- a/v2rayN/ServiceLib/Models/ProfileItemModel.cs +++ b/v2rayN/ServiceLib/Models/ProfileItemModel.cs @@ -3,16 +3,16 @@ [Serializable] public class ProfileItemModel : ProfileItem { - public bool isActive { get; set; } - public string subRemarks { get; set; } - public int delay { get; set; } - public decimal speed { get; set; } - public int sort { get; set; } - public string delayVal { get; set; } - public string speedVal { get; set; } - public string todayUp { get; set; } - public string todayDown { get; set; } - public string totalUp { get; set; } - public string totalDown { get; set; } + public bool IsActive { get; set; } + public string SubRemarks { get; set; } + public int Delay { get; set; } + public decimal Speed { get; set; } + public int Sort { get; set; } + public string DelayVal { get; set; } + public string SpeedVal { get; set; } + public string TodayUp { get; set; } + public string TodayDown { get; set; } + public string TotalUp { get; set; } + public string TotalDown { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/RoutingItem.cs b/v2rayN/ServiceLib/Models/RoutingItem.cs index 6f51821e..13e560cc 100644 --- a/v2rayN/ServiceLib/Models/RoutingItem.cs +++ b/v2rayN/ServiceLib/Models/RoutingItem.cs @@ -6,18 +6,17 @@ namespace ServiceLib.Models public class RoutingItem { [PrimaryKey] - public string id { get; set; } - - public string remarks { get; set; } - public string url { get; set; } - public string ruleSet { get; set; } - public int ruleNum { get; set; } - public bool enabled { get; set; } = true; - public bool locked { get; set; } - public string customIcon { get; set; } - public string customRulesetPath4Singbox { get; set; } - public string domainStrategy { get; set; } - public string domainStrategy4Singbox { get; set; } - public int sort { get; set; } + public string Id { get; set; } + public string Remarks { get; set; } + public string Url { get; set; } + public string RuleSet { get; set; } + public int RuleNum { get; set; } + public bool Enabled { get; set; } = true; + public bool Locked { get; set; } + public string CustomIcon { get; set; } + public string CustomRulesetPath4Singbox { get; set; } + public string DomainStrategy { get; set; } + public string DomainStrategy4Singbox { get; set; } + public int Sort { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/RoutingItemModel.cs b/v2rayN/ServiceLib/Models/RoutingItemModel.cs index 28461612..23dcab83 100644 --- a/v2rayN/ServiceLib/Models/RoutingItemModel.cs +++ b/v2rayN/ServiceLib/Models/RoutingItemModel.cs @@ -3,6 +3,6 @@ [Serializable] public class RoutingItemModel : RoutingItem { - public bool isActive { get; set; } + public bool IsActive { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/RulesItem.cs b/v2rayN/ServiceLib/Models/RulesItem.cs index 39ddd4ea..f7414593 100644 --- a/v2rayN/ServiceLib/Models/RulesItem.cs +++ b/v2rayN/ServiceLib/Models/RulesItem.cs @@ -13,7 +13,7 @@ public List? domain { get; set; } public List? protocol { get; set; } public List? process { get; set; } - public bool enabled { get; set; } = true; - public string? remarks { get; set; } + public bool Enabled { get; set; } = true; + public string? Remarks { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/RulesItemModel.cs b/v2rayN/ServiceLib/Models/RulesItemModel.cs index 0bbdb9cf..c11ccdd8 100644 --- a/v2rayN/ServiceLib/Models/RulesItemModel.cs +++ b/v2rayN/ServiceLib/Models/RulesItemModel.cs @@ -3,9 +3,9 @@ [Serializable] public class RulesItemModel : RulesItem { - public string inboundTags { get; set; } - public string ips { get; set; } - public string domains { get; set; } - public string protocols { get; set; } + public string InboundTags { get; set; } + public string Ips { get; set; } + public string Domains { get; set; } + public string Protocols { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/ServerStatItem.cs b/v2rayN/ServiceLib/Models/ServerStatItem.cs index 16939d1f..16f6695f 100644 --- a/v2rayN/ServiceLib/Models/ServerStatItem.cs +++ b/v2rayN/ServiceLib/Models/ServerStatItem.cs @@ -6,34 +6,16 @@ namespace ServiceLib.Models public class ServerStatItem { [PrimaryKey] - public string indexId - { - get; set; - } + public string IndexId { get; set; } - public long totalUp - { - get; set; - } + public long TotalUp { get; set; } - public long totalDown - { - get; set; - } + public long TotalDown { get; set; } - public long todayUp - { - get; set; - } + public long TodayUp { get; set; } - public long todayDown - { - get; set; - } + public long TodayDown { get; set; } - public long dateNow - { - get; set; - } + public long DateNow { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/SubItem.cs b/v2rayN/ServiceLib/Models/SubItem.cs index 4eb894b8..851733bf 100644 --- a/v2rayN/ServiceLib/Models/SubItem.cs +++ b/v2rayN/ServiceLib/Models/SubItem.cs @@ -6,32 +6,32 @@ namespace ServiceLib.Models public class SubItem { [PrimaryKey] - public string id { get; set; } + public string Id { get; set; } - public string remarks { get; set; } + public string Remarks { get; set; } - public string url { get; set; } + public string Url { get; set; } - public string moreUrl { get; set; } + public string MoreUrl { get; set; } - public bool enabled { get; set; } = true; + public bool Enabled { get; set; } = true; - public string userAgent { get; set; } = string.Empty; + public string UserAgent { get; set; } = string.Empty; - public int sort { get; set; } + public int Sort { get; set; } - public string? filter { get; set; } + public string? Filter { get; set; } - public int autoUpdateInterval { get; set; } + public int AutoUpdateInterval { get; set; } - public long updateTime { get; set; } + public long UpdateTime { get; set; } - public string? convertTarget { get; set; } + public string? ConvertTarget { get; set; } - public string? prevProfile { get; set; } + public string? PrevProfile { get; set; } - public string? nextProfile { get; set; } + public string? NextProfile { get; set; } - public int? preSocksPort { get; set; } + public int? PreSocksPort { get; set; } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/Models/V2rayConfig.cs b/v2rayN/ServiceLib/Models/V2rayConfig.cs index 28497719..4ea3c651 100644 --- a/v2rayN/ServiceLib/Models/V2rayConfig.cs +++ b/v2rayN/ServiceLib/Models/V2rayConfig.cs @@ -678,10 +678,10 @@ namespace ServiceLib.Models public string? authority { get; set; } public string? serviceName { get; set; } public bool multiMode { get; set; } - public int idle_timeout { get; set; } - public int health_check_timeout { get; set; } - public bool permit_without_stream { get; set; } - public int initial_windows_size { get; set; } + public int? idle_timeout { get; set; } + public int? health_check_timeout { get; set; } + public bool? permit_without_stream { get; set; } + public int? initial_windows_size { get; set; } } public class AccountsItem4Ray diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs index 05c42643..109f1cc1 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigClashService.cs @@ -43,7 +43,7 @@ File.Delete(fileName); } - string addressFileName = node.address; + string addressFileName = node.Address; if (Utils.IsNullOrEmpty(addressFileName)) { ret.Msg = ResUI.FailedGetDefaultConfiguration; diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs index 8d6d84ea..49ba6282 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigSingboxService.cs @@ -21,7 +21,7 @@ namespace ServiceLib.Services.CoreConfig try { if (node == null - || node.port <= 0) + || node.Port <= 0) { ret.Msg = ResUI.CheckServerSettings; return ret; @@ -137,7 +137,7 @@ namespace ServiceLib.Services.CoreConfig var item = await AppHandler.Instance.GetProfileItem(it.IndexId); if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS) { - if (item is null || Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id)) + if (item is null || Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id)) { continue; } @@ -184,19 +184,19 @@ namespace ServiceLib.Services.CoreConfig { continue; } - if (item.configType == EConfigType.Shadowsocks - && !Global.SsSecuritiesInSingbox.Contains(item.security)) + if (item.ConfigType == EConfigType.Shadowsocks + && !Global.SsSecuritiesInSingbox.Contains(item.Security)) { continue; } - if (item.configType == EConfigType.VLESS - && !Global.Flows.Contains(item.flow)) + if (item.ConfigType == EConfigType.VLESS + && !Global.Flows.Contains(item.Flow)) { continue; } if (it.ConfigType is EConfigType.VLESS or EConfigType.Trojan - && item.streamSecurity == Global.StreamSecurityReality - && item.publicKey.IsNullOrEmpty()) + && item.StreamSecurity == Global.StreamSecurityReality + && item.PublicKey.IsNullOrEmpty()) { continue; } @@ -278,32 +278,32 @@ namespace ServiceLib.Services.CoreConfig var tagProxy = new List(); foreach (var it in selecteds) { - if (it.configType == EConfigType.Custom) + if (it.ConfigType == EConfigType.Custom) { continue; } - if (it.port <= 0) + if (it.Port <= 0) { continue; } - var item = await AppHandler.Instance.GetProfileItem(it.indexId); + var item = await AppHandler.Instance.GetProfileItem(it.IndexId); if (item is null) { continue; } - if (it.configType is EConfigType.VMess or EConfigType.VLESS) + if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS) { - if (Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id)) + if (Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id)) { continue; } } - if (item.configType == EConfigType.Shadowsocks - && !Global.SsSecuritiesInSingbox.Contains(item.security)) + if (item.ConfigType == EConfigType.Shadowsocks + && !Global.SsSecuritiesInSingbox.Contains(item.Security)) { continue; } - if (item.configType == EConfigType.VLESS && !Global.Flows.Contains(item.flow)) + if (item.ConfigType == EConfigType.VLESS && !Global.Flows.Contains(item.Flow)) { continue; } @@ -381,7 +381,7 @@ namespace ServiceLib.Services.CoreConfig File.Delete(fileName); } - string addressFileName = node.address; + string addressFileName = node.Address; if (Utils.IsNullOrEmpty(addressFileName)) { ret.Msg = ResUI.FailedGetDefaultConfiguration; @@ -397,7 +397,7 @@ namespace ServiceLib.Services.CoreConfig return ret; } - if (node.address == Global.CoreMultipleLoadConfigFileName) + if (node.Address == Global.CoreMultipleLoadConfigFileName) { var txtFile = File.ReadAllText(addressFileName); var singboxConfig = JsonUtils.Deserialize(txtFile); @@ -502,9 +502,9 @@ namespace ServiceLib.Services.CoreConfig if (_config.RoutingBasicItem.EnableRoutingAdvanced) { var routing = await ConfigHandler.GetDefaultRouting(_config); - if (Utils.IsNotEmpty(routing.domainStrategy4Singbox)) + if (Utils.IsNotEmpty(routing.DomainStrategy4Singbox)) { - inbound.domain_strategy = routing.domainStrategy4Singbox; + inbound.domain_strategy = routing.DomainStrategy4Singbox; } } @@ -584,19 +584,19 @@ namespace ServiceLib.Services.CoreConfig { try { - outbound.server = node.address; - outbound.server_port = node.port; - outbound.type = Global.ProtocolTypes[node.configType]; + outbound.server = node.Address; + outbound.server_port = node.Port; + outbound.type = Global.ProtocolTypes[node.ConfigType]; - switch (node.configType) + switch (node.ConfigType) { case EConfigType.VMess: { - outbound.uuid = node.id; - outbound.alter_id = node.alterId; - if (Global.VmessSecurities.Contains(node.security)) + outbound.uuid = node.Id; + outbound.alter_id = node.AlterId; + if (Global.VmessSecurities.Contains(node.Security)) { - outbound.security = node.security; + outbound.security = node.Security; } else { @@ -608,8 +608,8 @@ namespace ServiceLib.Services.CoreConfig } case EConfigType.Shadowsocks: { - outbound.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.security) ? node.security : Global.None; - outbound.password = node.id; + outbound.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : Global.None; + outbound.password = node.Id; await GenOutboundMux(node, outbound); break; @@ -617,57 +617,57 @@ namespace ServiceLib.Services.CoreConfig case EConfigType.SOCKS: { outbound.version = "5"; - if (Utils.IsNotEmpty(node.security) - && Utils.IsNotEmpty(node.id)) + if (Utils.IsNotEmpty(node.Security) + && Utils.IsNotEmpty(node.Id)) { - outbound.username = node.security; - outbound.password = node.id; + outbound.username = node.Security; + outbound.password = node.Id; } break; } case EConfigType.HTTP: { - if (Utils.IsNotEmpty(node.security) - && Utils.IsNotEmpty(node.id)) + if (Utils.IsNotEmpty(node.Security) + && Utils.IsNotEmpty(node.Id)) { - outbound.username = node.security; - outbound.password = node.id; + outbound.username = node.Security; + outbound.password = node.Id; } break; } case EConfigType.VLESS: { - outbound.uuid = node.id; + outbound.uuid = node.Id; outbound.packet_encoding = "xudp"; - if (Utils.IsNullOrEmpty(node.flow)) + if (Utils.IsNullOrEmpty(node.Flow)) { await GenOutboundMux(node, outbound); } else { - outbound.flow = node.flow; + outbound.flow = node.Flow; } break; } case EConfigType.Trojan: { - outbound.password = node.id; + outbound.password = node.Id; await GenOutboundMux(node, outbound); break; } case EConfigType.Hysteria2: { - outbound.password = node.id; + outbound.password = node.Id; - if (Utils.IsNotEmpty(node.path)) + if (Utils.IsNotEmpty(node.Path)) { outbound.obfs = new() { type = "salamander", - password = node.path.TrimEx(), + password = node.Path.TrimEx(), }; } @@ -677,18 +677,18 @@ namespace ServiceLib.Services.CoreConfig } case EConfigType.TUIC: { - outbound.uuid = node.id; - outbound.password = node.security; - outbound.congestion_control = node.headerType; + outbound.uuid = node.Id; + outbound.password = node.Security; + outbound.congestion_control = node.HeaderType; break; } case EConfigType.WireGuard: { - outbound.private_key = node.id; - outbound.peer_public_key = node.publicKey; - outbound.reserved = Utils.String2List(node.path)?.Select(int.Parse).ToList(); - outbound.local_address = Utils.String2List(node.requestHost); - outbound.mtu = Utils.ToInt(node.shortId.IsNullOrEmpty() ? Global.TunMtus.FirstOrDefault() : node.shortId); + outbound.private_key = node.Id; + outbound.peer_public_key = node.PublicKey; + outbound.reserved = Utils.String2List(node.Path)?.Select(int.Parse).ToList(); + outbound.local_address = Utils.String2List(node.RequestHost); + outbound.mtu = Utils.ToInt(node.ShortId.IsNullOrEmpty() ? Global.TunMtus.FirstOrDefault() : node.ShortId); break; } } @@ -731,39 +731,39 @@ namespace ServiceLib.Services.CoreConfig { try { - if (node.streamSecurity == Global.StreamSecurityReality || node.streamSecurity == Global.StreamSecurity) + if (node.StreamSecurity == Global.StreamSecurityReality || node.StreamSecurity == Global.StreamSecurity) { var server_name = string.Empty; - if (Utils.IsNotEmpty(node.sni)) + if (Utils.IsNotEmpty(node.Sni)) { - server_name = node.sni; + server_name = node.Sni; } - else if (Utils.IsNotEmpty(node.requestHost)) + else if (Utils.IsNotEmpty(node.RequestHost)) { - server_name = Utils.String2List(node.requestHost)?.First(); + server_name = Utils.String2List(node.RequestHost)?.First(); } var tls = new Tls4Sbox() { enabled = true, server_name = server_name, - insecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.allowInsecure), + insecure = Utils.ToBool(node.AllowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.AllowInsecure), alpn = node.GetAlpn(), }; - if (Utils.IsNotEmpty(node.fingerprint)) + if (Utils.IsNotEmpty(node.Fingerprint)) { tls.utls = new Utls4Sbox() { enabled = true, - fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint + fingerprint = node.Fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.Fingerprint }; } - if (node.streamSecurity == Global.StreamSecurityReality) + if (node.StreamSecurity == Global.StreamSecurityReality) { tls.reality = new Reality4Sbox() { enabled = true, - public_key = node.publicKey, - short_id = node.shortId + public_key = node.PublicKey, + short_id = node.ShortId }; tls.insecure = false; } @@ -787,43 +787,43 @@ namespace ServiceLib.Services.CoreConfig { case nameof(ETransport.h2): transport.type = nameof(ETransport.http); - transport.host = Utils.IsNullOrEmpty(node.requestHost) ? null : Utils.String2List(node.requestHost); - transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path; + transport.host = Utils.IsNullOrEmpty(node.RequestHost) ? null : Utils.String2List(node.RequestHost); + transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path; break; case nameof(ETransport.tcp): //http - if (node.headerType == Global.TcpHeaderHttp) + if (node.HeaderType == Global.TcpHeaderHttp) { - if (node.configType == EConfigType.Shadowsocks) + if (node.ConfigType == EConfigType.Shadowsocks) { outbound.plugin = "obfs-local"; - outbound.plugin_opts = $"obfs=http;obfs-host={node.requestHost};"; + outbound.plugin_opts = $"obfs=http;obfs-host={node.RequestHost};"; } else { transport.type = nameof(ETransport.http); - transport.host = Utils.IsNullOrEmpty(node.requestHost) ? null : Utils.String2List(node.requestHost); - transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path; + transport.host = Utils.IsNullOrEmpty(node.RequestHost) ? null : Utils.String2List(node.RequestHost); + transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path; } } break; case nameof(ETransport.ws): transport.type = nameof(ETransport.ws); - transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path; - if (Utils.IsNotEmpty(node.requestHost)) + transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path; + if (Utils.IsNotEmpty(node.RequestHost)) { transport.headers = new() { - Host = node.requestHost + Host = node.RequestHost }; } break; case nameof(ETransport.httpupgrade): transport.type = nameof(ETransport.httpupgrade); - transport.path = Utils.IsNullOrEmpty(node.path) ? null : node.path; - transport.host = Utils.IsNullOrEmpty(node.requestHost) ? null : node.requestHost; + transport.path = Utils.IsNullOrEmpty(node.Path) ? null : node.Path; + transport.host = Utils.IsNullOrEmpty(node.RequestHost) ? null : node.RequestHost; break; @@ -833,9 +833,9 @@ namespace ServiceLib.Services.CoreConfig case nameof(ETransport.grpc): transport.type = nameof(ETransport.grpc); - transport.service_name = node.path; - transport.idle_timeout = _config.GrpcItem.IdleTimeout.ToString("##s"); - transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout.ToString("##s"); + transport.service_name = node.Path; + transport.idle_timeout = _config.GrpcItem.IdleTimeout?.ToString("##s"); + transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout?.ToString("##s"); transport.permit_without_stream = _config.GrpcItem.PermitWithoutStream; break; @@ -856,13 +856,13 @@ namespace ServiceLib.Services.CoreConfig private async Task GenMoreOutbounds(ProfileItem node, SingboxConfig singboxConfig) { - if (node.subid.IsNullOrEmpty()) + if (node.Subid.IsNullOrEmpty()) { return 0; } try { - var subItem = await AppHandler.Instance.GetSubItem(node.subid); + var subItem = await AppHandler.Instance.GetSubItem(node.Subid); if (subItem is null) { return 0; @@ -873,9 +873,9 @@ namespace ServiceLib.Services.CoreConfig var txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound); //Previous proxy - var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.prevProfile); + var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); if (prevNode is not null - && prevNode.configType != EConfigType.Custom) + && prevNode.ConfigType != EConfigType.Custom) { var prevOutbound = JsonUtils.Deserialize(txtOutbound); await GenOutbound(prevNode, prevOutbound); @@ -886,9 +886,9 @@ namespace ServiceLib.Services.CoreConfig } //Next proxy - var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.nextProfile); + var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile); if (nextNode is not null - && nextNode.configType != EConfigType.Custom) + && nextNode.ConfigType != EConfigType.Custom) { var nextOutbound = JsonUtils.Deserialize(txtOutbound); await GenOutbound(nextNode, nextOutbound); @@ -963,10 +963,10 @@ namespace ServiceLib.Services.CoreConfig var routing = await ConfigHandler.GetDefaultRouting(_config); if (routing != null) { - var rules = JsonUtils.Deserialize>(routing.ruleSet); + var rules = JsonUtils.Deserialize>(routing.RuleSet); foreach (var item in rules ?? []) { - if (item.enabled) + if (item.Enabled) { await GenRoutingUserRule(item, singboxConfig.route.rules); } @@ -978,7 +978,7 @@ namespace ServiceLib.Services.CoreConfig var lockedItem = await ConfigHandler.GetLockedRoutingItem(_config); if (lockedItem != null) { - var rules = JsonUtils.Deserialize>(lockedItem.ruleSet); + var rules = JsonUtils.Deserialize>(lockedItem.RuleSet); foreach (var item in rules ?? []) { await GenRoutingUserRule(item, singboxConfig.route.rules); @@ -1185,11 +1185,11 @@ namespace ServiceLib.Services.CoreConfig var strDNS = string.Empty; if (_config.TunModeItem.EnableTun) { - strDNS = Utils.IsNullOrEmpty(item?.tunDNS) ? Utils.GetEmbedText(Global.TunSingboxDNSFileName) : item?.tunDNS; + strDNS = Utils.IsNullOrEmpty(item?.TunDNS) ? Utils.GetEmbedText(Global.TunSingboxDNSFileName) : item?.TunDNS; } else { - strDNS = Utils.IsNullOrEmpty(item?.normalDNS) ? Utils.GetEmbedText(Global.DNSSingboxNormalFileName) : item?.normalDNS; + strDNS = Utils.IsNullOrEmpty(item?.NormalDNS) ? Utils.GetEmbedText(Global.DNSSingboxNormalFileName) : item?.NormalDNS; } var dns4Sbox = JsonUtils.Deserialize(strDNS); @@ -1218,9 +1218,9 @@ namespace ServiceLib.Services.CoreConfig dns4Sbox.servers.Add(new() { tag = tag, - address = Utils.IsNullOrEmpty(dNSItem?.domainDNSAddress) ? Global.SingboxDomainDNSAddress.FirstOrDefault() : dNSItem?.domainDNSAddress, + address = Utils.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.SingboxDomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress, detour = Global.DirectTag, - strategy = Utils.IsNullOrEmpty(dNSItem?.domainStrategy4Freedom) ? null : dNSItem?.domainStrategy4Freedom, + strategy = Utils.IsNullOrEmpty(dNSItem?.DomainStrategy4Freedom) ? null : dNSItem?.DomainStrategy4Freedom, }); dns4Sbox.rules.Insert(0, new() { @@ -1248,12 +1248,12 @@ namespace ServiceLib.Services.CoreConfig } //Tun2SocksAddress - if (_config.TunModeItem.EnableTun && node?.configType == EConfigType.SOCKS && Utils.IsDomain(node?.sni)) + if (_config.TunModeItem.EnableTun && node?.ConfigType == EConfigType.SOCKS && Utils.IsDomain(node?.Sni)) { dns4Sbox.rules.Insert(0, new() { server = tag, - domain = [node?.sni] + domain = [node?.Sni] }); } @@ -1337,9 +1337,9 @@ namespace ServiceLib.Services.CoreConfig if (_config.RoutingBasicItem.EnableRoutingAdvanced) { var routing = await ConfigHandler.GetDefaultRouting(_config); - if (Utils.IsNotEmpty(routing.customRulesetPath4Singbox)) + if (Utils.IsNotEmpty(routing.CustomRulesetPath4Singbox)) { - var result = Utils.LoadResource(routing.customRulesetPath4Singbox); + var result = Utils.LoadResource(routing.CustomRulesetPath4Singbox); if (Utils.IsNotEmpty(result)) { customRulesets = (JsonUtils.Deserialize>(result) ?? []) diff --git a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs index 97919ba3..99acf423 100644 --- a/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs +++ b/v2rayN/ServiceLib/Services/CoreConfig/CoreConfigV2rayService.cs @@ -21,7 +21,7 @@ namespace ServiceLib.Services.CoreConfig try { if (node == null - || node.port <= 0) + || node.Port <= 0) { ret.Msg = ResUI.CheckServerSettings; return ret; @@ -109,36 +109,36 @@ namespace ServiceLib.Services.CoreConfig var tagProxy = new List(); foreach (var it in selecteds) { - if (it.configType == EConfigType.Custom) + if (it.ConfigType == EConfigType.Custom) { continue; } - if (it.configType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard) + if (it.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.WireGuard) { continue; } - if (it.port <= 0) + if (it.Port <= 0) { continue; } - var item = await AppHandler.Instance.GetProfileItem(it.indexId); + var item = await AppHandler.Instance.GetProfileItem(it.IndexId); if (item is null) { continue; } - if (it.configType is EConfigType.VMess or EConfigType.VLESS) + if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS) { - if (Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id)) + if (Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id)) { continue; } } - if (item.configType == EConfigType.Shadowsocks - && !Global.SsSecuritiesInSingbox.Contains(item.security)) + if (item.ConfigType == EConfigType.Shadowsocks + && !Global.SsSecuritiesInSingbox.Contains(item.Security)) { continue; } - if (item.configType == EConfigType.VLESS && !Global.Flows.Contains(item.flow)) + if (item.ConfigType == EConfigType.VLESS && !Global.Flows.Contains(item.Flow)) { continue; } @@ -256,7 +256,7 @@ namespace ServiceLib.Services.CoreConfig var item = await AppHandler.Instance.GetProfileItem(it.IndexId); if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS) { - if (item is null || Utils.IsNullOrEmpty(item.id) || !Utils.IsGuidByParse(item.id)) + if (item is null || Utils.IsNullOrEmpty(item.Id) || !Utils.IsGuidByParse(item.Id)) { continue; } @@ -303,19 +303,19 @@ namespace ServiceLib.Services.CoreConfig { continue; } - if (item.configType == EConfigType.Shadowsocks - && !Global.SsSecuritiesInXray.Contains(item.security)) + if (item.ConfigType == EConfigType.Shadowsocks + && !Global.SsSecuritiesInXray.Contains(item.Security)) { continue; } - if (item.configType == EConfigType.VLESS - && !Global.Flows.Contains(item.flow)) + if (item.ConfigType == EConfigType.VLESS + && !Global.Flows.Contains(item.Flow)) { continue; } if (it.ConfigType is EConfigType.VLESS or EConfigType.Trojan - && item.streamSecurity == Global.StreamSecurityReality - && item.publicKey.IsNullOrEmpty()) + && item.StreamSecurity == Global.StreamSecurityReality + && item.PublicKey.IsNullOrEmpty()) { continue; } @@ -465,14 +465,14 @@ namespace ServiceLib.Services.CoreConfig var routing = await ConfigHandler.GetDefaultRouting(_config); if (routing != null) { - if (Utils.IsNotEmpty(routing.domainStrategy)) + if (Utils.IsNotEmpty(routing.DomainStrategy)) { - v2rayConfig.routing.domainStrategy = routing.domainStrategy; + v2rayConfig.routing.domainStrategy = routing.DomainStrategy; } - var rules = JsonUtils.Deserialize>(routing.ruleSet); + var rules = JsonUtils.Deserialize>(routing.RuleSet); foreach (var item in rules) { - if (item.enabled) + if (item.Enabled) { var item2 = JsonUtils.Deserialize(JsonUtils.Serialize(item)); await GenRoutingUserRule(item2, v2rayConfig); @@ -485,7 +485,7 @@ namespace ServiceLib.Services.CoreConfig var lockedItem = await ConfigHandler.GetLockedRoutingItem(_config); if (lockedItem != null) { - var rules = JsonUtils.Deserialize>(lockedItem.ruleSet); + var rules = JsonUtils.Deserialize>(lockedItem.RuleSet); foreach (var item in rules) { var item2 = JsonUtils.Deserialize(JsonUtils.Serialize(item)); @@ -584,7 +584,7 @@ namespace ServiceLib.Services.CoreConfig { try { - switch (node.configType) + switch (node.ConfigType) { case EConfigType.VMess: { @@ -598,8 +598,8 @@ namespace ServiceLib.Services.CoreConfig { vnextItem = outbound.settings.vnext[0]; } - vnextItem.address = node.address; - vnextItem.port = node.port; + vnextItem.address = node.Address; + vnextItem.port = node.Port; UsersItem4Ray usersItem; if (vnextItem.users.Count <= 0) @@ -612,12 +612,12 @@ namespace ServiceLib.Services.CoreConfig usersItem = vnextItem.users[0]; } //远程服务器用户ID - usersItem.id = node.id; - usersItem.alterId = node.alterId; + usersItem.id = node.Id; + usersItem.alterId = node.AlterId; usersItem.email = Global.UserEMail; - if (Global.VmessSecurities.Contains(node.security)) + if (Global.VmessSecurities.Contains(node.Security)) { - usersItem.security = node.security; + usersItem.security = node.Security; } else { @@ -641,10 +641,10 @@ namespace ServiceLib.Services.CoreConfig { serversItem = outbound.settings.servers[0]; } - serversItem.address = node.address; - serversItem.port = node.port; - serversItem.password = node.id; - serversItem.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.security) ? node.security : "none"; + serversItem.address = node.Address; + serversItem.port = node.Port; + serversItem.password = node.Id; + serversItem.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : "none"; serversItem.ota = false; serversItem.level = 1; @@ -667,18 +667,18 @@ namespace ServiceLib.Services.CoreConfig { serversItem = outbound.settings.servers[0]; } - serversItem.address = node.address; - serversItem.port = node.port; + serversItem.address = node.Address; + serversItem.port = node.Port; serversItem.method = null; serversItem.password = null; - if (Utils.IsNotEmpty(node.security) - && Utils.IsNotEmpty(node.id)) + if (Utils.IsNotEmpty(node.Security) + && Utils.IsNotEmpty(node.Id)) { SocksUsersItem4Ray socksUsersItem = new() { - user = node.security, - pass = node.id, + user = node.Security, + pass = node.Id, level = 1 }; @@ -702,8 +702,8 @@ namespace ServiceLib.Services.CoreConfig { vnextItem = outbound.settings.vnext[0]; } - vnextItem.address = node.address; - vnextItem.port = node.port; + vnextItem.address = node.Address; + vnextItem.port = node.Port; UsersItem4Ray usersItem; if (vnextItem.users.Count <= 0) @@ -715,23 +715,23 @@ namespace ServiceLib.Services.CoreConfig { usersItem = vnextItem.users[0]; } - usersItem.id = node.id; + usersItem.id = node.Id; usersItem.email = Global.UserEMail; - usersItem.encryption = node.security; + usersItem.encryption = node.Security; await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled); - if (node.streamSecurity == Global.StreamSecurityReality - || node.streamSecurity == Global.StreamSecurity) + if (node.StreamSecurity == Global.StreamSecurityReality + || node.StreamSecurity == Global.StreamSecurity) { - if (Utils.IsNotEmpty(node.flow)) + if (Utils.IsNotEmpty(node.Flow)) { - usersItem.flow = node.flow; + usersItem.flow = node.Flow; await GenOutboundMux(node, outbound, false); } } - if (node.streamSecurity == Global.StreamSecurityReality && Utils.IsNullOrEmpty(node.flow)) + if (node.StreamSecurity == Global.StreamSecurityReality && Utils.IsNullOrEmpty(node.Flow)) { await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled); } @@ -751,9 +751,9 @@ namespace ServiceLib.Services.CoreConfig { serversItem = outbound.settings.servers[0]; } - serversItem.address = node.address; - serversItem.port = node.port; - serversItem.password = node.id; + serversItem.address = node.Address; + serversItem.port = node.Port; + serversItem.password = node.Id; serversItem.ota = false; serversItem.level = 1; @@ -765,7 +765,7 @@ namespace ServiceLib.Services.CoreConfig } } - outbound.protocol = Global.ProtocolTypes[node.configType]; + outbound.protocol = Global.ProtocolTypes[node.ConfigType]; await GenBoundStreamSettings(node, outbound.streamSettings); } catch (Exception ex) @@ -804,8 +804,8 @@ namespace ServiceLib.Services.CoreConfig try { streamSettings.network = node.GetNetwork(); - string host = node.requestHost.TrimEx(); - string sni = node.sni; + string host = node.RequestHost.TrimEx(); + string sni = node.Sni; string useragent = ""; if (!_config.CoreBasicItem.DefUserAgent.IsNullOrEmpty()) { @@ -820,15 +820,15 @@ namespace ServiceLib.Services.CoreConfig } //if tls - if (node.streamSecurity == Global.StreamSecurity) + if (node.StreamSecurity == Global.StreamSecurity) { - streamSettings.security = node.streamSecurity; + streamSettings.security = node.StreamSecurity; TlsSettings4Ray tlsSettings = new() { - allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.allowInsecure), + allowInsecure = Utils.ToBool(node.AllowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.AllowInsecure), alpn = node.GetAlpn(), - fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint + fingerprint = node.Fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.Fingerprint }; if (Utils.IsNotEmpty(sni)) { @@ -842,17 +842,17 @@ namespace ServiceLib.Services.CoreConfig } //if Reality - if (node.streamSecurity == Global.StreamSecurityReality) + if (node.StreamSecurity == Global.StreamSecurityReality) { - streamSettings.security = node.streamSecurity; + streamSettings.security = node.StreamSecurity; TlsSettings4Ray realitySettings = new() { - fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint, + fingerprint = node.Fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.Fingerprint, serverName = sni, - publicKey = node.publicKey, - shortId = node.shortId, - spiderX = node.spiderX, + publicKey = node.PublicKey, + shortId = node.ShortId, + spiderX = node.SpiderX, show = false, }; @@ -877,11 +877,11 @@ namespace ServiceLib.Services.CoreConfig kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize; kcpSettings.header = new Header4Ray { - type = node.headerType + type = node.HeaderType }; - if (Utils.IsNotEmpty(node.path)) + if (Utils.IsNotEmpty(node.Path)) { - kcpSettings.seed = node.path; + kcpSettings.seed = node.Path; } streamSettings.kcpSettings = kcpSettings; break; @@ -889,7 +889,7 @@ namespace ServiceLib.Services.CoreConfig case nameof(ETransport.ws): WsSettings4Ray wsSettings = new(); wsSettings.headers = new Headers4Ray(); - string path = node.path; + string path = node.Path; if (Utils.IsNotEmpty(host)) { wsSettings.headers.Host = host; @@ -909,9 +909,9 @@ namespace ServiceLib.Services.CoreConfig case nameof(ETransport.httpupgrade): HttpupgradeSettings4Ray httpupgradeSettings = new(); - if (Utils.IsNotEmpty(node.path)) + if (Utils.IsNotEmpty(node.Path)) { - httpupgradeSettings.path = node.path; + httpupgradeSettings.path = node.Path; } if (Utils.IsNotEmpty(host)) { @@ -928,9 +928,9 @@ namespace ServiceLib.Services.CoreConfig maxConcurrentUploads = 10 }; - if (Utils.IsNotEmpty(node.path)) + if (Utils.IsNotEmpty(node.Path)) { - splithttpSettings.path = node.path; + splithttpSettings.path = node.Path; } if (Utils.IsNotEmpty(host)) { @@ -947,7 +947,7 @@ namespace ServiceLib.Services.CoreConfig { httpSettings.host = Utils.String2List(host); } - httpSettings.path = node.path; + httpSettings.path = node.Path; streamSettings.httpSettings = httpSettings; @@ -957,14 +957,14 @@ namespace ServiceLib.Services.CoreConfig QuicSettings4Ray quicsettings = new() { security = host, - key = node.path, + key = node.Path, header = new Header4Ray { - type = node.headerType + type = node.HeaderType } }; streamSettings.quicSettings = quicsettings; - if (node.streamSecurity == Global.StreamSecurity) + if (node.StreamSecurity == Global.StreamSecurity) { if (Utils.IsNotEmpty(sni)) { @@ -972,7 +972,7 @@ namespace ServiceLib.Services.CoreConfig } else { - streamSettings.tlsSettings.serverName = node.address; + streamSettings.tlsSettings.serverName = node.Address; } } break; @@ -981,8 +981,8 @@ namespace ServiceLib.Services.CoreConfig GrpcSettings4Ray grpcSettings = new() { authority = Utils.IsNullOrEmpty(host) ? null : host, - serviceName = node.path, - multiMode = node.headerType == Global.GrpcMultiMode, + serviceName = node.Path, + multiMode = node.HeaderType == Global.GrpcMultiMode, idle_timeout = _config.GrpcItem.IdleTimeout, health_check_timeout = _config.GrpcItem.HealthCheckTimeout, permit_without_stream = _config.GrpcItem.PermitWithoutStream, @@ -993,13 +993,13 @@ namespace ServiceLib.Services.CoreConfig default: //tcp - if (node.headerType == Global.TcpHeaderHttp) + if (node.HeaderType == Global.TcpHeaderHttp) { TcpSettings4Ray tcpSettings = new() { header = new Header4Ray { - type = node.headerType + type = node.HeaderType } }; @@ -1012,9 +1012,9 @@ namespace ServiceLib.Services.CoreConfig request = request.Replace("$requestUserAgent$", $"\"{useragent}\""); //Path string pathHttp = @"/"; - if (Utils.IsNotEmpty(node.path)) + if (Utils.IsNotEmpty(node.Path)) { - string[] arrPath = node.path.Split(','); + string[] arrPath = node.Path.Split(','); pathHttp = string.Join("\",\"", arrPath); } request = request.Replace("$requestPath$", $"\"{pathHttp}\""); @@ -1037,8 +1037,8 @@ namespace ServiceLib.Services.CoreConfig try { var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray); - var normalDNS = item?.normalDNS; - var domainStrategy4Freedom = item?.domainStrategy4Freedom; + var normalDNS = item?.NormalDNS; + var domainStrategy4Freedom = item?.DomainStrategy4Freedom; if (Utils.IsNullOrEmpty(normalDNS)) { normalDNS = Utils.GetEmbedText(Global.DNSV2rayNormalFileName); @@ -1066,7 +1066,7 @@ namespace ServiceLib.Services.CoreConfig } // 追加至 dns 设置 - if (item.useSystemHosts) + if (item.UseSystemHosts) { var systemHosts = Utils.GetSystemHosts(); if (systemHosts.Count > 0) @@ -1102,12 +1102,12 @@ namespace ServiceLib.Services.CoreConfig var servers = dns["servers"]; if (servers != null) { - if (Utils.IsDomain(node.address)) + if (Utils.IsDomain(node.Address)) { var dnsServer = new DnsServer4Ray() { - address = Utils.IsNullOrEmpty(dNSItem?.domainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.domainDNSAddress, - domains = [node.address] + address = Utils.IsNullOrEmpty(dNSItem?.DomainDNSAddress) ? Global.DomainDNSAddress.FirstOrDefault() : dNSItem?.DomainDNSAddress, + domains = [node.Address] }; servers.AsArray().Add(JsonUtils.SerializeToNode(dnsServer)); } @@ -1194,13 +1194,13 @@ namespace ServiceLib.Services.CoreConfig return 0; } - if (node.subid.IsNullOrEmpty()) + if (node.Subid.IsNullOrEmpty()) { return 0; } try { - var subItem = await AppHandler.Instance.GetSubItem(node.subid); + var subItem = await AppHandler.Instance.GetSubItem(node.Subid); if (subItem is null) { return 0; @@ -1211,12 +1211,12 @@ namespace ServiceLib.Services.CoreConfig var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound); //Previous proxy - var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.prevProfile); + var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile); if (prevNode is not null - && prevNode.configType != EConfigType.Custom - && prevNode.configType != EConfigType.Hysteria2 - && prevNode.configType != EConfigType.TUIC - && prevNode.configType != EConfigType.WireGuard) + && prevNode.ConfigType != EConfigType.Custom + && prevNode.ConfigType != EConfigType.Hysteria2 + && prevNode.ConfigType != EConfigType.TUIC + && prevNode.ConfigType != EConfigType.WireGuard) { var prevOutbound = JsonUtils.Deserialize(txtOutbound); await GenOutbound(prevNode, prevOutbound); @@ -1230,12 +1230,12 @@ namespace ServiceLib.Services.CoreConfig } //Next proxy - var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.nextProfile); + var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile); if (nextNode is not null - && nextNode.configType != EConfigType.Custom - && nextNode.configType != EConfigType.Hysteria2 - && nextNode.configType != EConfigType.TUIC - && nextNode.configType != EConfigType.WireGuard) + && nextNode.ConfigType != EConfigType.Custom + && nextNode.ConfigType != EConfigType.Hysteria2 + && nextNode.ConfigType != EConfigType.TUIC + && nextNode.ConfigType != EConfigType.WireGuard) { var nextOutbound = JsonUtils.Deserialize(txtOutbound); await GenOutbound(nextNode, nextOutbound); diff --git a/v2rayN/ServiceLib/Services/SpeedtestService.cs b/v2rayN/ServiceLib/Services/SpeedtestService.cs index a821e86d..61bfd7c1 100644 --- a/v2rayN/ServiceLib/Services/SpeedtestService.cs +++ b/v2rayN/ServiceLib/Services/SpeedtestService.cs @@ -22,20 +22,20 @@ namespace ServiceLib.Services _selecteds = new List(); foreach (var it in selecteds) { - if (it.configType == EConfigType.Custom) + if (it.ConfigType == EConfigType.Custom) { continue; } - if (it.port <= 0) + if (it.Port <= 0) { continue; } _selecteds.Add(new ServerTestItem() { - IndexId = it.indexId, - Address = it.address, - Port = it.port, - ConfigType = it.configType + IndexId = it.IndexId, + Address = it.Address, + Port = it.Port, + ConfigType = it.ConfigType }); } //clear test result diff --git a/v2rayN/ServiceLib/Services/UpdateService.cs b/v2rayN/ServiceLib/Services/UpdateService.cs index c939ecd2..bc66b3af 100644 --- a/v2rayN/ServiceLib/Services/UpdateService.cs +++ b/v2rayN/ServiceLib/Services/UpdateService.cs @@ -122,11 +122,11 @@ namespace ServiceLib.Services foreach (var item in subItem) { - string id = item.id.TrimEx(); - string url = item.url.TrimEx(); - string userAgent = item.userAgent.TrimEx(); - string hashCode = $"{item.remarks}->"; - if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url) || Utils.IsNotEmpty(subId) && item.id != subId) + string id = item.Id.TrimEx(); + string url = item.Url.TrimEx(); + string userAgent = item.UserAgent.TrimEx(); + string hashCode = $"{item.Remarks}->"; + if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url) || Utils.IsNotEmpty(subId) && item.Id != subId) { //_updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgNoValidSubscription}"); continue; @@ -135,7 +135,7 @@ namespace ServiceLib.Services { continue; } - if (item.enabled == false) + if (item.Enabled == false) { _updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgSkipSubscriptionUpdate}"); continue; @@ -152,13 +152,13 @@ namespace ServiceLib.Services //one url url = Utils.GetPunycode(url); //convert - if (Utils.IsNotEmpty(item.convertTarget)) + if (Utils.IsNotEmpty(item.ConvertTarget)) { var subConvertUrl = Utils.IsNullOrEmpty(config.ConstItem.SubConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.ConstItem.SubConvertUrl; url = string.Format(subConvertUrl!, Utils.UrlEncode(url)); if (!url.Contains("target=")) { - url += string.Format("&target={0}", item.convertTarget); + url += string.Format("&target={0}", item.ConvertTarget); } if (!url.Contains("config=")) { @@ -172,14 +172,14 @@ namespace ServiceLib.Services } //more url - if (Utils.IsNullOrEmpty(item.convertTarget) && Utils.IsNotEmpty(item.moreUrl.TrimEx())) + if (Utils.IsNullOrEmpty(item.ConvertTarget) && Utils.IsNotEmpty(item.MoreUrl.TrimEx())) { if (Utils.IsNotEmpty(result) && Utils.IsBase64String(result)) { result = Utils.Base64Decode(result); } - var lstUrl = item.moreUrl.TrimEx().Split(",") ?? []; + var lstUrl = item.MoreUrl.TrimEx().Split(",") ?? []; foreach (var it in lstUrl) { var url2 = Utils.GetPunycode(it); @@ -480,7 +480,7 @@ namespace ServiceLib.Services var routingItems = await AppHandler.Instance.RoutingItems(); foreach (var routing in routingItems) { - var rules = JsonUtils.Deserialize>(routing.ruleSet); + var rules = JsonUtils.Deserialize>(routing.RuleSet); foreach (var item in rules ?? []) { foreach (var ip in item.ip ?? []) diff --git a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs index 63ac0ce8..c0cfb32c 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs @@ -35,25 +35,25 @@ namespace ServiceLib.ViewModels await SaveServerAsync(); }); - SelectedSource = profileItem.indexId.IsNullOrEmpty() ? profileItem : JsonUtils.DeepCopy(profileItem); - CoreType = SelectedSource?.coreType?.ToString(); + SelectedSource = profileItem.IndexId.IsNullOrEmpty() ? profileItem : JsonUtils.DeepCopy(profileItem); + CoreType = SelectedSource?.CoreType?.ToString(); } private async Task SaveServerAsync() { - string remarks = SelectedSource.remarks; + string remarks = SelectedSource.Remarks; if (Utils.IsNullOrEmpty(remarks)) { NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } - if (Utils.IsNullOrEmpty(SelectedSource.address)) + if (Utils.IsNullOrEmpty(SelectedSource.Address)) { NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom); return; } - SelectedSource.coreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType); + SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType); if (await ConfigHandler.EditCustomServer(_config, SelectedSource) == 0) { @@ -73,13 +73,13 @@ namespace ServiceLib.ViewModels return; } - var item = await AppHandler.Instance.GetProfileItem(SelectedSource.indexId); + var item = await AppHandler.Instance.GetProfileItem(SelectedSource.IndexId); item ??= SelectedSource; - item.address = fileName; + item.Address = fileName; if (await ConfigHandler.AddCustomServer(_config, item, false) == 0) { NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer); - if (Utils.IsNotEmpty(item.indexId)) + if (Utils.IsNotEmpty(item.IndexId)) { SelectedSource = JsonUtils.DeepCopy(item); } @@ -93,7 +93,7 @@ namespace ServiceLib.ViewModels private async Task EditServer() { - var address = SelectedSource.address; + var address = SelectedSource.Address; if (Utils.IsNullOrEmpty(address)) { NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom); diff --git a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs index 8ac3ebb6..39c77271 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs @@ -24,64 +24,64 @@ namespace ServiceLib.ViewModels await SaveServerAsync(); }); - if (profileItem.indexId.IsNullOrEmpty()) + if (profileItem.IndexId.IsNullOrEmpty()) { - profileItem.network = Global.DefaultNetwork; - profileItem.headerType = Global.None; - profileItem.requestHost = ""; - profileItem.streamSecurity = ""; + profileItem.Network = Global.DefaultNetwork; + profileItem.HeaderType = Global.None; + profileItem.RequestHost = ""; + profileItem.StreamSecurity = ""; SelectedSource = profileItem; } else { SelectedSource = JsonUtils.DeepCopy(profileItem); } - CoreType = SelectedSource?.coreType?.ToString(); + CoreType = SelectedSource?.CoreType?.ToString(); } private async Task SaveServerAsync() { - if (Utils.IsNullOrEmpty(SelectedSource.remarks)) + if (Utils.IsNullOrEmpty(SelectedSource.Remarks)) { NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); return; } - if (Utils.IsNullOrEmpty(SelectedSource.address)) + if (Utils.IsNullOrEmpty(SelectedSource.Address)) { NoticeHandler.Instance.Enqueue(ResUI.FillServerAddress); return; } - var port = SelectedSource.port.ToString(); + var port = SelectedSource.Port.ToString(); if (Utils.IsNullOrEmpty(port) || !Utils.IsNumeric(port) - || SelectedSource.port <= 0 || SelectedSource.port >= Global.MaxPort) + || SelectedSource.Port <= 0 || SelectedSource.Port >= Global.MaxPort) { NoticeHandler.Instance.Enqueue(ResUI.FillCorrectServerPort); return; } - if (SelectedSource.configType == EConfigType.Shadowsocks) + if (SelectedSource.ConfigType == EConfigType.Shadowsocks) { - if (Utils.IsNullOrEmpty(SelectedSource.id)) + if (Utils.IsNullOrEmpty(SelectedSource.Id)) { NoticeHandler.Instance.Enqueue(ResUI.FillPassword); return; } - if (Utils.IsNullOrEmpty(SelectedSource.security)) + if (Utils.IsNullOrEmpty(SelectedSource.Security)) { NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectEncryption); return; } } - if (SelectedSource.configType != EConfigType.SOCKS - && SelectedSource.configType != EConfigType.HTTP) + if (SelectedSource.ConfigType != EConfigType.SOCKS + && SelectedSource.ConfigType != EConfigType.HTTP) { - if (Utils.IsNullOrEmpty(SelectedSource.id)) + if (Utils.IsNullOrEmpty(SelectedSource.Id)) { NoticeHandler.Instance.Enqueue(ResUI.FillUUID); return; } } - SelectedSource.coreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType); + SelectedSource.CoreType = CoreType.IsNullOrEmpty() ? null : (ECoreType)Enum.Parse(typeof(ECoreType), CoreType); if (await ConfigHandler.AddServer(_config, SelectedSource) == 0) { diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index c6a35138..7bfe7ffa 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -273,7 +273,7 @@ namespace ServiceLib.ViewModels var lstDetails = new List(); foreach (var item in proxy.all) { - var isActive = item == proxy.now; + var IsActive = item == proxy.now; var proxy2 = TryGetProxy(item); if (proxy2 == null) @@ -288,7 +288,7 @@ namespace ServiceLib.ViewModels lstDetails.Add(new ClashProxyModel() { - isActive = isActive, + IsActive = IsActive, name = item, type = proxy2.type, delay = delay <= 0 ? _delayTimeout : delay, diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index f7fcf848..cef99002 100644 --- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -46,16 +46,16 @@ namespace ServiceLib.ViewModels private async Task Init() { var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray); - useSystemHosts = item.useSystemHosts; - domainStrategy4Freedom = item?.domainStrategy4Freedom ?? string.Empty; - domainDNSAddress = item?.domainDNSAddress ?? string.Empty; - normalDNS = item?.normalDNS ?? string.Empty; + useSystemHosts = item.UseSystemHosts; + domainStrategy4Freedom = item?.DomainStrategy4Freedom ?? string.Empty; + domainDNSAddress = item?.DomainDNSAddress ?? string.Empty; + normalDNS = item?.NormalDNS ?? string.Empty; var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); - domainStrategy4Freedom2 = item2?.domainStrategy4Freedom ?? string.Empty; - domainDNSAddress2 = item2?.domainDNSAddress ?? string.Empty; - normalDNS2 = item2?.normalDNS ?? string.Empty; - tunDNS2 = item2?.tunDNS ?? string.Empty; + domainStrategy4Freedom2 = item2?.DomainStrategy4Freedom ?? string.Empty; + domainDNSAddress2 = item2?.DomainDNSAddress ?? string.Empty; + normalDNS2 = item2?.NormalDNS ?? string.Empty; + tunDNS2 = item2?.TunDNS ?? string.Empty; } private async Task SaveSettingAsync() @@ -95,17 +95,17 @@ namespace ServiceLib.ViewModels } var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray); - item.domainStrategy4Freedom = domainStrategy4Freedom; - item.domainDNSAddress = domainDNSAddress; - item.useSystemHosts = useSystemHosts; - item.normalDNS = normalDNS; + item.DomainStrategy4Freedom = domainStrategy4Freedom; + item.DomainDNSAddress = domainDNSAddress; + item.UseSystemHosts = useSystemHosts; + item.NormalDNS = normalDNS; await ConfigHandler.SaveDNSItems(_config, item); var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); - item2.domainStrategy4Freedom = domainStrategy4Freedom2; - item2.domainDNSAddress = domainDNSAddress2; - item2.normalDNS = JsonUtils.Serialize(JsonUtils.ParseJson(normalDNS2)); - item2.tunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(tunDNS2)); ; + item2.DomainStrategy4Freedom = domainStrategy4Freedom2; + item2.DomainDNSAddress = domainDNSAddress2; + item2.NormalDNS = JsonUtils.Serialize(JsonUtils.ParseJson(normalDNS2)); + item2.TunDNS = JsonUtils.Serialize(JsonUtils.ParseJson(tunDNS2)); ; await ConfigHandler.SaveDNSItems(_config, item2); NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index a343b44d..4c8cfb8b 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -351,9 +351,9 @@ namespace ServiceLib.ViewModels { ProfileItem item = new() { - subid = _config.SubIndexId, - configType = eConfigType, - isSub = false, + Subid = _config.SubIndexId, + ConfigType = eConfigType, + IsSub = false, }; bool? ret = false; @@ -368,7 +368,7 @@ namespace ServiceLib.ViewModels if (ret == true) { RefreshServers(); - if (item.indexId == _config.IndexId) + if (item.IndexId == _config.IndexId) { await Reload(); } diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs index bc6249fe..8249d6e8 100644 --- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs @@ -103,15 +103,15 @@ namespace ServiceLib.ViewModels var canEditRemove = this.WhenAnyValue( x => x.SelectedProfile, - selectedSource => selectedSource != null && !selectedSource.indexId.IsNullOrEmpty()); + selectedSource => selectedSource != null && !selectedSource.IndexId.IsNullOrEmpty()); this.WhenAnyValue( x => x.SelectedSub, - y => y != null && !y.remarks.IsNullOrEmpty() && _config.SubIndexId != y.id) + y => y != null && !y.Remarks.IsNullOrEmpty() && _config.SubIndexId != y.Id) .Subscribe(async c => await SubSelectedChangedAsync(c)); this.WhenAnyValue( x => x.SelectedMoveToGroup, - y => y != null && !y.remarks.IsNullOrEmpty()) + y => y != null && !y.Remarks.IsNullOrEmpty()) .Subscribe(async c => await MoveToGroup(c)); this.WhenAnyValue( @@ -195,7 +195,7 @@ namespace ServiceLib.ViewModels }, canEditRemove); SortServerResultCmd = ReactiveCommand.CreateFromTask(async () => { - await SortServer(EServerColName.delayVal.ToString()); + await SortServer(EServerColName.DelayVal.ToString()); }); //servers export Export2ClientConfigCmd = ReactiveCommand.CreateFromTask(async () => @@ -273,18 +273,18 @@ namespace ServiceLib.ViewModels NoticeHandler.Instance.Enqueue(result.Delay); return; } - var item = _profileItems.Where(it => it.indexId == result.IndexId).FirstOrDefault(); + var item = _profileItems.Where(it => it.IndexId == result.IndexId).FirstOrDefault(); if (item != null) { if (Utils.IsNotEmpty(result.Delay)) { int.TryParse(result.Delay, out int temp); - item.delay = temp; - item.delayVal = $"{result.Delay} {Global.DelayUnit}"; + item.Delay = temp; + item.DelayVal = $"{result.Delay} {Global.DelayUnit}"; } if (Utils.IsNotEmpty(result.Speed)) { - item.speedVal = $"{result.Speed} {Global.SpeedUnit}"; + item.SpeedVal = $"{result.Speed} {Global.SpeedUnit}"; } _profileItems.Replace(item, JsonUtils.DeepCopy(item)); } @@ -294,15 +294,15 @@ namespace ServiceLib.ViewModels { try { - var item = _profileItems.Where(it => it.indexId == update.indexId).FirstOrDefault(); + var item = _profileItems.Where(it => it.IndexId == update.IndexId).FirstOrDefault(); if (item != null) { - item.todayDown = Utils.HumanFy(update.todayDown); - item.todayUp = Utils.HumanFy(update.todayUp); - item.totalDown = Utils.HumanFy(update.totalDown); - item.totalUp = Utils.HumanFy(update.totalUp); + item.TodayDown = Utils.HumanFy(update.TodayDown); + item.TodayUp = Utils.HumanFy(update.TodayUp); + item.TotalDown = Utils.HumanFy(update.TotalDown); + item.TotalUp = Utils.HumanFy(update.TotalUp); - if (SelectedProfile?.indexId == item.indexId) + if (SelectedProfile?.IndexId == item.IndexId) { var temp = JsonUtils.DeepCopy(item); _profileItems.Replace(item, temp); @@ -334,7 +334,7 @@ namespace ServiceLib.ViewModels { return; } - _config.SubIndexId = SelectedSub?.id; + _config.SubIndexId = SelectedSub?.Id; RefreshServers(); @@ -368,7 +368,7 @@ namespace ServiceLib.ViewModels _profileItems.AddRange(lstModel); if (lstModel.Count > 0) { - var selected = lstModel.FirstOrDefault(t => t.indexId == _config.IndexId); + var selected = lstModel.FirstOrDefault(t => t.IndexId == _config.IndexId); if (selected != null) { SelectedProfile = selected; @@ -384,15 +384,15 @@ namespace ServiceLib.ViewModels { _subItems.Clear(); - _subItems.Add(new SubItem { remarks = ResUI.AllGroupServers }); + _subItems.Add(new SubItem { Remarks = ResUI.AllGroupServers }); foreach (var item in await AppHandler.Instance.SubItems()) { _subItems.Add(item); } - if (_config.SubIndexId != null && _subItems.FirstOrDefault(t => t.id == _config.SubIndexId) != null) + if (_config.SubIndexId != null && _subItems.FirstOrDefault(t => t.Id == _config.SubIndexId) != null) { - SelectedSub = _subItems.FirstOrDefault(t => t.id == _config.SubIndexId); + SelectedSub = _subItems.FirstOrDefault(t => t.Id == _config.SubIndexId); } else { @@ -412,12 +412,12 @@ namespace ServiceLib.ViewModels return null; } - var orderProfiles = SelectedProfiles?.OrderBy(t => t.sort); + var orderProfiles = SelectedProfiles?.OrderBy(t => t.Sort); if (latest) { foreach (var profile in orderProfiles) { - var item = await AppHandler.Instance.GetProfileItem(profile.indexId); + var item = await AppHandler.Instance.GetProfileItem(profile.IndexId); if (item is not null) { lstSelecteds.Add(item); @@ -434,17 +434,17 @@ namespace ServiceLib.ViewModels public async Task EditServerAsync(EConfigType eConfigType) { - if (Utils.IsNullOrEmpty(SelectedProfile?.indexId)) + if (Utils.IsNullOrEmpty(SelectedProfile?.IndexId)) { return; } - var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.indexId); + var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId); if (item is null) { NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); return; } - eConfigType = item.configType; + eConfigType = item.ConfigType; bool? ret = false; if (eConfigType == EConfigType.Custom) @@ -458,7 +458,7 @@ namespace ServiceLib.ViewModels if (ret == true) { RefreshServers(); - if (item.indexId == _config.IndexId) + if (item.IndexId == _config.IndexId) { Reload(); } @@ -476,7 +476,7 @@ namespace ServiceLib.ViewModels { return; } - var exists = lstSelecteds.Exists(t => t.indexId == _config.IndexId); + var exists = lstSelecteds.Exists(t => t.IndexId == _config.IndexId); await ConfigHandler.RemoveServer(_config, lstSelecteds); NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); @@ -512,11 +512,11 @@ namespace ServiceLib.ViewModels public async Task SetDefaultServer() { - if (Utils.IsNullOrEmpty(SelectedProfile?.indexId)) + if (Utils.IsNullOrEmpty(SelectedProfile?.IndexId)) { return; } - await SetDefaultServer(SelectedProfile.indexId); + await SetDefaultServer(SelectedProfile.IndexId); } public async Task SetDefaultServer(string indexId) @@ -562,7 +562,7 @@ namespace ServiceLib.ViewModels public async Task ShareServerAsync() { - var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.indexId); + var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId); if (item is null) { NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); @@ -633,7 +633,7 @@ namespace ServiceLib.ViewModels return; } - await ConfigHandler.MoveToGroup(_config, lstSelecteds, SelectedMoveToGroup.id); + await ConfigHandler.MoveToGroup(_config, lstSelecteds, SelectedMoveToGroup.Id); NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); RefreshServers(); @@ -643,7 +643,7 @@ namespace ServiceLib.ViewModels public async Task MoveServer(EMove eMove) { - var item = _lstProfile.FirstOrDefault(t => t.indexId == SelectedProfile.indexId); + var item = _lstProfile.FirstOrDefault(t => t.IndexId == SelectedProfile.IndexId); if (item is null) { NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); @@ -696,7 +696,7 @@ namespace ServiceLib.ViewModels private async Task Export2ClientConfigAsync(bool blClipboard) { - var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.indexId); + var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId); if (item is null) { NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer); diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs index 91fdbdc5..da7fba0c 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs @@ -40,7 +40,7 @@ namespace ServiceLib.ViewModels { rulesItem.id = Utils.GetGuid(false); rulesItem.outboundTag = Global.ProxyTag; - rulesItem.enabled = true; + rulesItem.Enabled = true; SelectedSource = rulesItem; } else diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs index 91f90ec2..5a0c5ede 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs @@ -92,7 +92,7 @@ namespace ServiceLib.ViewModels SelectedSource = new(); SelectedRouting = routingItem; - _rules = routingItem.id.IsNullOrEmpty() ? new() : JsonUtils.Deserialize>(SelectedRouting.ruleSet); + _rules = routingItem.Id.IsNullOrEmpty() ? new() : JsonUtils.Deserialize>(SelectedRouting.RuleSet); RefreshRulesItems(); } @@ -109,12 +109,12 @@ namespace ServiceLib.ViewModels outboundTag = item.outboundTag, port = item.port, network = item.network, - protocols = Utils.List2String(item.protocol), - inboundTags = Utils.List2String(item.inboundTag), - domains = Utils.List2String(item.domain), - ips = Utils.List2String(item.ip), - enabled = item.enabled, - remarks = item.remarks, + Protocols = Utils.List2String(item.protocol), + InboundTags = Utils.List2String(item.inboundTag), + Domains = Utils.List2String(item.domain), + Ips = Utils.List2String(item.ip), + Enabled = item.Enabled, + Remarks = item.Remarks, }; _rulesItems.Add(it); } @@ -214,7 +214,7 @@ namespace ServiceLib.ViewModels private async Task SaveRoutingAsync() { - string remarks = SelectedRouting.remarks; + string remarks = SelectedRouting.Remarks; if (Utils.IsNullOrEmpty(remarks)) { NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); @@ -225,8 +225,8 @@ namespace ServiceLib.ViewModels { it.id = Utils.GetGuid(false); } - item.ruleNum = _rules.Count; - item.ruleSet = JsonUtils.Serialize(_rules, false); + item.RuleNum = _rules.Count; + item.RuleSet = JsonUtils.Serialize(_rules, false); if (await ConfigHandler.SaveRoutingItem(_config, item) == 0) { @@ -278,7 +278,7 @@ namespace ServiceLib.ViewModels private async Task ImportRulesFromUrl() { - var url = SelectedRouting.url; + var url = SelectedRouting.Url; if (Utils.IsNullOrEmpty(url)) { NoticeHandler.Instance.Enqueue(ResUI.MsgNeedUrl); diff --git a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs index d529f85b..2b8a413f 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs @@ -71,7 +71,7 @@ namespace ServiceLib.ViewModels var canEditRemove = this.WhenAnyValue( x => x.SelectedSource, - selectedSource => selectedSource != null && !selectedSource.remarks.IsNullOrEmpty()); + selectedSource => selectedSource != null && !selectedSource.Remarks.IsNullOrEmpty()); this.WhenAnyValue( x => x.enableRoutingAdvanced) @@ -130,16 +130,16 @@ namespace ServiceLib.ViewModels { _lockedItem = new RoutingItem() { - remarks = "locked", - url = string.Empty, - locked = true, + Remarks = "locked", + Url = string.Empty, + Locked = true, }; await ConfigHandler.AddBatchRoutingRules(_lockedItem, Utils.GetEmbedText(Global.CustomRoutingFileName + "locked")); } if (_lockedItem != null) { - _lockedRules = JsonUtils.Deserialize>(_lockedItem.ruleSet); + _lockedRules = JsonUtils.Deserialize>(_lockedItem.RuleSet); ProxyDomain = Utils.List2String(_lockedRules[0].domain, true); ProxyIP = Utils.List2String(_lockedRules[0].ip, true); @@ -164,7 +164,7 @@ namespace ServiceLib.ViewModels _lockedRules[2].domain = Utils.String2List(Utils.Convert2Comma(BlockDomain.TrimEx())); _lockedRules[2].ip = Utils.String2List(Utils.Convert2Comma(BlockIP.TrimEx())); - _lockedItem.ruleSet = JsonUtils.Serialize(_lockedRules, false); + _lockedItem.RuleSet = JsonUtils.Serialize(_lockedRules, false); await ConfigHandler.SaveRoutingItem(_config, _lockedItem); } @@ -182,21 +182,21 @@ namespace ServiceLib.ViewModels foreach (var item in routings) { bool def = false; - if (item.id == _config.RoutingBasicItem.RoutingIndexId) + if (item.Id == _config.RoutingBasicItem.RoutingIndexId) { def = true; } var it = new RoutingItemModel() { - isActive = def, - ruleNum = item.ruleNum, - id = item.id, - remarks = item.remarks, - url = item.url, - customIcon = item.customIcon, - customRulesetPath4Singbox = item.customRulesetPath4Singbox, - sort = item.sort, + IsActive = def, + RuleNum = item.RuleNum, + Id = item.Id, + Remarks = item.Remarks, + Url = item.Url, + CustomIcon = item.CustomIcon, + CustomRulesetPath4Singbox = item.CustomRulesetPath4Singbox, + Sort = item.Sort, }; _routingItems.Add(it); } @@ -245,7 +245,7 @@ namespace ServiceLib.ViewModels } else { - item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.id); + item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.Id); if (item is null) { return; @@ -260,7 +260,7 @@ namespace ServiceLib.ViewModels public async Task RoutingAdvancedRemoveAsync() { - if (SelectedSource is null || SelectedSource.remarks.IsNullOrEmpty()) + if (SelectedSource is null || SelectedSource.Remarks.IsNullOrEmpty()) { NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); return; @@ -271,7 +271,7 @@ namespace ServiceLib.ViewModels } foreach (var it in SelectedSources ?? [SelectedSource]) { - var item = await AppHandler.Instance.GetRoutingItem(it?.id); + var item = await AppHandler.Instance.GetRoutingItem(it?.Id); if (item != null) { await ConfigHandler.RemoveRoutingItem(item); @@ -284,7 +284,7 @@ namespace ServiceLib.ViewModels public async Task RoutingAdvancedSetDefault() { - var item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.id); + var item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.Id); if (item is null) { NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules); diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs index c5c0ed81..577a7136 100644 --- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs @@ -109,7 +109,7 @@ namespace ServiceLib.ViewModels this.WhenAnyValue( x => x.SelectedRouting, - y => y != null && !y.remarks.IsNullOrEmpty()) + y => y != null && !y.Remarks.IsNullOrEmpty()) .Subscribe(async c => await RoutingSelectedChangedAsync(c)); this.WhenAnyValue( @@ -263,9 +263,9 @@ namespace ServiceLib.ViewModels ProfileItem it = lstModel[k]; string name = it.GetSummary(); - var item = new ComboItem() { ID = it.indexId, Text = name }; + var item = new ComboItem() { ID = it.IndexId, Text = name }; _servers.Add(item); - if (_config.IndexId == it.indexId) + if (_config.IndexId == it.IndexId) { SelectedServer = item; } @@ -358,7 +358,7 @@ namespace ServiceLib.ViewModels foreach (var item in routings) { _routingItems.Add(item); - if (item.id == _config.RoutingBasicItem.RoutingIndexId) + if (item.Id == _config.RoutingBasicItem.RoutingIndexId) { SelectedRouting = item; } @@ -377,12 +377,12 @@ namespace ServiceLib.ViewModels return; } - var item = await AppHandler.Instance.GetRoutingItem(SelectedRouting?.id); + var item = await AppHandler.Instance.GetRoutingItem(SelectedRouting?.Id); if (item is null) { return; } - if (_config.RoutingBasicItem.RoutingIndexId == item.id) + if (_config.RoutingBasicItem.RoutingIndexId == item.Id) { return; } diff --git a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs index 3f38ab9a..ac7a6472 100644 --- a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs @@ -21,12 +21,12 @@ namespace ServiceLib.ViewModels await SaveSubAsync(); }); - SelectedSource = subItem.id.IsNullOrEmpty() ? subItem : JsonUtils.DeepCopy(subItem); + SelectedSource = subItem.Id.IsNullOrEmpty() ? subItem : JsonUtils.DeepCopy(subItem); } private async Task SaveSubAsync() { - var remarks = SelectedSource.remarks; + var remarks = SelectedSource.Remarks; if (Utils.IsNullOrEmpty(remarks)) { NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks); diff --git a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs index 840c1c7e..2e4f04d3 100644 --- a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs @@ -29,7 +29,7 @@ namespace ServiceLib.ViewModels var canEditRemove = this.WhenAnyValue( x => x.SelectedSource, - selectedSource => selectedSource != null && !selectedSource.id.IsNullOrEmpty()); + selectedSource => selectedSource != null && !selectedSource.Id.IsNullOrEmpty()); SubAddCmd = ReactiveCommand.CreateFromTask(async () => { @@ -45,7 +45,7 @@ namespace ServiceLib.ViewModels }, canEditRemove); SubShareCmd = ReactiveCommand.CreateFromTask(async () => { - await _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url); + await _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.Url); }, canEditRemove); Init(); @@ -73,7 +73,7 @@ namespace ServiceLib.ViewModels } else { - item = await AppHandler.Instance.GetSubItem(SelectedSource?.id); + item = await AppHandler.Instance.GetSubItem(SelectedSource?.Id); if (item is null) { return; @@ -95,7 +95,7 @@ namespace ServiceLib.ViewModels foreach (var it in SelectedSources ?? [SelectedSource]) { - await ConfigHandler.DeleteSubItem(_config, it.id); + await ConfigHandler.DeleteSubItem(_config, it.Id); } await RefreshSubItems(); NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); diff --git a/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml.cs b/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml.cs index 5ca98956..22849578 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/AddServer2Window.axaml.cs @@ -31,11 +31,11 @@ namespace v2rayN.Desktop.Views this.WhenActivated(disposables => { - this.Bind(ViewModel, vm => vm.SelectedSource.remarks, v => v.txtRemarks.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.address, v => v.txtAddress.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Remarks, v => v.txtRemarks.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Address, v => v.txtAddress.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.CoreType, v => v.cmbCoreType.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.displayLog, v => v.togDisplayLog.IsChecked).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.preSocksPort, v => v.txtPreSocksPort.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.DisplayLog, v => v.togDisplayLog.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.PreSocksPort, v => v.txtPreSocksPort.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.BrowseServerCmd, v => v.btnBrowse).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.EditServerCmd, v => v.btnEdit).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs index 9c00aadf..4ad21c7a 100644 --- a/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/AddServerWindow.axaml.cs @@ -26,7 +26,7 @@ namespace v2rayN.Desktop.Views ViewModel = new AddServerViewModel(profileItem, UpdateViewHandler); - if (profileItem.configType == EConfigType.VLESS) + if (profileItem.ConfigType == EConfigType.VLESS) { Global.CoreTypes4VLESS.ForEach(it => { @@ -63,7 +63,7 @@ namespace v2rayN.Desktop.Views cmbAlpn.Items.Add(it); }); - switch (profileItem.configType) + switch (profileItem.ConfigType) { case EConfigType.VMess: gridVMess.IsVisible = true; @@ -71,9 +71,9 @@ namespace v2rayN.Desktop.Views { cmbSecurity.Items.Add(it); }); - if (profileItem.security.IsNullOrEmpty()) + if (profileItem.Security.IsNullOrEmpty()) { - profileItem.security = Global.DefaultSecurity; + profileItem.Security = Global.DefaultSecurity; } break; @@ -97,9 +97,9 @@ namespace v2rayN.Desktop.Views { cmbFlow5.Items.Add(it); }); - if (profileItem.security.IsNullOrEmpty()) + if (profileItem.Security.IsNullOrEmpty()) { - profileItem.security = Global.None; + profileItem.Security = Global.None; } break; @@ -151,80 +151,80 @@ namespace v2rayN.Desktop.Views this.WhenActivated(disposables => { this.Bind(ViewModel, vm => vm.CoreType, v => v.cmbCoreType.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.remarks, v => v.txtRemarks.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.address, v => v.txtAddress.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.port, v => v.txtPort.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Remarks, v => v.txtRemarks.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Address, v => v.txtAddress.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Port, v => v.txtPort.Text).DisposeWith(disposables); - switch (profileItem.configType) + switch (profileItem.ConfigType) { case EConfigType.VMess: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.alterId, v => v.txtAlterId.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.cmbSecurity.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.AlterId, v => v.txtAlterId.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.cmbSecurity.SelectedValue).DisposeWith(disposables); break; case EConfigType.Shadowsocks: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId3.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.cmbSecurity3.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId3.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.cmbSecurity3.SelectedValue).DisposeWith(disposables); break; case EConfigType.SOCKS: case EConfigType.HTTP: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId4.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity4.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId4.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity4.Text).DisposeWith(disposables); break; case EConfigType.VLESS: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId5.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.flow, v => v.cmbFlow5.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity5.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId5.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Flow, v => v.cmbFlow5.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity5.Text).DisposeWith(disposables); break; case EConfigType.Trojan: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId6.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.flow, v => v.cmbFlow6.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId6.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Flow, v => v.cmbFlow6.SelectedValue).DisposeWith(disposables); break; case EConfigType.Hysteria2: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId7.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath7.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId7.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath7.Text).DisposeWith(disposables); break; case EConfigType.TUIC: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId8.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity8.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType8.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId8.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity8.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.SelectedValue).DisposeWith(disposables); break; case EConfigType.WireGuard: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId9.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.publicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath9.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.requestHost, v => v.txtRequestHost9.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.shortId, v => v.txtShortId9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.PublicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.ShortId, v => v.txtShortId9.Text).DisposeWith(disposables); break; } - this.Bind(ViewModel, vm => vm.SelectedSource.network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.requestHost, v => v.txtRequestHost.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.streamSecurity, v => v.cmbStreamSecurity.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.sni, v => v.txtSNI.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.allowInsecure, v => v.cmbAllowInsecure.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.fingerprint, v => v.cmbFingerprint.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.alpn, v => v.cmbAlpn.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.AllowInsecure, v => v.cmbAllowInsecure.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Fingerprint, v => v.cmbFingerprint.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Alpn, v => v.cmbAlpn.SelectedValue).DisposeWith(disposables); //reality - this.Bind(ViewModel, vm => vm.SelectedSource.sni, v => v.txtSNI2.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.fingerprint, v => v.cmbFingerprint2.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.publicKey, v => v.txtPublicKey.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.shortId, v => v.txtShortId.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.spiderX, v => v.txtSpiderX.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI2.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Fingerprint, v => v.cmbFingerprint2.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.PublicKey, v => v.txtPublicKey.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.ShortId, v => v.txtShortId.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.SpiderX, v => v.txtSpiderX.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - this.Title = $"{profileItem.configType}"; + this.Title = $"{profileItem.ConfigType}"; } private async Task UpdateViewHandler(EViewAction action, object? obj) diff --git a/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml b/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml index ce64ce2c..0c3477c2 100644 --- a/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/ClashProxiesView.axaml @@ -154,7 +154,7 @@ Background="YellowGreen" CornerRadius="4" DockPanel.Dock="Left" - IsVisible="{Binding isActive}" /> + IsVisible="{Binding IsActive}" /> diff --git a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml index 53e0e305..5cc3d6f6 100644 --- a/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/ProfilesView.axaml @@ -20,7 +20,7 @@ @@ -124,7 +124,7 @@ @@ -153,11 +153,11 @@ + Tag="ConfigType" /> - + @@ -168,12 +168,12 @@ Margin="0,0,8,0" Classes="Solid Red" Content="{x:Static resx:ResUI.TipActiveServer}" - IsVisible="{Binding isActive}" + IsVisible="{Binding IsActive}" Theme="{StaticResource TagLabel}" /> + Text="{Binding Remarks}" /> @@ -181,30 +181,30 @@ + Tag="Address" /> + Tag="Port" /> + Tag="Network" /> + Tag="StreamSecurity" /> - + Tag="SubRemarks" /> + @@ -214,37 +214,37 @@ Margin="8,0" HorizontalAlignment="Right" VerticalAlignment="Center" - Foreground="{Binding delay, Converter={StaticResource DelayColorConverter}}" - Text="{Binding Path=delayVal, Mode=OneWay}" /> + Foreground="{Binding Delay, Converter={StaticResource DelayColorConverter}}" + Text="{Binding Path=DelayVal, Mode=OneWay}" /> + Tag="SpeedVal" /> + Tag="TodayUp" /> + Tag="TodayDown" /> + Tag="TotalUp" /> + Tag="TotalDown" /> diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs index a4ac7696..edf2926e 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleDetailsWindow.axaml.cs @@ -53,11 +53,11 @@ namespace v2rayN.Desktop.Views this.WhenActivated(disposables => { - this.Bind(ViewModel, vm => vm.SelectedSource.remarks, v => v.txtRemarks.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Remarks, v => v.txtRemarks.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.outboundTag, v => v.cmbOutboundTag.SelectedValue).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.port, v => v.txtPort.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.network, v => v.cmbNetwork.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.enabled, v => v.togEnabled.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Enabled, v => v.togEnabled.IsChecked).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Domain, v => v.txtDomain.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.IP, v => v.txtIP.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.Process, v => v.txtProcess.Text).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml index 12616690..fc3e7703 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml @@ -210,11 +210,11 @@ diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml.cs index 77fb4255..db233fc1 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/RoutingRuleSettingWindow.axaml.cs @@ -46,14 +46,14 @@ namespace v2rayN.Desktop.Views this.OneWayBind(ViewModel, vm => vm.RulesItems, v => v.lstRules.ItemsSource).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource, v => v.lstRules.SelectedItem).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedRouting.remarks, v => v.txtRemarks.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedRouting.domainStrategy, v => v.cmbdomainStrategy.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedRouting.domainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedRouting.Remarks, v => v.txtRemarks.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedRouting.DomainStrategy, v => v.cmbdomainStrategy.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedRouting.DomainStrategy4Singbox, v => v.cmbdomainStrategy4Singbox.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedRouting.url, v => v.txtUrl.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedRouting.customIcon, v => v.txtCustomIcon.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedRouting.customRulesetPath4Singbox, v => v.txtCustomRulesetPath4Singbox.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedRouting.sort, v => v.txtSort.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedRouting.Url, v => v.txtUrl.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedRouting.CustomIcon, v => v.txtCustomIcon.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedRouting.CustomRulesetPath4Singbox, v => v.txtCustomRulesetPath4Singbox.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedRouting.Sort, v => v.txtSort.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.RuleAddCmd, v => v.menuRuleAdd).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ImportRulesFromFileCmd, v => v.menuImportRulesFromFile).DisposeWith(disposables); diff --git a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml index 3ba7aa9b..b8f59c0b 100644 --- a/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/RoutingSettingWindow.axaml @@ -109,26 +109,26 @@ - + diff --git a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml index d46ae9ab..9d3b99f5 100644 --- a/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml +++ b/v2rayN/v2rayN.Desktop/Views/StatusBarView.axaml @@ -69,7 +69,7 @@ x:Name="cmbRoutings2" Width="160" Margin="8,0" - DisplayMemberBinding="{Binding remarks}" + DisplayMemberBinding="{Binding Remarks}" ItemsSource="{Binding RoutingItems}" ToolTip.Tip="{x:Static resx:ResUI.menuRouting}" /> diff --git a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs index f3ec02c7..905e022c 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs +++ b/v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs @@ -29,18 +29,18 @@ namespace v2rayN.Desktop.Views this.WhenActivated(disposables => { - this.Bind(ViewModel, vm => vm.SelectedSource.remarks, v => v.txtRemarks.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.url, v => v.txtUrl.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.moreUrl, v => v.txtMoreUrl.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.enabled, v => v.togEnable.IsChecked).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.autoUpdateInterval, v => v.txtAutoUpdateInterval.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.userAgent, v => v.txtUserAgent.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.sort, v => v.txtSort.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.filter, v => v.txtFilter.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.convertTarget, v => v.cmbConvertTarget.SelectedValue).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.prevProfile, v => v.txtPrevProfile.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.nextProfile, v => v.txtNextProfile.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.preSocksPort, v => v.txtPreSocksPort.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Remarks, v => v.txtRemarks.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Url, v => v.txtUrl.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.MoreUrl, v => v.txtMoreUrl.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Enabled, v => v.togEnable.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.AutoUpdateInterval, v => v.txtAutoUpdateInterval.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.UserAgent, v => v.txtUserAgent.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Sort, v => v.txtSort.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Filter, v => v.txtFilter.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.ConvertTarget, v => v.cmbConvertTarget.SelectedValue).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.PrevProfile, v => v.txtPrevProfile.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.NextProfile, v => v.txtNextProfile.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.PreSocksPort, v => v.txtPreSocksPort.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); diff --git a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml index 23974c14..7d43eb37 100644 --- a/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml +++ b/v2rayN/v2rayN.Desktop/Views/SubSettingWindow.axaml @@ -50,27 +50,27 @@ diff --git a/v2rayN/v2rayN/Handler/WindowsHandler.cs b/v2rayN/v2rayN/Handler/WindowsHandler.cs index 4a5ef4c0..6fe94cf4 100644 --- a/v2rayN/v2rayN/Handler/WindowsHandler.cs +++ b/v2rayN/v2rayN/Handler/WindowsHandler.cs @@ -60,7 +60,7 @@ namespace v2rayN.Handler } var item = await ConfigHandler.GetDefaultRouting(config); - if (item == null || Utils.IsNullOrEmpty(item.customIcon) || !File.Exists(item.customIcon)) + if (item == null || Utils.IsNullOrEmpty(item.CustomIcon) || !File.Exists(item.CustomIcon)) { return null; } @@ -81,7 +81,7 @@ namespace v2rayN.Handler graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //graphics.FillRectangle(drawBrush, new Rectangle(0, 0, width, height)); - graphics.DrawImage(new Bitmap(item.customIcon), 0, 0, width, height); + graphics.DrawImage(new Bitmap(item.CustomIcon), 0, 0, width, height); graphics.FillEllipse(drawBrush, width / 2, width / 2, width / 2, width / 2); Icon createdIcon = Icon.FromHandle(bitmap.GetHicon()); diff --git a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs index 19904340..caab9c73 100644 --- a/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServer2Window.xaml.cs @@ -24,11 +24,11 @@ namespace v2rayN.Views this.WhenActivated(disposables => { - this.Bind(ViewModel, vm => vm.SelectedSource.remarks, v => v.txtRemarks.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.address, v => v.txtAddress.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Remarks, v => v.txtRemarks.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Address, v => v.txtAddress.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.CoreType, v => v.cmbCoreType.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.displayLog, v => v.togDisplayLog.IsChecked).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.preSocksPort, v => v.txtPreSocksPort.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.DisplayLog, v => v.togDisplayLog.IsChecked).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.PreSocksPort, v => v.txtPreSocksPort.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.BrowseServerCmd, v => v.btnBrowse).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.EditServerCmd, v => v.btnEdit).DisposeWith(disposables); diff --git a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs index 6d95e23d..2cb5a685 100644 --- a/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs +++ b/v2rayN/v2rayN/Views/AddServerWindow.xaml.cs @@ -20,7 +20,7 @@ namespace v2rayN.Views ViewModel = new AddServerViewModel(profileItem, UpdateViewHandler); - if (profileItem.configType == EConfigType.VLESS) + if (profileItem.ConfigType == EConfigType.VLESS) { Global.CoreTypes4VLESS.ForEach(it => { @@ -57,7 +57,7 @@ namespace v2rayN.Views cmbAlpn.Items.Add(it); }); - switch (profileItem.configType) + switch (profileItem.ConfigType) { case EConfigType.VMess: gridVMess.Visibility = Visibility.Visible; @@ -65,9 +65,9 @@ namespace v2rayN.Views { cmbSecurity.Items.Add(it); }); - if (profileItem.security.IsNullOrEmpty()) + if (profileItem.Security.IsNullOrEmpty()) { - profileItem.security = Global.DefaultSecurity; + profileItem.Security = Global.DefaultSecurity; } break; @@ -91,9 +91,9 @@ namespace v2rayN.Views { cmbFlow5.Items.Add(it); }); - if (profileItem.security.IsNullOrEmpty()) + if (profileItem.Security.IsNullOrEmpty()) { - profileItem.security = Global.None; + profileItem.Security = Global.None; } break; @@ -145,80 +145,80 @@ namespace v2rayN.Views this.WhenActivated(disposables => { this.Bind(ViewModel, vm => vm.CoreType, v => v.cmbCoreType.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.remarks, v => v.txtRemarks.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.address, v => v.txtAddress.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.port, v => v.txtPort.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Remarks, v => v.txtRemarks.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Address, v => v.txtAddress.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Port, v => v.txtPort.Text).DisposeWith(disposables); - switch (profileItem.configType) + switch (profileItem.ConfigType) { case EConfigType.VMess: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.alterId, v => v.txtAlterId.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.cmbSecurity.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.AlterId, v => v.txtAlterId.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.cmbSecurity.Text).DisposeWith(disposables); break; case EConfigType.Shadowsocks: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId3.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.cmbSecurity3.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId3.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.cmbSecurity3.Text).DisposeWith(disposables); break; case EConfigType.SOCKS: case EConfigType.HTTP: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId4.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity4.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId4.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity4.Text).DisposeWith(disposables); break; case EConfigType.VLESS: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId5.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.flow, v => v.cmbFlow5.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity5.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId5.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Flow, v => v.cmbFlow5.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity5.Text).DisposeWith(disposables); break; case EConfigType.Trojan: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId6.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.flow, v => v.cmbFlow6.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId6.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Flow, v => v.cmbFlow6.Text).DisposeWith(disposables); break; case EConfigType.Hysteria2: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId7.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath7.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId7.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath7.Text).DisposeWith(disposables); break; case EConfigType.TUIC: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId8.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.security, v => v.txtSecurity8.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType8.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId8.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Security, v => v.txtSecurity8.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType8.Text).DisposeWith(disposables); break; case EConfigType.WireGuard: - this.Bind(ViewModel, vm => vm.SelectedSource.id, v => v.txtId9.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.publicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath9.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.requestHost, v => v.txtRequestHost9.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.shortId, v => v.txtShortId9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Id, v => v.txtId9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.PublicKey, v => v.txtPublicKey9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost9.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.ShortId, v => v.txtShortId9.Text).DisposeWith(disposables); break; } - this.Bind(ViewModel, vm => vm.SelectedSource.network, v => v.cmbNetwork.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.headerType, v => v.cmbHeaderType.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.requestHost, v => v.txtRequestHost.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.path, v => v.txtPath.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Network, v => v.cmbNetwork.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.HeaderType, v => v.cmbHeaderType.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.RequestHost, v => v.txtRequestHost.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Path, v => v.txtPath.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.streamSecurity, v => v.cmbStreamSecurity.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.sni, v => v.txtSNI.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.allowInsecure, v => v.cmbAllowInsecure.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.fingerprint, v => v.cmbFingerprint.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.alpn, v => v.cmbAlpn.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.StreamSecurity, v => v.cmbStreamSecurity.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.AllowInsecure, v => v.cmbAllowInsecure.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Fingerprint, v => v.cmbFingerprint.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Alpn, v => v.cmbAlpn.Text).DisposeWith(disposables); //reality - this.Bind(ViewModel, vm => vm.SelectedSource.sni, v => v.txtSNI2.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.fingerprint, v => v.cmbFingerprint2.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.publicKey, v => v.txtPublicKey.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.shortId, v => v.txtShortId.Text).DisposeWith(disposables); - this.Bind(ViewModel, vm => vm.SelectedSource.spiderX, v => v.txtSpiderX.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Sni, v => v.txtSNI2.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.Fingerprint, v => v.cmbFingerprint2.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.PublicKey, v => v.txtPublicKey.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.ShortId, v => v.txtShortId.Text).DisposeWith(disposables); + this.Bind(ViewModel, vm => vm.SelectedSource.SpiderX, v => v.txtSpiderX.Text).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); }); - this.Title = $"{profileItem.configType}"; + this.Title = $"{profileItem.ConfigType}"; WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark); } diff --git a/v2rayN/v2rayN/Views/ClashProxiesView.xaml b/v2rayN/v2rayN/Views/ClashProxiesView.xaml index d461ecde..0e333222 100644 --- a/v2rayN/v2rayN/Views/ClashProxiesView.xaml +++ b/v2rayN/v2rayN/Views/ClashProxiesView.xaml @@ -161,7 +161,7 @@ Background="{DynamicResource MaterialDesign.Brush.Primary.Light}" CornerRadius="4" DockPanel.Dock="Left" - Visibility="{Binding Path=isActive, Converter={StaticResource BoolToVisConverter}}" /> + Visibility="{Binding Path=IsActive, Converter={StaticResource BoolToVisConverter}}" /> diff --git a/v2rayN/v2rayN/Views/ProfilesView.xaml b/v2rayN/v2rayN/Views/ProfilesView.xaml index 85427c0f..1d4c57d4 100644 --- a/v2rayN/v2rayN/Views/ProfilesView.xaml +++ b/v2rayN/v2rayN/Views/ProfilesView.xaml @@ -30,7 +30,7 @@ Style="{StaticResource MaterialDesignChoiceChipPrimaryOutlineListBox}"> - + @@ -162,7 +162,7 @@ x:Name="cmbMoveToGroup" Width="200" materialDesign:HintAssist.Hint="{x:Static resx:ResUI.menuSubscription}" - DisplayMemberPath="remarks" + DisplayMemberPath="Remarks" FontSize="{DynamicResource StdFontSize}" Style="{StaticResource MaterialDesignFilledComboBox}" /> @@ -224,7 +224,7 @@