mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-14 04:19:12 +00:00
Rename Manager
This commit is contained in:
parent
2060ac18fd
commit
d5c50ef27c
74 changed files with 383 additions and 383 deletions
|
@ -216,7 +216,7 @@ public static class ConfigHandler
|
||||||
/// <returns>Result of the operation (0 if successful, -1 if failed)</returns>
|
/// <returns>Result of the operation (0 if successful, -1 if failed)</returns>
|
||||||
public static async Task<int> AddServer(Config config, ProfileItem profileItem)
|
public static async Task<int> AddServer(Config config, ProfileItem profileItem)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(profileItem.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
item = profileItem;
|
item = profileItem;
|
||||||
|
@ -336,7 +336,7 @@ public static class ConfigHandler
|
||||||
{
|
{
|
||||||
foreach (var it in indexes)
|
foreach (var it in indexes)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(it.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -418,7 +418,7 @@ public static class ConfigHandler
|
||||||
/// <returns>The default profile item or null if none exists</returns>
|
/// <returns>The default profile item or null if none exists</returns>
|
||||||
public static async Task<ProfileItem?> GetDefaultServer(Config config)
|
public static async Task<ProfileItem?> GetDefaultServer(Config config)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(config.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(config.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
var item2 = await SQLiteHelper.Instance.TableAsync<ProfileItem>().FirstOrDefaultAsync();
|
var item2 = await SQLiteHelper.Instance.TableAsync<ProfileItem>().FirstOrDefaultAsync();
|
||||||
|
@ -449,7 +449,7 @@ public static class ConfigHandler
|
||||||
|
|
||||||
for (int i = 0; i < lstProfile.Count; i++)
|
for (int i = 0; i < lstProfile.Count; i++)
|
||||||
{
|
{
|
||||||
ProfileExHandler.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10);
|
ProfileExManager.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
var sort = 0;
|
var sort = 0;
|
||||||
|
@ -461,7 +461,7 @@ public static class ConfigHandler
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sort = ProfileExHandler.Instance.GetSort(lstProfile.First().IndexId) - 1;
|
sort = ProfileExManager.Instance.GetSort(lstProfile.First().IndexId) - 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -471,7 +471,7 @@ public static class ConfigHandler
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sort = ProfileExHandler.Instance.GetSort(lstProfile[index - 1].IndexId) - 1;
|
sort = ProfileExManager.Instance.GetSort(lstProfile[index - 1].IndexId) - 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -482,7 +482,7 @@ public static class ConfigHandler
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sort = ProfileExHandler.Instance.GetSort(lstProfile[index + 1].IndexId) + 1;
|
sort = ProfileExManager.Instance.GetSort(lstProfile[index + 1].IndexId) + 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -492,7 +492,7 @@ public static class ConfigHandler
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sort = ProfileExHandler.Instance.GetSort(lstProfile[^1].IndexId) + 1;
|
sort = ProfileExManager.Instance.GetSort(lstProfile[^1].IndexId) + 1;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -501,7 +501,7 @@ public static class ConfigHandler
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProfileExHandler.Instance.SetSort(lstProfile[index].IndexId, sort);
|
ProfileExManager.Instance.SetSort(lstProfile[index].IndexId, sort);
|
||||||
return await Task.FromResult(0);
|
return await Task.FromResult(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +559,7 @@ public static class ConfigHandler
|
||||||
/// <returns>0 if successful, -1 if failed</returns>
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> EditCustomServer(Config config, ProfileItem profileItem)
|
public static async Task<int> EditCustomServer(Config config, ProfileItem profileItem)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(profileItem.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(profileItem.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
item = profileItem;
|
item = profileItem;
|
||||||
|
@ -601,7 +601,7 @@ public static class ConfigHandler
|
||||||
profileItem.Id = profileItem.Id.TrimEx();
|
profileItem.Id = profileItem.Id.TrimEx();
|
||||||
profileItem.Security = profileItem.Security.TrimEx();
|
profileItem.Security = profileItem.Security.TrimEx();
|
||||||
|
|
||||||
if (!AppHandler.Instance.GetShadowsocksSecurities(profileItem).Contains(profileItem.Security))
|
if (!AppManager.Instance.GetShadowsocksSecurities(profileItem).Contains(profileItem.Security))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -829,13 +829,13 @@ public static class ConfigHandler
|
||||||
/// <returns>0 if successful, -1 if failed</returns>
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> SortServers(Config config, string subId, string colName, bool asc)
|
public static async Task<int> SortServers(Config config, string subId, string colName, bool asc)
|
||||||
{
|
{
|
||||||
var lstModel = await AppHandler.Instance.ProfileItems(subId, "");
|
var lstModel = await AppManager.Instance.ProfileItems(subId, "");
|
||||||
if (lstModel.Count <= 0)
|
if (lstModel.Count <= 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
var lstServerStat = (config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? [];
|
var lstServerStat = (config.GuiItem.EnableStatistics ? StatisticsManager.Instance.ServerStat : null) ?? [];
|
||||||
var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs();
|
var lstProfileExs = await ProfileExManager.Instance.GetProfileExs();
|
||||||
var lstProfile = (from t in lstModel
|
var lstProfile = (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()
|
from t22 in t2b.DefaultIfEmpty()
|
||||||
|
@ -905,7 +905,7 @@ public static class ConfigHandler
|
||||||
|
|
||||||
for (var i = 0; i < lstProfile.Count; i++)
|
for (var i = 0; i < lstProfile.Count; i++)
|
||||||
{
|
{
|
||||||
ProfileExHandler.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10);
|
ProfileExManager.Instance.SetSort(lstProfile[i].IndexId, (i + 1) * 10);
|
||||||
}
|
}
|
||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
|
@ -914,7 +914,7 @@ public static class ConfigHandler
|
||||||
var maxSort = lstProfile.Max(t => t.Sort) + 10;
|
var maxSort = lstProfile.Max(t => t.Sort) + 10;
|
||||||
foreach (var item in lstProfile.Where(item => item.Delay <= 0))
|
foreach (var item in lstProfile.Where(item => item.Delay <= 0))
|
||||||
{
|
{
|
||||||
ProfileExHandler.Instance.SetSort(item.IndexId, maxSort);
|
ProfileExManager.Instance.SetSort(item.IndexId, maxSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -924,7 +924,7 @@ public static class ConfigHandler
|
||||||
var maxSort = lstProfile.Max(t => t.Sort) + 10;
|
var maxSort = lstProfile.Max(t => t.Sort) + 10;
|
||||||
foreach (var item in lstProfile.Where(item => item.Speed <= 0))
|
foreach (var item in lstProfile.Where(item => item.Speed <= 0))
|
||||||
{
|
{
|
||||||
ProfileExHandler.Instance.SetSort(item.IndexId, maxSort);
|
ProfileExManager.Instance.SetSort(item.IndexId, maxSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -982,7 +982,7 @@ public static class ConfigHandler
|
||||||
/// <returns>Tuple with total count and remaining count after deduplication</returns>
|
/// <returns>Tuple with total count and remaining count after deduplication</returns>
|
||||||
public static async Task<Tuple<int, int>> DedupServerList(Config config, string subId)
|
public static async Task<Tuple<int, int>> DedupServerList(Config config, string subId)
|
||||||
{
|
{
|
||||||
var lstProfile = await AppHandler.Instance.ProfileItems(subId);
|
var lstProfile = await AppManager.Instance.ProfileItems(subId);
|
||||||
if (lstProfile == null)
|
if (lstProfile == null)
|
||||||
{
|
{
|
||||||
return new Tuple<int, int>(0, 0);
|
return new Tuple<int, int>(0, 0);
|
||||||
|
@ -1052,15 +1052,15 @@ public static class ConfigHandler
|
||||||
if (profileItem.IndexId.IsNullOrEmpty())
|
if (profileItem.IndexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
profileItem.IndexId = Utils.GetGuid(false);
|
profileItem.IndexId = Utils.GetGuid(false);
|
||||||
maxSort = ProfileExHandler.Instance.GetMaxSort();
|
maxSort = ProfileExManager.Instance.GetMaxSort();
|
||||||
}
|
}
|
||||||
if (!toFile && maxSort < 0)
|
if (!toFile && maxSort < 0)
|
||||||
{
|
{
|
||||||
maxSort = ProfileExHandler.Instance.GetMaxSort();
|
maxSort = ProfileExManager.Instance.GetMaxSort();
|
||||||
}
|
}
|
||||||
if (maxSort > 0)
|
if (maxSort > 0)
|
||||||
{
|
{
|
||||||
ProfileExHandler.Instance.SetSort(profileItem.IndexId, maxSort + 1);
|
ProfileExManager.Instance.SetSort(profileItem.IndexId, maxSort + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toFile)
|
if (toFile)
|
||||||
|
@ -1120,7 +1120,7 @@ public static class ConfigHandler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(indexId);
|
var item = await AppManager.Instance.GetProfileItem(indexId);
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1165,7 +1165,7 @@ public static class ConfigHandler
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
var profileItem = await AppHandler.Instance.GetProfileItem(indexId) ?? new();
|
var profileItem = await AppManager.Instance.GetProfileItem(indexId) ?? new();
|
||||||
profileItem.IndexId = indexId;
|
profileItem.IndexId = indexId;
|
||||||
if (coreType == ECoreType.Xray)
|
if (coreType == ECoreType.Xray)
|
||||||
{
|
{
|
||||||
|
@ -1211,7 +1211,7 @@ public static class ConfigHandler
|
||||||
ConfigType = EConfigType.SOCKS,
|
ConfigType = EConfigType.SOCKS,
|
||||||
Address = Global.Loopback,
|
Address = Global.Loopback,
|
||||||
Sni = node.Address, //Tun2SocksAddress
|
Sni = node.Address, //Tun2SocksAddress
|
||||||
Port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)
|
Port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if ((node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0))
|
else if ((node.ConfigType == EConfigType.Custom && node.PreSocksPort > 0))
|
||||||
|
@ -1238,12 +1238,12 @@ public static class ConfigHandler
|
||||||
/// <returns>Number of removed servers or -1 if failed</returns>
|
/// <returns>Number of removed servers or -1 if failed</returns>
|
||||||
public static async Task<int> RemoveInvalidServerResult(Config config, string subid)
|
public static async Task<int> RemoveInvalidServerResult(Config config, string subid)
|
||||||
{
|
{
|
||||||
var lstModel = await AppHandler.Instance.ProfileItems(subid, "");
|
var lstModel = await AppManager.Instance.ProfileItems(subid, "");
|
||||||
if (lstModel is { Count: <= 0 })
|
if (lstModel is { Count: <= 0 })
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs();
|
var lstProfileExs = await ProfileExManager.Instance.GetProfileExs();
|
||||||
var lstProfile = (from t in lstModel
|
var lstProfile = (from t in lstModel
|
||||||
join t2 in lstProfileExs on t.IndexId equals t2.IndexId
|
join t2 in lstProfileExs on t.IndexId equals t2.IndexId
|
||||||
where t2.Delay == -1
|
where t2.Delay == -1
|
||||||
|
@ -1279,7 +1279,7 @@ public static class ConfigHandler
|
||||||
if (isSub && subid.IsNotEmpty())
|
if (isSub && subid.IsNotEmpty())
|
||||||
{
|
{
|
||||||
await RemoveServersViaSubid(config, subid, isSub);
|
await RemoveServersViaSubid(config, subid, isSub);
|
||||||
subFilter = (await AppHandler.Instance.GetSubItem(subid))?.Filter ?? "";
|
subFilter = (await AppManager.Instance.GetSubItem(subid))?.Filter ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
var countServers = 0;
|
var countServers = 0;
|
||||||
|
@ -1363,7 +1363,7 @@ public static class ConfigHandler
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var subItem = await AppHandler.Instance.GetSubItem(subid);
|
var subItem = await AppManager.Instance.GetSubItem(subid);
|
||||||
var subRemarks = subItem?.Remarks;
|
var subRemarks = subItem?.Remarks;
|
||||||
var preSocksPort = subItem?.PreSocksPort;
|
var preSocksPort = subItem?.PreSocksPort;
|
||||||
|
|
||||||
|
@ -1519,7 +1519,7 @@ public static class ConfigHandler
|
||||||
ProfileItem? activeProfile = null;
|
ProfileItem? activeProfile = null;
|
||||||
if (isSub && subid.IsNotEmpty())
|
if (isSub && subid.IsNotEmpty())
|
||||||
{
|
{
|
||||||
lstOriSub = await AppHandler.Instance.ProfileItems(subid);
|
lstOriSub = await AppManager.Instance.ProfileItems(subid);
|
||||||
activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == config.IndexId);
|
activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == config.IndexId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1551,7 +1551,7 @@ public static class ConfigHandler
|
||||||
//Select active node
|
//Select active node
|
||||||
if (activeProfile != null)
|
if (activeProfile != null)
|
||||||
{
|
{
|
||||||
var lstSub = await AppHandler.Instance.ProfileItems(subid);
|
var lstSub = await AppManager.Instance.ProfileItems(subid);
|
||||||
var existItem = lstSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == activeProfile.Remarks : CompareProfileItem(t, activeProfile, true));
|
var existItem = lstSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == activeProfile.Remarks : CompareProfileItem(t, activeProfile, true));
|
||||||
if (existItem != null)
|
if (existItem != null)
|
||||||
{
|
{
|
||||||
|
@ -1562,13 +1562,13 @@ public static class ConfigHandler
|
||||||
//Keep the last traffic statistics
|
//Keep the last traffic statistics
|
||||||
if (lstOriSub != null)
|
if (lstOriSub != null)
|
||||||
{
|
{
|
||||||
var lstSub = await AppHandler.Instance.ProfileItems(subid);
|
var lstSub = await AppManager.Instance.ProfileItems(subid);
|
||||||
foreach (var item in lstSub)
|
foreach (var item in lstSub)
|
||||||
{
|
{
|
||||||
var existItem = lstOriSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == item.Remarks : CompareProfileItem(t, item, true));
|
var existItem = lstOriSub?.FirstOrDefault(t => config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.Remarks == item.Remarks : CompareProfileItem(t, item, true));
|
||||||
if (existItem != null)
|
if (existItem != null)
|
||||||
{
|
{
|
||||||
await StatisticsHandler.Instance.CloneServerStatItem(existItem.IndexId, item.IndexId);
|
await StatisticsManager.Instance.CloneServerStatItem(existItem.IndexId, item.IndexId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1608,7 +1608,7 @@ public static class ConfigHandler
|
||||||
if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost))
|
if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost))
|
||||||
{
|
{
|
||||||
//TODO Temporary reminder to be removed later
|
//TODO Temporary reminder to be removed later
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.InsecureUrlProtocol);
|
NoticeManager.Instance.Enqueue(ResUI.InsecureUrlProtocol);
|
||||||
//return -1;
|
//return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1626,7 +1626,7 @@ public static class ConfigHandler
|
||||||
/// <returns>0 if successful, -1 if failed</returns>
|
/// <returns>0 if successful, -1 if failed</returns>
|
||||||
public static async Task<int> AddSubItem(Config config, SubItem subItem)
|
public static async Task<int> AddSubItem(Config config, SubItem subItem)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetSubItem(subItem.Id);
|
var item = await AppManager.Instance.GetSubItem(subItem.Id);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
item = subItem;
|
item = subItem;
|
||||||
|
@ -1658,7 +1658,7 @@ public static class ConfigHandler
|
||||||
var maxSort = 0;
|
var maxSort = 0;
|
||||||
if (await SQLiteHelper.Instance.TableAsync<SubItem>().CountAsync() > 0)
|
if (await SQLiteHelper.Instance.TableAsync<SubItem>().CountAsync() > 0)
|
||||||
{
|
{
|
||||||
var lstSubs = (await AppHandler.Instance.SubItems());
|
var lstSubs = (await AppManager.Instance.SubItems());
|
||||||
maxSort = lstSubs.LastOrDefault()?.Sort ?? 0;
|
maxSort = lstSubs.LastOrDefault()?.Sort ?? 0;
|
||||||
}
|
}
|
||||||
item.Sort = maxSort + 1;
|
item.Sort = maxSort + 1;
|
||||||
|
@ -1712,7 +1712,7 @@ public static class ConfigHandler
|
||||||
/// <returns>0 if successful</returns>
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> DeleteSubItem(Config config, string id)
|
public static async Task<int> DeleteSubItem(Config config, string id)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetSubItem(id);
|
var item = await AppManager.Instance.GetSubItem(id);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1896,7 +1896,7 @@ public static class ConfigHandler
|
||||||
/// <returns>0 if successful</returns>
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> SetDefaultRouting(Config config, RoutingItem routingItem)
|
public static async Task<int> SetDefaultRouting(Config config, RoutingItem routingItem)
|
||||||
{
|
{
|
||||||
var items = await AppHandler.Instance.RoutingItems();
|
var items = await AppManager.Instance.RoutingItems();
|
||||||
if (items.Any(t => t.Id == routingItem.Id && t.IsActive == true))
|
if (items.Any(t => t.Id == routingItem.Id && t.IsActive == true))
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1976,7 +1976,7 @@ public static class ConfigHandler
|
||||||
if (template == null)
|
if (template == null)
|
||||||
return await InitBuiltinRouting(config, blImportAdvancedRules); // fallback
|
return await InitBuiltinRouting(config, blImportAdvancedRules); // fallback
|
||||||
|
|
||||||
var items = await AppHandler.Instance.RoutingItems();
|
var items = await AppManager.Instance.RoutingItems();
|
||||||
var maxSort = items.Count;
|
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)
|
||||||
{
|
{
|
||||||
|
@ -2023,14 +2023,14 @@ public static class ConfigHandler
|
||||||
public static async Task<int> InitBuiltinRouting(Config config, bool blImportAdvancedRules = false)
|
public static async Task<int> InitBuiltinRouting(Config config, bool blImportAdvancedRules = false)
|
||||||
{
|
{
|
||||||
var ver = "V3-";
|
var ver = "V3-";
|
||||||
var items = await AppHandler.Instance.RoutingItems();
|
var items = await AppManager.Instance.RoutingItems();
|
||||||
|
|
||||||
//TODO Temporary code to be removed later
|
//TODO Temporary code to be removed later
|
||||||
var lockItem = items?.FirstOrDefault(t => t.Locked == true);
|
var lockItem = items?.FirstOrDefault(t => t.Locked == true);
|
||||||
if (lockItem != null)
|
if (lockItem != null)
|
||||||
{
|
{
|
||||||
await ConfigHandler.RemoveRoutingItem(lockItem);
|
await ConfigHandler.RemoveRoutingItem(lockItem);
|
||||||
items = await AppHandler.Instance.RoutingItems();
|
items = await AppManager.Instance.RoutingItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!blImportAdvancedRules && items.Count > 0)
|
if (!blImportAdvancedRules && items.Count > 0)
|
||||||
|
@ -2107,7 +2107,7 @@ public static class ConfigHandler
|
||||||
/// <returns>0 if successful</returns>
|
/// <returns>0 if successful</returns>
|
||||||
public static async Task<int> InitBuiltinDNS(Config config)
|
public static async Task<int> InitBuiltinDNS(Config config)
|
||||||
{
|
{
|
||||||
var items = await AppHandler.Instance.DNSItems();
|
var items = await AppManager.Instance.DNSItems();
|
||||||
|
|
||||||
// Check existing DNS items and disable those with empty NormalDNS
|
// Check existing DNS items and disable those with empty NormalDNS
|
||||||
var needsUpdate = false;
|
var needsUpdate = false;
|
||||||
|
@ -2185,7 +2185,7 @@ public static class ConfigHandler
|
||||||
/// <returns>DNS item with configuration from the URL</returns>
|
/// <returns>DNS item with configuration from the URL</returns>
|
||||||
public static async Task<DNSItem> GetExternalDNSItem(ECoreType type, string url)
|
public static async Task<DNSItem> GetExternalDNSItem(ECoreType type, string url)
|
||||||
{
|
{
|
||||||
var currentItem = await AppHandler.Instance.GetDNSItem(type);
|
var currentItem = await AppManager.Instance.GetDNSItem(type);
|
||||||
|
|
||||||
var downloadHandle = new DownloadService();
|
var downloadHandle = new DownloadService();
|
||||||
var templateContent = await downloadHandle.TryDownloadString(url, true, "");
|
var templateContent = await downloadHandle.TryDownloadString(url, true, "");
|
||||||
|
@ -2247,7 +2247,7 @@ public static class ConfigHandler
|
||||||
|
|
||||||
public static async Task<int> InitBuiltinFullConfigTemplate(Config config)
|
public static async Task<int> InitBuiltinFullConfigTemplate(Config config)
|
||||||
{
|
{
|
||||||
var items = await AppHandler.Instance.FullConfigTemplateItem();
|
var items = await AppManager.Instance.FullConfigTemplateItem();
|
||||||
if (items.Count <= 0)
|
if (items.Count <= 0)
|
||||||
{
|
{
|
||||||
var item = new FullConfigTemplateItem()
|
var item = new FullConfigTemplateItem()
|
||||||
|
|
|
@ -13,7 +13,7 @@ public static class ConnectionHandler
|
||||||
|
|
||||||
private static async Task<string?> GetIPInfo(DownloadService downloadHandle)
|
private static async Task<string?> GetIPInfo(DownloadService downloadHandle)
|
||||||
{
|
{
|
||||||
var url = AppHandler.Instance.Config.SpeedTestItem.IPAPIUrl;
|
var url = AppManager.Instance.Config.SpeedTestItem.IPAPIUrl;
|
||||||
if (url.IsNullOrEmpty())
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -9,7 +9,7 @@ public static class CoreConfigHandler
|
||||||
|
|
||||||
public static async Task<RetResult> GenerateClientConfig(ProfileItem node, string? fileName)
|
public static async Task<RetResult> GenerateClientConfig(ProfileItem node, string? fileName)
|
||||||
{
|
{
|
||||||
var config = AppHandler.Instance.Config;
|
var config = AppManager.Instance.Config;
|
||||||
var result = new RetResult();
|
var result = new RetResult();
|
||||||
|
|
||||||
if (node.ConfigType == EConfigType.Custom)
|
if (node.ConfigType == EConfigType.Custom)
|
||||||
|
@ -21,7 +21,7 @@ public static class CoreConfigHandler
|
||||||
_ => await GenerateClientCustomConfig(node, fileName)
|
_ => await GenerateClientCustomConfig(node, fileName)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (AppHandler.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box)
|
else if (AppManager.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box)
|
||||||
{
|
{
|
||||||
result = await new CoreConfigSingboxService(config).GenerateClientConfigContent(node);
|
result = await new CoreConfigSingboxService(config).GenerateClientConfigContent(node);
|
||||||
}
|
}
|
||||||
|
@ -112,11 +112,11 @@ public static class CoreConfigHandler
|
||||||
public static async Task<RetResult> GenerateClientSpeedtestConfig(Config config, ProfileItem node, ServerTestItem testItem, string fileName)
|
public static async Task<RetResult> GenerateClientSpeedtestConfig(Config config, ProfileItem node, ServerTestItem testItem, string fileName)
|
||||||
{
|
{
|
||||||
var result = new RetResult();
|
var result = new RetResult();
|
||||||
var initPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest);
|
var initPort = AppManager.Instance.GetLocalPort(EInboundProtocol.speedtest);
|
||||||
var port = Utils.GetFreePort(initPort + testItem.QueueNum);
|
var port = Utils.GetFreePort(initPort + testItem.QueueNum);
|
||||||
testItem.Port = port;
|
testItem.Port = port;
|
||||||
|
|
||||||
if (AppHandler.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box)
|
if (AppManager.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box)
|
||||||
{
|
{
|
||||||
result = await new CoreConfigSingboxService(config).GenerateClientSpeedtestConfig(node, port);
|
result = await new CoreConfigSingboxService(config).GenerateClientSpeedtestConfig(node, port);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ public static class SubscriptionHandler
|
||||||
public static async Task UpdateProcess(Config config, string subId, bool blProxy, Action<bool, string> updateFunc)
|
public static async Task UpdateProcess(Config config, string subId, bool blProxy, Action<bool, string> updateFunc)
|
||||||
{
|
{
|
||||||
updateFunc?.Invoke(false, ResUI.MsgUpdateSubscriptionStart);
|
updateFunc?.Invoke(false, ResUI.MsgUpdateSubscriptionStart);
|
||||||
var subItem = await AppHandler.Instance.SubItems();
|
var subItem = await AppManager.Instance.SubItems();
|
||||||
|
|
||||||
if (subItem is not { Count: > 0 })
|
if (subItem is not { Count: > 0 })
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ public static class SysProxyHandler
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
|
var port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||||
var exceptions = config.SystemProxyItem.SystemProxyExceptions.Replace(" ", "");
|
var exceptions = config.SystemProxyItem.SystemProxyExceptions.Replace(" ", "");
|
||||||
if (port <= 0)
|
if (port <= 0)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ public static class SysProxyHandler
|
||||||
|
|
||||||
if (type != ESysProxyType.Pac && Utils.IsWindows())
|
if (type != ESysProxyType.Pac && Utils.IsWindows())
|
||||||
{
|
{
|
||||||
PacHandler.Instance.Stop();
|
PacManager.Instance.Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -90,8 +90,8 @@ public static class SysProxyHandler
|
||||||
|
|
||||||
private static async Task SetWindowsProxyPac(int port)
|
private static async Task SetWindowsProxyPac(int port)
|
||||||
{
|
{
|
||||||
var portPac = AppHandler.Instance.GetLocalPort(EInboundProtocol.pac);
|
var portPac = AppManager.Instance.GetLocalPort(EInboundProtocol.pac);
|
||||||
await PacHandler.Instance.StartAsync(Utils.GetConfigPath(), port, portPac);
|
await PacManager.Instance.StartAsync(Utils.GetConfigPath(), port, portPac);
|
||||||
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
|
var strProxy = $"{Global.HttpProtocol}{Global.Loopback}:{portPac}/pac?t={DateTime.Now.Ticks}";
|
||||||
ProxySettingWindows.SetProxy(strProxy, "", 4);
|
ProxySettingWindows.SetProxy(strProxy, "", 4);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public sealed class AppHandler
|
public sealed class AppManager
|
||||||
{
|
{
|
||||||
#region Property
|
#region Property
|
||||||
|
|
||||||
private static readonly Lazy<AppHandler> _instance = new(() => new());
|
private static readonly Lazy<AppManager> _instance = new(() => new());
|
||||||
private Config _config;
|
private Config _config;
|
||||||
private int? _statePort;
|
private int? _statePort;
|
||||||
private int? _statePort2;
|
private int? _statePort2;
|
||||||
private Job? _processJob;
|
private Job? _processJob;
|
||||||
public static AppHandler Instance => _instance.Value;
|
public static AppManager Instance => _instance.Value;
|
||||||
public Config Config => _config;
|
public Config Config => _config;
|
||||||
|
|
||||||
public int StatePort
|
public int StatePort
|
|
@ -2,10 +2,10 @@ using static ServiceLib.Models.ClashProxies;
|
||||||
|
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public sealed class ClashApiHandler
|
public sealed class ClashApiManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<ClashApiHandler> instance = new(() => new());
|
private static readonly Lazy<ClashApiManager> instance = new(() => new());
|
||||||
public static ClashApiHandler Instance => instance.Value;
|
public static ClashApiManager Instance => instance.Value;
|
||||||
|
|
||||||
private static readonly string _tag = "ClashApiHandler";
|
private static readonly string _tag = "ClashApiHandler";
|
||||||
private Dictionary<string, ProxiesItem>? _proxies;
|
private Dictionary<string, ProxiesItem>? _proxies;
|
||||||
|
@ -65,7 +65,7 @@ public sealed class ClashApiHandler
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var urlBase = $"{GetApiUrl()}/proxies";
|
var urlBase = $"{GetApiUrl()}/proxies";
|
||||||
urlBase += @"/{0}/delay?timeout=10000&url=" + AppHandler.Instance.Config.SpeedTestItem.SpeedPingTestUrl;
|
urlBase += @"/{0}/delay?timeout=10000&url=" + AppManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl;
|
||||||
|
|
||||||
var tasks = new List<Task>();
|
var tasks = new List<Task>();
|
||||||
foreach (var it in lstProxy)
|
foreach (var it in lstProxy)
|
||||||
|
@ -182,6 +182,6 @@ public sealed class ClashApiHandler
|
||||||
|
|
||||||
private string GetApiUrl()
|
private string GetApiUrl()
|
||||||
{
|
{
|
||||||
return $"{Global.HttpProtocol}{Global.Loopback}:{AppHandler.Instance.StatePort2}";
|
return $"{Global.HttpProtocol}{Global.Loopback}:{AppManager.Instance.StatePort2}";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,10 +5,10 @@ using CliWrap.Buffered;
|
||||||
|
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public class CoreAdminHandler
|
public class CoreAdminManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<CoreAdminHandler> _instance = new(() => new());
|
private static readonly Lazy<CoreAdminManager> _instance = new(() => new());
|
||||||
public static CoreAdminHandler Instance => _instance.Value;
|
public static CoreAdminManager Instance => _instance.Value;
|
||||||
private Config _config;
|
private Config _config;
|
||||||
private Action<bool, string>? _updateFunc;
|
private Action<bool, string>? _updateFunc;
|
||||||
private int _linuxSudoPid = -1;
|
private int _linuxSudoPid = -1;
|
||||||
|
@ -72,7 +72,7 @@ public class CoreAdminHandler
|
||||||
proc.BeginErrorReadLine();
|
proc.BeginErrorReadLine();
|
||||||
|
|
||||||
await Task.Delay(10);
|
await Task.Delay(10);
|
||||||
await proc.StandardInput.WriteLineAsync(AppHandler.Instance.LinuxSudoPwd);
|
await proc.StandardInput.WriteLineAsync(AppManager.Instance.LinuxSudoPwd);
|
||||||
|
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
if (proc is null or { HasExited: true })
|
if (proc is null or { HasExited: true })
|
||||||
|
@ -103,7 +103,7 @@ public class CoreAdminHandler
|
||||||
var arg = new List<string>() { "-c", $"sudo -S {shFilePath} {_linuxSudoPid}" };
|
var arg = new List<string>() { "-c", $"sudo -S {shFilePath} {_linuxSudoPid}" };
|
||||||
var result = await Cli.Wrap(Global.LinuxBash)
|
var result = await Cli.Wrap(Global.LinuxBash)
|
||||||
.WithArguments(arg)
|
.WithArguments(arg)
|
||||||
.WithStandardInputPipe(PipeSource.FromString(AppHandler.Instance.LinuxSudoPwd))
|
.WithStandardInputPipe(PipeSource.FromString(AppManager.Instance.LinuxSudoPwd))
|
||||||
.ExecuteBufferedAsync();
|
.ExecuteBufferedAsync();
|
||||||
|
|
||||||
UpdateFunc(false, result.StandardOutput.ToString());
|
UpdateFunc(false, result.StandardOutput.ToString());
|
|
@ -1,12 +1,12 @@
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public sealed class CoreInfoHandler
|
public sealed class CoreInfoManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<CoreInfoHandler> _instance = new(() => new());
|
private static readonly Lazy<CoreInfoManager> _instance = new(() => new());
|
||||||
private List<CoreInfo>? _coreInfo;
|
private List<CoreInfo>? _coreInfo;
|
||||||
public static CoreInfoHandler Instance => _instance.Value;
|
public static CoreInfoManager Instance => _instance.Value;
|
||||||
|
|
||||||
public CoreInfoHandler()
|
public CoreInfoManager()
|
||||||
{
|
{
|
||||||
InitCoreInfo();
|
InitCoreInfo();
|
||||||
}
|
}
|
|
@ -6,10 +6,10 @@ namespace ServiceLib.Manager;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Core process processing class
|
/// Core process processing class
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CoreHandler
|
public class CoreManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<CoreHandler> _instance = new(() => new());
|
private static readonly Lazy<CoreManager> _instance = new(() => new());
|
||||||
public static CoreHandler Instance => _instance.Value;
|
public static CoreManager Instance => _instance.Value;
|
||||||
private Config _config;
|
private Config _config;
|
||||||
private Process? _process;
|
private Process? _process;
|
||||||
private Process? _processPre;
|
private Process? _processPre;
|
||||||
|
@ -39,7 +39,7 @@ public class CoreHandler
|
||||||
|
|
||||||
if (Utils.IsNonWindows())
|
if (Utils.IsNonWindows())
|
||||||
{
|
{
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo();
|
||||||
foreach (var it in coreInfo)
|
foreach (var it in coreInfo)
|
||||||
{
|
{
|
||||||
if (it.CoreType == ECoreType.v2rayN)
|
if (it.CoreType == ECoreType.v2rayN)
|
||||||
|
@ -114,7 +114,7 @@ public class CoreHandler
|
||||||
UpdateFunc(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
UpdateFunc(false, string.Format(ResUI.StartService, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")));
|
||||||
UpdateFunc(false, configPath);
|
UpdateFunc(false, configPath);
|
||||||
|
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType);
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType);
|
||||||
var proc = await RunProcess(coreInfo, fileName, true, false);
|
var proc = await RunProcess(coreInfo, fileName, true, false);
|
||||||
if (proc is null)
|
if (proc is null)
|
||||||
{
|
{
|
||||||
|
@ -126,7 +126,7 @@ public class CoreHandler
|
||||||
|
|
||||||
public async Task<int> LoadCoreConfigSpeedtest(ServerTestItem testItem)
|
public async Task<int> LoadCoreConfigSpeedtest(ServerTestItem testItem)
|
||||||
{
|
{
|
||||||
var node = await AppHandler.Instance.GetProfileItem(testItem.IndexId);
|
var node = await AppManager.Instance.GetProfileItem(testItem.IndexId);
|
||||||
if (node is null)
|
if (node is null)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -140,8 +140,8 @@ public class CoreHandler
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType);
|
var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType);
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType);
|
||||||
var proc = await RunProcess(coreInfo, fileName, true, false);
|
var proc = await RunProcess(coreInfo, fileName, true, false);
|
||||||
if (proc is null)
|
if (proc is null)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +157,7 @@ public class CoreHandler
|
||||||
{
|
{
|
||||||
if (_linuxSudo)
|
if (_linuxSudo)
|
||||||
{
|
{
|
||||||
await CoreAdminHandler.Instance.KillProcessAsLinuxSudo();
|
await CoreAdminManager.Instance.KillProcessAsLinuxSudo();
|
||||||
_linuxSudo = false;
|
_linuxSudo = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,8 +183,8 @@ public class CoreHandler
|
||||||
|
|
||||||
private async Task CoreStart(ProfileItem node)
|
private async Task CoreStart(ProfileItem node)
|
||||||
{
|
{
|
||||||
var coreType = _config.RunningCoreType = AppHandler.Instance.GetCoreType(node, node.ConfigType);
|
var coreType = _config.RunningCoreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType);
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType);
|
||||||
|
|
||||||
var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog;
|
var displayLog = node.ConfigType != EConfigType.Custom || node.DisplayLog;
|
||||||
var proc = await RunProcess(coreInfo, Global.CoreConfigFileName, displayLog, true);
|
var proc = await RunProcess(coreInfo, Global.CoreConfigFileName, displayLog, true);
|
||||||
|
@ -199,7 +199,7 @@ public class CoreHandler
|
||||||
{
|
{
|
||||||
if (_process != null && !_process.HasExited)
|
if (_process != null && !_process.HasExited)
|
||||||
{
|
{
|
||||||
var coreType = AppHandler.Instance.GetCoreType(node, node.ConfigType);
|
var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||||
var itemSocks = await ConfigHandler.GetPreSocksItem(_config, node, coreType);
|
var itemSocks = await ConfigHandler.GetPreSocksItem(_config, node, coreType);
|
||||||
if (itemSocks != null)
|
if (itemSocks != null)
|
||||||
{
|
{
|
||||||
|
@ -208,7 +208,7 @@ public class CoreHandler
|
||||||
var result = await CoreConfigHandler.GenerateClientConfig(itemSocks, fileName);
|
var result = await CoreConfigHandler.GenerateClientConfig(itemSocks, fileName);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(preCoreType);
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(preCoreType);
|
||||||
var proc = await RunProcess(coreInfo, Global.CorePreConfigFileName, true, true);
|
var proc = await RunProcess(coreInfo, Global.CorePreConfigFileName, true, true);
|
||||||
if (proc is null)
|
if (proc is null)
|
||||||
{
|
{
|
||||||
|
@ -231,7 +231,7 @@ public class CoreHandler
|
||||||
|
|
||||||
private async Task<Process?> RunProcess(CoreInfo? coreInfo, string configPath, bool displayLog, bool mayNeedSudo)
|
private async Task<Process?> RunProcess(CoreInfo? coreInfo, string configPath, bool displayLog, bool mayNeedSudo)
|
||||||
{
|
{
|
||||||
var fileName = CoreInfoHandler.Instance.GetCoreExecFile(coreInfo, out var msg);
|
var fileName = CoreInfoManager.Instance.GetCoreExecFile(coreInfo, out var msg);
|
||||||
if (fileName.IsNullOrEmpty())
|
if (fileName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
UpdateFunc(false, msg);
|
UpdateFunc(false, msg);
|
||||||
|
@ -246,8 +246,8 @@ public class CoreHandler
|
||||||
&& Utils.IsNonWindows())
|
&& Utils.IsNonWindows())
|
||||||
{
|
{
|
||||||
_linuxSudo = true;
|
_linuxSudo = true;
|
||||||
await CoreAdminHandler.Instance.Init(_config, _updateFunc);
|
await CoreAdminManager.Instance.Init(_config, _updateFunc);
|
||||||
return await CoreAdminHandler.Instance.RunProcessAsLinuxSudo(fileName, coreInfo, configPath);
|
return await CoreAdminManager.Instance.RunProcessAsLinuxSudo(fileName, coreInfo, configPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await RunProcessNormal(fileName, coreInfo, configPath, displayLog);
|
return await RunProcessNormal(fileName, coreInfo, configPath, displayLog);
|
||||||
|
@ -299,7 +299,7 @@ public class CoreHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
AppHandler.Instance.AddProcess(proc.Handle);
|
AppManager.Instance.AddProcess(proc.Handle);
|
||||||
if (proc is null or { HasExited: true })
|
if (proc is null or { HasExited: true })
|
||||||
{
|
{
|
||||||
throw new Exception(ResUI.FailedToRunCore);
|
throw new Exception(ResUI.FailedToRunCore);
|
|
@ -2,10 +2,10 @@ using ReactiveUI;
|
||||||
|
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public class NoticeHandler
|
public class NoticeManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<NoticeHandler> _instance = new(() => new());
|
private static readonly Lazy<NoticeManager> _instance = new(() => new());
|
||||||
public static NoticeHandler Instance => _instance.Value;
|
public static NoticeManager Instance => _instance.Value;
|
||||||
|
|
||||||
public void Enqueue(string? content)
|
public void Enqueue(string? content)
|
||||||
{
|
{
|
|
@ -3,10 +3,10 @@ using System.Text;
|
||||||
|
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public class PacHandler
|
public class PacManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<PacHandler> _instance = new(() => new PacHandler());
|
private static readonly Lazy<PacManager> _instance = new(() => new PacManager());
|
||||||
public static PacHandler Instance => _instance.Value;
|
public static PacManager Instance => _instance.Value;
|
||||||
|
|
||||||
private string _configPath;
|
private string _configPath;
|
||||||
private int _httpPort;
|
private int _httpPort;
|
|
@ -2,17 +2,17 @@ using System.Collections.Concurrent;
|
||||||
|
|
||||||
//using System.Reactive.Linq;
|
//using System.Reactive.Linq;
|
||||||
|
|
||||||
namespace ServiceLib.Handler;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public class ProfileExHandler
|
public class ProfileExManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<ProfileExHandler> _instance = new(() => new());
|
private static readonly Lazy<ProfileExManager> _instance = new(() => new());
|
||||||
private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
|
private ConcurrentBag<ProfileExItem> _lstProfileEx = [];
|
||||||
private readonly Queue<string> _queIndexIds = new();
|
private readonly Queue<string> _queIndexIds = new();
|
||||||
public static ProfileExHandler Instance => _instance.Value;
|
public static ProfileExManager Instance => _instance.Value;
|
||||||
private static readonly string _tag = "ProfileExHandler";
|
private static readonly string _tag = "ProfileExHandler";
|
||||||
|
|
||||||
public ProfileExHandler()
|
public ProfileExManager()
|
||||||
{
|
{
|
||||||
//Init();
|
//Init();
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public class StatisticsHandler
|
public class StatisticsManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<StatisticsHandler> instance = new(() => new());
|
private static readonly Lazy<StatisticsManager> instance = new(() => new());
|
||||||
public static StatisticsHandler Instance => instance.Value;
|
public static StatisticsManager Instance => instance.Value;
|
||||||
|
|
||||||
private Config _config;
|
private Config _config;
|
||||||
private ServerStatItem? _serverStatItem;
|
private ServerStatItem? _serverStatItem;
|
|
@ -1,9 +1,9 @@
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public class TaskHandler
|
public class TaskManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<TaskHandler> _instance = new(() => new());
|
private static readonly Lazy<TaskManager> _instance = new(() => new());
|
||||||
public static TaskHandler Instance => _instance.Value;
|
public static TaskManager Instance => _instance.Value;
|
||||||
|
|
||||||
public void RegUpdateTask(Config config, Action<bool, string> updateFunc)
|
public void RegUpdateTask(Config config, Action<bool, string> updateFunc)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ public class TaskHandler
|
||||||
//Logging.SaveLog("Execute save config");
|
//Logging.SaveLog("Execute save config");
|
||||||
|
|
||||||
await ConfigHandler.SaveConfig(config);
|
await ConfigHandler.SaveConfig(config);
|
||||||
await ProfileExHandler.Instance.SaveTo();
|
await ProfileExManager.Instance.SaveTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Execute once 1 hour
|
//Execute once 1 hour
|
||||||
|
@ -52,7 +52,7 @@ public class TaskHandler
|
||||||
private async Task UpdateTaskRunSubscription(Config config, Action<bool, string> updateFunc)
|
private async Task UpdateTaskRunSubscription(Config config, Action<bool, string> updateFunc)
|
||||||
{
|
{
|
||||||
var updateTime = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
|
var updateTime = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
|
||||||
var lstSubs = (await AppHandler.Instance.SubItems())?
|
var lstSubs = (await AppManager.Instance.SubItems())?
|
||||||
.Where(t => t.AutoUpdateInterval > 0)
|
.Where(t => t.AutoUpdateInterval > 0)
|
||||||
.Where(t => updateTime - t.UpdateTime >= t.AutoUpdateInterval * 60)
|
.Where(t => updateTime - t.UpdateTime >= t.AutoUpdateInterval * 60)
|
||||||
.ToList();
|
.ToList();
|
|
@ -3,10 +3,10 @@ using WebDav;
|
||||||
|
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public sealed class WebDavHandler
|
public sealed class WebDavManager
|
||||||
{
|
{
|
||||||
private static readonly Lazy<WebDavHandler> _instance = new(() => new());
|
private static readonly Lazy<WebDavManager> _instance = new(() => new());
|
||||||
public static WebDavHandler Instance => _instance.Value;
|
public static WebDavManager Instance => _instance.Value;
|
||||||
|
|
||||||
private readonly Config? _config;
|
private readonly Config? _config;
|
||||||
private WebDavClient? _client;
|
private WebDavClient? _client;
|
||||||
|
@ -15,9 +15,9 @@ public sealed class WebDavHandler
|
||||||
private readonly string _webFileName = "backup.zip";
|
private readonly string _webFileName = "backup.zip";
|
||||||
private readonly string _tag = "WebDav--";
|
private readonly string _tag = "WebDav--";
|
||||||
|
|
||||||
public WebDavHandler()
|
public WebDavManager()
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> GetClient()
|
private async Task<bool> GetClient()
|
|
@ -73,12 +73,12 @@ public class CoreConfigClashService
|
||||||
}
|
}
|
||||||
|
|
||||||
//mixed-port
|
//mixed-port
|
||||||
fileContent["mixed-port"] = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
|
fileContent["mixed-port"] = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||||
//log-level
|
//log-level
|
||||||
fileContent["log-level"] = GetLogLevel(_config.CoreBasicItem.Loglevel);
|
fileContent["log-level"] = GetLogLevel(_config.CoreBasicItem.Loglevel);
|
||||||
|
|
||||||
//external-controller
|
//external-controller
|
||||||
fileContent["external-controller"] = $"{Global.Loopback}:{AppHandler.Instance.StatePort2}";
|
fileContent["external-controller"] = $"{Global.Loopback}:{AppManager.Instance.StatePort2}";
|
||||||
//allow-lan
|
//allow-lan
|
||||||
if (_config.Inbound.First().AllowLANConn)
|
if (_config.Inbound.First().AllowLANConn)
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,7 @@ public class CoreConfigClashService
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClashApiHandler.Instance.ProfileContent = fileContent;
|
ClashApiManager.Instance.ProfileContent = fileContent;
|
||||||
|
|
||||||
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, $"{node.GetSummary()}");
|
ret.Msg = string.Format(ResUI.SuccessfulConfiguration, $"{node.GetSummary()}");
|
||||||
ret.Success = true;
|
ret.Success = true;
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class CoreConfigSingboxService
|
||||||
singboxConfig.inbounds.Clear();
|
singboxConfig.inbounds.Clear();
|
||||||
singboxConfig.outbounds.RemoveAt(0);
|
singboxConfig.outbounds.RemoveAt(0);
|
||||||
|
|
||||||
var initPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest);
|
var initPort = AppManager.Instance.GetLocalPort(EInboundProtocol.speedtest);
|
||||||
|
|
||||||
foreach (var it in selecteds)
|
foreach (var it in selecteds)
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ public class CoreConfigSingboxService
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(it.IndexId);
|
||||||
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
||||||
{
|
{
|
||||||
if (item is null || item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id))
|
if (item is null || item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id))
|
||||||
|
@ -242,7 +242,7 @@ public class CoreConfigSingboxService
|
||||||
singboxConfig.route.rules.Add(rule);
|
singboxConfig.route.rules.Add(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
var rawDNSItem = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
|
var rawDNSItem = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
if (rawDNSItem != null && rawDNSItem.Enabled == true)
|
if (rawDNSItem != null && rawDNSItem.Enabled == true)
|
||||||
{
|
{
|
||||||
await GenDnsDomainsCompatible(singboxConfig, rawDNSItem);
|
await GenDnsDomainsCompatible(singboxConfig, rawDNSItem);
|
||||||
|
@ -314,7 +314,7 @@ public class CoreConfigSingboxService
|
||||||
await GenOutbound(node, singboxConfig.outbounds.First());
|
await GenOutbound(node, singboxConfig.outbounds.First());
|
||||||
}
|
}
|
||||||
await GenMoreOutbounds(node, singboxConfig);
|
await GenMoreOutbounds(node, singboxConfig);
|
||||||
var item = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
|
var item = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
if (item != null && item.Enabled == true)
|
if (item != null && item.Enabled == true)
|
||||||
{
|
{
|
||||||
await GenDnsDomainsCompatible(singboxConfig, item);
|
await GenDnsDomainsCompatible(singboxConfig, item);
|
||||||
|
@ -396,7 +396,7 @@ public class CoreConfigSingboxService
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(it.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -583,7 +583,7 @@ public class CoreConfigSingboxService
|
||||||
};
|
};
|
||||||
singboxConfig.inbounds.Add(inbound);
|
singboxConfig.inbounds.Add(inbound);
|
||||||
|
|
||||||
inbound.listen_port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
|
inbound.listen_port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||||
|
|
||||||
if (_config.Inbound.First().SecondLocalPortEnabled)
|
if (_config.Inbound.First().SecondLocalPortEnabled)
|
||||||
{
|
{
|
||||||
|
@ -681,7 +681,7 @@ public class CoreConfigSingboxService
|
||||||
}
|
}
|
||||||
case EConfigType.Shadowsocks:
|
case EConfigType.Shadowsocks:
|
||||||
{
|
{
|
||||||
outbound.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : Global.None;
|
outbound.method = AppManager.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : Global.None;
|
||||||
outbound.password = node.Id;
|
outbound.password = node.Id;
|
||||||
|
|
||||||
await GenOutboundMux(node, outbound);
|
await GenOutboundMux(node, outbound);
|
||||||
|
@ -1007,7 +1007,7 @@ public class CoreConfigSingboxService
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var subItem = await AppHandler.Instance.GetSubItem(node.Subid);
|
var subItem = await AppManager.Instance.GetSubItem(node.Subid);
|
||||||
if (subItem is null)
|
if (subItem is null)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1020,7 +1020,7 @@ public class CoreConfigSingboxService
|
||||||
var txtOutbound = EmbedUtils.GetEmbedText(Global.SingboxSampleOutbound);
|
var txtOutbound = EmbedUtils.GetEmbedText(Global.SingboxSampleOutbound);
|
||||||
|
|
||||||
//Previous proxy
|
//Previous proxy
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
||||||
string? prevOutboundTag = null;
|
string? prevOutboundTag = null;
|
||||||
if (prevNode is not null
|
if (prevNode is not null
|
||||||
&& prevNode.ConfigType != EConfigType.Custom)
|
&& prevNode.ConfigType != EConfigType.Custom)
|
||||||
|
@ -1098,7 +1098,7 @@ public class CoreConfigSingboxService
|
||||||
nextServer = JsonUtils.DeepCopy(nextServer);
|
nextServer = JsonUtils.DeepCopy(nextServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
var subItem = await AppHandler.Instance.GetSubItem(node.Subid);
|
var subItem = await AppManager.Instance.GetSubItem(node.Subid);
|
||||||
|
|
||||||
// current proxy
|
// current proxy
|
||||||
currentServer.tag = $"{Global.ProxyTag}-{index}";
|
currentServer.tag = $"{Global.ProxyTag}-{index}";
|
||||||
|
@ -1112,7 +1112,7 @@ public class CoreConfigSingboxService
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
||||||
if (prevNode is not null
|
if (prevNode is not null
|
||||||
&& prevNode.ConfigType != EConfigType.Custom)
|
&& prevNode.ConfigType != EConfigType.Custom)
|
||||||
{
|
{
|
||||||
|
@ -1219,7 +1219,7 @@ public class CoreConfigSingboxService
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next proxy
|
// Next proxy
|
||||||
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
||||||
if (nextNode is not null
|
if (nextNode is not null
|
||||||
&& nextNode.ConfigType != EConfigType.Custom)
|
&& nextNode.ConfigType != EConfigType.Custom)
|
||||||
{
|
{
|
||||||
|
@ -1248,7 +1248,7 @@ public class CoreConfigSingboxService
|
||||||
var defaultDomainResolverTag = Global.SingboxOutboundResolverTag;
|
var defaultDomainResolverTag = Global.SingboxOutboundResolverTag;
|
||||||
var directDNSStrategy = item.SingboxStrategy4Direct.IsNullOrEmpty() ? Global.SingboxDomainStrategy4Out.FirstOrDefault() : item.SingboxStrategy4Direct;
|
var directDNSStrategy = item.SingboxStrategy4Direct.IsNullOrEmpty() ? Global.SingboxDomainStrategy4Out.FirstOrDefault() : item.SingboxStrategy4Direct;
|
||||||
|
|
||||||
var rawDNSItem = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
|
var rawDNSItem = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
if (rawDNSItem != null && rawDNSItem.Enabled == true)
|
if (rawDNSItem != null && rawDNSItem.Enabled == true)
|
||||||
{
|
{
|
||||||
defaultDomainResolverTag = Global.SingboxFinalResolverTag;
|
defaultDomainResolverTag = Global.SingboxFinalResolverTag;
|
||||||
|
@ -1372,7 +1372,7 @@ public class CoreConfigSingboxService
|
||||||
var dnsExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
var dnsExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
var directExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
var directExeSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
var coreInfoResult = CoreInfoHandler.Instance.GetCoreInfo();
|
var coreInfoResult = CoreInfoManager.Instance.GetCoreInfo();
|
||||||
|
|
||||||
foreach (var coreConfig in coreInfoResult)
|
foreach (var coreConfig in coreInfoResult)
|
||||||
{
|
{
|
||||||
|
@ -1572,7 +1572,7 @@ public class CoreConfigSingboxService
|
||||||
return outboundTag;
|
return outboundTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag);
|
var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag);
|
||||||
if (node == null
|
if (node == null
|
||||||
|| node.ConfigType == EConfigType.Custom)
|
|| node.ConfigType == EConfigType.Custom)
|
||||||
{
|
{
|
||||||
|
@ -1603,7 +1603,7 @@ public class CoreConfigSingboxService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
|
var item = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
if (item != null && item.Enabled == true)
|
if (item != null && item.Enabled == true)
|
||||||
{
|
{
|
||||||
return await GenDnsCompatible(singboxConfig);
|
return await GenDnsCompatible(singboxConfig);
|
||||||
|
@ -1890,7 +1890,7 @@ public class CoreConfigSingboxService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
|
var item = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
var strDNS = string.Empty;
|
var strDNS = string.Empty;
|
||||||
if (_config.TunModeItem.EnableTun)
|
if (_config.TunModeItem.EnableTun)
|
||||||
{
|
{
|
||||||
|
@ -2084,7 +2084,7 @@ public class CoreConfigSingboxService
|
||||||
singboxConfig.experimental ??= new Experimental4Sbox();
|
singboxConfig.experimental ??= new Experimental4Sbox();
|
||||||
singboxConfig.experimental.clash_api = new Clash_Api4Sbox()
|
singboxConfig.experimental.clash_api = new Clash_Api4Sbox()
|
||||||
{
|
{
|
||||||
external_controller = $"{Global.Loopback}:{AppHandler.Instance.StatePort2}",
|
external_controller = $"{Global.Loopback}:{AppManager.Instance.StatePort2}",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2219,7 +2219,7 @@ public class CoreConfigSingboxService
|
||||||
|
|
||||||
private async Task<string> ApplyFullConfigTemplate(SingboxConfig singboxConfig)
|
private async Task<string> ApplyFullConfigTemplate(SingboxConfig singboxConfig)
|
||||||
{
|
{
|
||||||
var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
var fullConfigTemplate = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
||||||
if (fullConfigTemplate == null || !fullConfigTemplate.Enabled)
|
if (fullConfigTemplate == null || !fullConfigTemplate.Enabled)
|
||||||
{
|
{
|
||||||
return JsonUtils.Serialize(singboxConfig);
|
return JsonUtils.Serialize(singboxConfig);
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(it.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -254,7 +254,7 @@ public class CoreConfigV2rayService
|
||||||
v2rayConfig.outbounds.Clear();
|
v2rayConfig.outbounds.Clear();
|
||||||
v2rayConfig.routing.rules.Clear();
|
v2rayConfig.routing.rules.Clear();
|
||||||
|
|
||||||
var initPort = AppHandler.Instance.GetLocalPort(EInboundProtocol.speedtest);
|
var initPort = AppManager.Instance.GetLocalPort(EInboundProtocol.speedtest);
|
||||||
|
|
||||||
foreach (var it in selecteds)
|
foreach (var it in selecteds)
|
||||||
{
|
{
|
||||||
|
@ -266,7 +266,7 @@ public class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var item = await AppHandler.Instance.GetProfileItem(it.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(it.IndexId);
|
||||||
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
if (it.ConfigType is EConfigType.VMess or EConfigType.VLESS)
|
||||||
{
|
{
|
||||||
if (item is null || item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id))
|
if (item is null || item.Id.IsNullOrEmpty() || !Utils.IsGuidByParse(item.Id))
|
||||||
|
@ -638,7 +638,7 @@ public class CoreConfigV2rayService
|
||||||
return outboundTag;
|
return outboundTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
var node = await AppHandler.Instance.GetProfileItemViaRemarks(outboundTag);
|
var node = await AppManager.Instance.GetProfileItemViaRemarks(outboundTag);
|
||||||
if (node == null
|
if (node == null
|
||||||
|| node.ConfigType == EConfigType.Custom
|
|| node.ConfigType == EConfigType.Custom
|
||||||
|| node.ConfigType == EConfigType.Hysteria2
|
|| node.ConfigType == EConfigType.Hysteria2
|
||||||
|
@ -722,7 +722,7 @@ public class CoreConfigV2rayService
|
||||||
serversItem.address = node.Address;
|
serversItem.address = node.Address;
|
||||||
serversItem.port = node.Port;
|
serversItem.port = node.Port;
|
||||||
serversItem.password = node.Id;
|
serversItem.password = node.Id;
|
||||||
serversItem.method = AppHandler.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : "none";
|
serversItem.method = AppManager.Instance.GetShadowsocksSecurities(node).Contains(node.Security) ? node.Security : "none";
|
||||||
|
|
||||||
serversItem.ota = false;
|
serversItem.ota = false;
|
||||||
serversItem.level = 1;
|
serversItem.level = 1;
|
||||||
|
@ -1139,7 +1139,7 @@ public class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
|
var item = await AppManager.Instance.GetDNSItem(ECoreType.Xray);
|
||||||
if (item != null && item.Enabled == true)
|
if (item != null && item.Enabled == true)
|
||||||
{
|
{
|
||||||
var result = await GenDnsCompatible(node, v2rayConfig);
|
var result = await GenDnsCompatible(node, v2rayConfig);
|
||||||
|
@ -1310,12 +1310,12 @@ public class CoreConfigV2rayService
|
||||||
|
|
||||||
if (node?.Subid is not null)
|
if (node?.Subid is not null)
|
||||||
{
|
{
|
||||||
var subItem = await AppHandler.Instance.GetSubItem(node.Subid);
|
var subItem = await AppManager.Instance.GetSubItem(node.Subid);
|
||||||
if (subItem is not null)
|
if (subItem is not null)
|
||||||
{
|
{
|
||||||
foreach (var profile in new[] { subItem.PrevProfile, subItem.NextProfile })
|
foreach (var profile in new[] { subItem.PrevProfile, subItem.NextProfile })
|
||||||
{
|
{
|
||||||
var profileNode = await AppHandler.Instance.GetProfileItemViaRemarks(profile);
|
var profileNode = await AppManager.Instance.GetProfileItemViaRemarks(profile);
|
||||||
if (profileNode is not null &&
|
if (profileNode is not null &&
|
||||||
profileNode.ConfigType is not (EConfigType.Custom or EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.Anytls) &&
|
profileNode.ConfigType is not (EConfigType.Custom or EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.Anytls) &&
|
||||||
Utils.IsDomain(profileNode.Address))
|
Utils.IsDomain(profileNode.Address))
|
||||||
|
@ -1426,7 +1426,7 @@ public class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
|
var item = await AppManager.Instance.GetDNSItem(ECoreType.Xray);
|
||||||
var normalDNS = item?.NormalDNS;
|
var normalDNS = item?.NormalDNS;
|
||||||
var domainStrategy4Freedom = item?.DomainStrategy4Freedom;
|
var domainStrategy4Freedom = item?.DomainStrategy4Freedom;
|
||||||
if (normalDNS.IsNullOrEmpty())
|
if (normalDNS.IsNullOrEmpty())
|
||||||
|
@ -1514,11 +1514,11 @@ public class CoreConfigV2rayService
|
||||||
{
|
{
|
||||||
domainList.Add(node.Address);
|
domainList.Add(node.Address);
|
||||||
}
|
}
|
||||||
var subItem = await AppHandler.Instance.GetSubItem(node.Subid);
|
var subItem = await AppManager.Instance.GetSubItem(node.Subid);
|
||||||
if (subItem is not null)
|
if (subItem is not null)
|
||||||
{
|
{
|
||||||
// Previous proxy
|
// Previous proxy
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
||||||
if (prevNode is not null
|
if (prevNode is not null
|
||||||
&& prevNode.ConfigType != EConfigType.Custom
|
&& prevNode.ConfigType != EConfigType.Custom
|
||||||
&& prevNode.ConfigType != EConfigType.Hysteria2
|
&& prevNode.ConfigType != EConfigType.Hysteria2
|
||||||
|
@ -1529,7 +1529,7 @@ public class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next proxy
|
// Next proxy
|
||||||
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
||||||
if (nextNode is not null
|
if (nextNode is not null
|
||||||
&& nextNode.ConfigType != EConfigType.Custom
|
&& nextNode.ConfigType != EConfigType.Custom
|
||||||
&& nextNode.ConfigType != EConfigType.Hysteria2
|
&& nextNode.ConfigType != EConfigType.Hysteria2
|
||||||
|
@ -1578,7 +1578,7 @@ public class CoreConfigV2rayService
|
||||||
Inboundsettings4Ray apiInboundSettings = new();
|
Inboundsettings4Ray apiInboundSettings = new();
|
||||||
apiInbound.tag = tag;
|
apiInbound.tag = tag;
|
||||||
apiInbound.listen = Global.Loopback;
|
apiInbound.listen = Global.Loopback;
|
||||||
apiInbound.port = AppHandler.Instance.StatePort;
|
apiInbound.port = AppManager.Instance.StatePort;
|
||||||
apiInbound.protocol = Global.InboundAPIProtocol;
|
apiInbound.protocol = Global.InboundAPIProtocol;
|
||||||
apiInboundSettings.address = Global.Loopback;
|
apiInboundSettings.address = Global.Loopback;
|
||||||
apiInbound.settings = apiInboundSettings;
|
apiInbound.settings = apiInboundSettings;
|
||||||
|
@ -1635,7 +1635,7 @@ public class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var subItem = await AppHandler.Instance.GetSubItem(node.Subid);
|
var subItem = await AppManager.Instance.GetSubItem(node.Subid);
|
||||||
if (subItem is null)
|
if (subItem is null)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1646,7 +1646,7 @@ public class CoreConfigV2rayService
|
||||||
var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
|
var txtOutbound = EmbedUtils.GetEmbedText(Global.V2raySampleOutbound);
|
||||||
|
|
||||||
//Previous proxy
|
//Previous proxy
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
||||||
string? prevOutboundTag = null;
|
string? prevOutboundTag = null;
|
||||||
if (prevNode is not null
|
if (prevNode is not null
|
||||||
&& prevNode.ConfigType != EConfigType.Custom
|
&& prevNode.ConfigType != EConfigType.Custom
|
||||||
|
@ -1709,7 +1709,7 @@ public class CoreConfigV2rayService
|
||||||
nextOutbound = JsonUtils.DeepCopy(nextOutbound);
|
nextOutbound = JsonUtils.DeepCopy(nextOutbound);
|
||||||
}
|
}
|
||||||
|
|
||||||
var subItem = await AppHandler.Instance.GetSubItem(node.Subid);
|
var subItem = await AppManager.Instance.GetSubItem(node.Subid);
|
||||||
|
|
||||||
// current proxy
|
// current proxy
|
||||||
await GenOutbound(node, currentOutbound);
|
await GenOutbound(node, currentOutbound);
|
||||||
|
@ -1723,7 +1723,7 @@ public class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var prevNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
var prevNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.PrevProfile);
|
||||||
if (prevNode is not null
|
if (prevNode is not null
|
||||||
&& prevNode.ConfigType != EConfigType.Custom
|
&& prevNode.ConfigType != EConfigType.Custom
|
||||||
&& prevNode.ConfigType != EConfigType.Hysteria2
|
&& prevNode.ConfigType != EConfigType.Hysteria2
|
||||||
|
@ -1793,7 +1793,7 @@ public class CoreConfigV2rayService
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next proxy
|
// Next proxy
|
||||||
var nextNode = await AppHandler.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
var nextNode = await AppManager.Instance.GetProfileItemViaRemarks(subItem.NextProfile);
|
||||||
if (nextNode is not null
|
if (nextNode is not null
|
||||||
&& nextNode.ConfigType != EConfigType.Custom
|
&& nextNode.ConfigType != EConfigType.Custom
|
||||||
&& nextNode.ConfigType != EConfigType.Hysteria2
|
&& nextNode.ConfigType != EConfigType.Hysteria2
|
||||||
|
@ -1829,7 +1829,7 @@ public class CoreConfigV2rayService
|
||||||
var observatory = new Observatory4Ray
|
var observatory = new Observatory4Ray
|
||||||
{
|
{
|
||||||
subjectSelector = [Global.ProxyTag],
|
subjectSelector = [Global.ProxyTag],
|
||||||
probeUrl = AppHandler.Instance.Config.SpeedTestItem.SpeedPingTestUrl,
|
probeUrl = AppManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl,
|
||||||
probeInterval = "3m",
|
probeInterval = "3m",
|
||||||
enableConcurrency = true,
|
enableConcurrency = true,
|
||||||
};
|
};
|
||||||
|
@ -1842,7 +1842,7 @@ public class CoreConfigV2rayService
|
||||||
subjectSelector = [Global.ProxyTag],
|
subjectSelector = [Global.ProxyTag],
|
||||||
pingConfig = new()
|
pingConfig = new()
|
||||||
{
|
{
|
||||||
destination = AppHandler.Instance.Config.SpeedTestItem.SpeedPingTestUrl,
|
destination = AppManager.Instance.Config.SpeedTestItem.SpeedPingTestUrl,
|
||||||
interval = "5m",
|
interval = "5m",
|
||||||
timeout = "30s",
|
timeout = "30s",
|
||||||
sampling = 2,
|
sampling = 2,
|
||||||
|
@ -1870,7 +1870,7 @@ public class CoreConfigV2rayService
|
||||||
|
|
||||||
private async Task<string> ApplyFullConfigTemplate(V2rayConfig v2rayConfig, bool handleBalancerAndRules = false)
|
private async Task<string> ApplyFullConfigTemplate(V2rayConfig v2rayConfig, bool handleBalancerAndRules = false)
|
||||||
{
|
{
|
||||||
var fullConfigTemplate = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
var fullConfigTemplate = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
||||||
if (fullConfigTemplate == null || !fullConfigTemplate.Enabled || fullConfigTemplate.Config.IsNullOrEmpty())
|
if (fullConfigTemplate == null || !fullConfigTemplate.Enabled || fullConfigTemplate.Config.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return JsonUtils.Serialize(v2rayConfig);
|
return JsonUtils.Serialize(v2rayConfig);
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class DownloadService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
||||||
|
|
||||||
var progress = new Progress<string>();
|
var progress = new Progress<string>();
|
||||||
progress.ProgressChanged += (sender, value) => updateFunc?.Invoke(false, $"{value}");
|
progress.ProgressChanged += (sender, value) => updateFunc?.Invoke(false, $"{value}");
|
||||||
|
@ -45,7 +45,7 @@ public class DownloadService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
||||||
UpdateCompleted?.Invoke(this, new RetResult(false, $"{ResUI.Downloading} {url}"));
|
UpdateCompleted?.Invoke(this, new RetResult(false, $"{ResUI.Downloading} {url}"));
|
||||||
|
|
||||||
var progress = new Progress<double>();
|
var progress = new Progress<double>();
|
||||||
|
@ -72,7 +72,7 @@ public class DownloadService
|
||||||
|
|
||||||
public async Task<string?> UrlRedirectAsync(string url, bool blProxy)
|
public async Task<string?> UrlRedirectAsync(string url, bool blProxy)
|
||||||
{
|
{
|
||||||
SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
||||||
var webRequestHandler = new SocketsHttpHandler
|
var webRequestHandler = new SocketsHttpHandler
|
||||||
{
|
{
|
||||||
AllowAutoRedirect = false,
|
AllowAutoRedirect = false,
|
||||||
|
@ -142,7 +142,7 @@ public class DownloadService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
||||||
var webProxy = await GetWebProxy(blProxy);
|
var webProxy = await GetWebProxy(blProxy);
|
||||||
var client = new HttpClient(new SocketsHttpHandler()
|
var client = new HttpClient(new SocketsHttpHandler()
|
||||||
{
|
{
|
||||||
|
@ -187,7 +187,7 @@ public class DownloadService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
SetSecurityProtocol(AppManager.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
||||||
|
|
||||||
var webProxy = await GetWebProxy(blProxy);
|
var webProxy = await GetWebProxy(blProxy);
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ public class DownloadService
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
webProxy ??= await GetWebProxy(true);
|
webProxy ??= await GetWebProxy(true);
|
||||||
var config = AppHandler.Instance.Config;
|
var config = AppManager.Instance.Config;
|
||||||
|
|
||||||
for (var i = 0; i < 2; i++)
|
for (var i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
|
@ -273,7 +273,7 @@ public class DownloadService
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
|
var port = AppManager.Instance.GetLocalPort(EInboundProtocol.socks);
|
||||||
if (await SocketCheck(Global.Loopback, port) == false)
|
if (await SocketCheck(Global.Loopback, port) == false)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class SpeedtestService
|
||||||
Task.Run(async () =>
|
Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await RunAsync(actionType, selecteds);
|
await RunAsync(actionType, selecteds);
|
||||||
await ProfileExHandler.Instance.SaveTo();
|
await ProfileExManager.Instance.SaveTo();
|
||||||
UpdateFunc("", ResUI.SpeedtestingCompleted);
|
UpdateFunc("", ResUI.SpeedtestingCompleted);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -98,18 +98,18 @@ public class SpeedtestService
|
||||||
case ESpeedActionType.Tcping:
|
case ESpeedActionType.Tcping:
|
||||||
case ESpeedActionType.Realping:
|
case ESpeedActionType.Realping:
|
||||||
UpdateFunc(it.IndexId, ResUI.Speedtesting, "");
|
UpdateFunc(it.IndexId, ResUI.Speedtesting, "");
|
||||||
ProfileExHandler.Instance.SetTestDelay(it.IndexId, 0);
|
ProfileExManager.Instance.SetTestDelay(it.IndexId, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESpeedActionType.Speedtest:
|
case ESpeedActionType.Speedtest:
|
||||||
UpdateFunc(it.IndexId, "", ResUI.SpeedtestingWait);
|
UpdateFunc(it.IndexId, "", ResUI.SpeedtestingWait);
|
||||||
ProfileExHandler.Instance.SetTestSpeed(it.IndexId, 0);
|
ProfileExManager.Instance.SetTestSpeed(it.IndexId, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ESpeedActionType.Mixedtest:
|
case ESpeedActionType.Mixedtest:
|
||||||
UpdateFunc(it.IndexId, ResUI.Speedtesting, ResUI.SpeedtestingWait);
|
UpdateFunc(it.IndexId, ResUI.Speedtesting, ResUI.SpeedtestingWait);
|
||||||
ProfileExHandler.Instance.SetTestDelay(it.IndexId, 0);
|
ProfileExManager.Instance.SetTestDelay(it.IndexId, 0);
|
||||||
ProfileExHandler.Instance.SetTestSpeed(it.IndexId, 0);
|
ProfileExManager.Instance.SetTestSpeed(it.IndexId, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class SpeedtestService
|
||||||
{
|
{
|
||||||
var responseTime = await GetTcpingTime(it.Address, it.Port);
|
var responseTime = await GetTcpingTime(it.Address, it.Port);
|
||||||
|
|
||||||
ProfileExHandler.Instance.SetTestDelay(it.IndexId, responseTime);
|
ProfileExManager.Instance.SetTestDelay(it.IndexId, responseTime);
|
||||||
UpdateFunc(it.IndexId, responseTime.ToString());
|
UpdateFunc(it.IndexId, responseTime.ToString());
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -191,7 +191,7 @@ public class SpeedtestService
|
||||||
var pid = -1;
|
var pid = -1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pid = await CoreHandler.Instance.LoadCoreConfigSpeedtest(selecteds);
|
pid = await CoreManager.Instance.LoadCoreConfigSpeedtest(selecteds);
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -255,7 +255,7 @@ public class SpeedtestService
|
||||||
var pid = -1;
|
var pid = -1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pid = await CoreHandler.Instance.LoadCoreConfigSpeedtest(it);
|
pid = await CoreManager.Instance.LoadCoreConfigSpeedtest(it);
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
{
|
{
|
||||||
UpdateFunc(it.IndexId, "", ResUI.FailedToRunCore);
|
UpdateFunc(it.IndexId, "", ResUI.FailedToRunCore);
|
||||||
|
@ -299,7 +299,7 @@ public class SpeedtestService
|
||||||
var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}");
|
var webProxy = new WebProxy($"socks5://{Global.Loopback}:{it.Port}");
|
||||||
var responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10);
|
var responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10);
|
||||||
|
|
||||||
ProfileExHandler.Instance.SetTestDelay(it.IndexId, responseTime);
|
ProfileExManager.Instance.SetTestDelay(it.IndexId, responseTime);
|
||||||
UpdateFunc(it.IndexId, responseTime.ToString());
|
UpdateFunc(it.IndexId, responseTime.ToString());
|
||||||
return responseTime;
|
return responseTime;
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ public class SpeedtestService
|
||||||
decimal.TryParse(msg, out var dec);
|
decimal.TryParse(msg, out var dec);
|
||||||
if (dec > 0)
|
if (dec > 0)
|
||||||
{
|
{
|
||||||
ProfileExHandler.Instance.SetTestSpeed(it.IndexId, dec);
|
ProfileExManager.Instance.SetTestSpeed(it.IndexId, dec);
|
||||||
}
|
}
|
||||||
UpdateFunc(it.IndexId, "", msg);
|
UpdateFunc(it.IndexId, "", msg);
|
||||||
});
|
});
|
||||||
|
@ -378,7 +378,7 @@ public class SpeedtestService
|
||||||
_updateFunc?.Invoke(new() { IndexId = indexId, Delay = delay, Speed = speed });
|
_updateFunc?.Invoke(new() { IndexId = indexId, Delay = delay, Speed = speed });
|
||||||
if (indexId.IsNotEmpty() && speed.IsNotEmpty())
|
if (indexId.IsNotEmpty() && speed.IsNotEmpty())
|
||||||
{
|
{
|
||||||
ProfileExHandler.Instance.SetTestMessage(indexId, speed);
|
ProfileExManager.Instance.SetTestMessage(indexId, speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class StatisticsSingboxService
|
||||||
private bool _exitFlag;
|
private bool _exitFlag;
|
||||||
private ClientWebSocket? webSocket;
|
private ClientWebSocket? webSocket;
|
||||||
private Action<ServerSpeedItem>? _updateFunc;
|
private Action<ServerSpeedItem>? _updateFunc;
|
||||||
private string Url => $"ws://{Global.Loopback}:{AppHandler.Instance.StatePort2}/traffic";
|
private string Url => $"ws://{Global.Loopback}:{AppManager.Instance.StatePort2}/traffic";
|
||||||
private static readonly string _tag = "StatisticsSingboxService";
|
private static readonly string _tag = "StatisticsSingboxService";
|
||||||
|
|
||||||
public StatisticsSingboxService(Config config, Action<ServerSpeedItem> updateFunc)
|
public StatisticsSingboxService(Config config, Action<ServerSpeedItem> updateFunc)
|
||||||
|
|
|
@ -7,7 +7,7 @@ public class StatisticsXrayService
|
||||||
private readonly Config _config;
|
private readonly Config _config;
|
||||||
private bool _exitFlag;
|
private bool _exitFlag;
|
||||||
private Action<ServerSpeedItem>? _updateFunc;
|
private Action<ServerSpeedItem>? _updateFunc;
|
||||||
private string Url => $"{Global.HttpProtocol}{Global.Loopback}:{AppHandler.Instance.StatePort}/debug/vars";
|
private string Url => $"{Global.HttpProtocol}{Global.Loopback}:{AppManager.Instance.StatePort}/debug/vars";
|
||||||
|
|
||||||
public StatisticsXrayService(Config config, Action<ServerSpeedItem> updateFunc)
|
public StatisticsXrayService(Config config, Action<ServerSpeedItem> updateFunc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -135,7 +135,7 @@ public class UpdateService
|
||||||
|
|
||||||
private async Task<RetResult> GetRemoteVersion(DownloadService downloadHandle, ECoreType type, bool preRelease)
|
private async Task<RetResult> GetRemoteVersion(DownloadService downloadHandle, ECoreType type, bool preRelease)
|
||||||
{
|
{
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type);
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(type);
|
||||||
var tagName = string.Empty;
|
var tagName = string.Empty;
|
||||||
if (preRelease)
|
if (preRelease)
|
||||||
{
|
{
|
||||||
|
@ -169,7 +169,7 @@ public class UpdateService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type);
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(type);
|
||||||
string filePath = string.Empty;
|
string filePath = string.Empty;
|
||||||
foreach (var name in coreInfo.CoreExes)
|
foreach (var name in coreInfo.CoreExes)
|
||||||
{
|
{
|
||||||
|
@ -221,7 +221,7 @@ public class UpdateService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type);
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(type);
|
||||||
var coreUrl = await GetUrlFromCore(coreInfo) ?? string.Empty;
|
var coreUrl = await GetUrlFromCore(coreInfo) ?? string.Empty;
|
||||||
SemanticVersion curVersion;
|
SemanticVersion curVersion;
|
||||||
string message;
|
string message;
|
||||||
|
@ -379,7 +379,7 @@ public class UpdateService
|
||||||
var geoSiteFiles = new List<string>();
|
var geoSiteFiles = new List<string>();
|
||||||
|
|
||||||
//Collect used files list
|
//Collect used files list
|
||||||
var routingItems = await AppHandler.Instance.RoutingItems();
|
var routingItems = await AppManager.Instance.RoutingItems();
|
||||||
foreach (var routing in routingItems)
|
foreach (var routing in routingItems)
|
||||||
{
|
{
|
||||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class AddServer2ViewModel : MyReactiveObject
|
||||||
|
|
||||||
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
BrowseServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
BrowseServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
@ -45,25 +45,25 @@ public class AddServer2ViewModel : MyReactiveObject
|
||||||
var remarks = SelectedSource.Remarks;
|
var remarks = SelectedSource.Remarks;
|
||||||
if (remarks.IsNullOrEmpty())
|
if (remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SelectedSource.Address.IsNullOrEmpty())
|
if (SelectedSource.Address.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
NoticeManager.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
||||||
return;
|
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)
|
if (await ConfigHandler.EditCustomServer(_config, SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,12 +74,12 @@ public class AddServer2ViewModel : MyReactiveObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var item = await AppHandler.Instance.GetProfileItem(SelectedSource.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(SelectedSource.IndexId);
|
||||||
item ??= SelectedSource;
|
item ??= SelectedSource;
|
||||||
item.Address = fileName;
|
item.Address = fileName;
|
||||||
if (await ConfigHandler.AddCustomServer(_config, item, false) == 0)
|
if (await ConfigHandler.AddCustomServer(_config, item, false) == 0)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer);
|
NoticeManager.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer);
|
||||||
if (item.IndexId.IsNotEmpty())
|
if (item.IndexId.IsNotEmpty())
|
||||||
{
|
{
|
||||||
SelectedSource = JsonUtils.DeepCopy(item);
|
SelectedSource = JsonUtils.DeepCopy(item);
|
||||||
|
@ -88,7 +88,7 @@ public class AddServer2ViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FailedImportedCustomServer);
|
NoticeManager.Instance.Enqueue(ResUI.FailedImportedCustomServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class AddServer2ViewModel : MyReactiveObject
|
||||||
var address = SelectedSource.Address;
|
var address = SelectedSource.Address;
|
||||||
if (address.IsNullOrEmpty())
|
if (address.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
NoticeManager.Instance.Enqueue(ResUI.FillServerAddressCustom);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class AddServer2ViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FailedReadConfiguration);
|
NoticeManager.Instance.Enqueue(ResUI.FailedReadConfiguration);
|
||||||
}
|
}
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
|
|
||||||
public AddServerViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
public AddServerViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
@ -43,32 +43,32 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (SelectedSource.Remarks.IsNullOrEmpty())
|
if (SelectedSource.Remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SelectedSource.Address.IsNullOrEmpty())
|
if (SelectedSource.Address.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillServerAddress);
|
NoticeManager.Instance.Enqueue(ResUI.FillServerAddress);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var port = SelectedSource.Port.ToString();
|
var port = SelectedSource.Port.ToString();
|
||||||
if (port.IsNullOrEmpty() || !Utils.IsNumeric(port)
|
if (port.IsNullOrEmpty() || !Utils.IsNumeric(port)
|
||||||
|| SelectedSource.Port <= 0 || SelectedSource.Port >= Global.MaxPort)
|
|| SelectedSource.Port <= 0 || SelectedSource.Port >= Global.MaxPort)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectServerPort);
|
NoticeManager.Instance.Enqueue(ResUI.FillCorrectServerPort);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (SelectedSource.ConfigType == EConfigType.Shadowsocks)
|
if (SelectedSource.ConfigType == EConfigType.Shadowsocks)
|
||||||
{
|
{
|
||||||
if (SelectedSource.Id.IsNullOrEmpty())
|
if (SelectedSource.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillPassword);
|
NoticeManager.Instance.Enqueue(ResUI.FillPassword);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (SelectedSource.Security.IsNullOrEmpty())
|
if (SelectedSource.Security.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectEncryption);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectEncryption);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (SelectedSource.Id.IsNullOrEmpty())
|
if (SelectedSource.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillUUID);
|
NoticeManager.Instance.Enqueue(ResUI.FillUUID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,12 +84,12 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
|
|
||||||
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
if (await ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
|
||||||
|
|
||||||
public BackupAndRestoreViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public BackupAndRestoreViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
WebDavCheckCmd = ReactiveCommand.CreateFromTask(async () =>
|
WebDavCheckCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
@ -52,14 +52,14 @@ public class BackupAndRestoreViewModel : MyReactiveObject
|
||||||
_config.WebDavItem = SelectedSource;
|
_config.WebDavItem = SelectedSource;
|
||||||
_ = await ConfigHandler.SaveConfig(_config);
|
_ = await ConfigHandler.SaveConfig(_config);
|
||||||
|
|
||||||
var result = await WebDavHandler.Instance.CheckConnection();
|
var result = await WebDavManager.Instance.CheckConnection();
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
DisplayOperationMsg(ResUI.OperationSuccess);
|
DisplayOperationMsg(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
|
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
|
||||||
var result = await CreateZipFileFromDirectory(fileName);
|
var result = await CreateZipFileFromDirectory(fileName);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
var result2 = await WebDavHandler.Instance.PutFile(fileName);
|
var result2 = await WebDavManager.Instance.PutFile(fileName);
|
||||||
if (result2)
|
if (result2)
|
||||||
{
|
{
|
||||||
DisplayOperationMsg(ResUI.OperationSuccess);
|
DisplayOperationMsg(ResUI.OperationSuccess);
|
||||||
|
@ -78,21 +78,21 @@ public class BackupAndRestoreViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
|
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RemoteRestore()
|
private async Task RemoteRestore()
|
||||||
{
|
{
|
||||||
DisplayOperationMsg();
|
DisplayOperationMsg();
|
||||||
var fileName = Utils.GetTempPath(Utils.GetGuid());
|
var fileName = Utils.GetTempPath(Utils.GetGuid());
|
||||||
var result = await WebDavHandler.Instance.GetRawFile(fileName);
|
var result = await WebDavManager.Instance.GetRawFile(fileName);
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
await LocalRestore(fileName);
|
await LocalRestore(fileName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
|
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> LocalBackup(string fileName)
|
public async Task<bool> LocalBackup(string fileName)
|
||||||
|
@ -105,7 +105,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
|
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -158,7 +158,7 @@ public class BackupAndRestoreViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayOperationMsg(WebDavHandler.Instance.GetLastError());
|
DisplayOperationMsg(WebDavManager.Instance.GetLastError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
|
|
||||||
public CheckUpdateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public CheckUpdateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
CheckUpdateCmd = ReactiveCommand.CreateFromTask(async () =>
|
CheckUpdateCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class ClashConnectionsViewModel : MyReactiveObject
|
||||||
|
|
||||||
public ClashConnectionsViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public ClashConnectionsViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
AutoRefresh = _config.ClashUIItem.ConnectionsAutoRefresh;
|
AutoRefresh = _config.ClashUIItem.ConnectionsAutoRefresh;
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class ClashConnectionsViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task GetClashConnections()
|
private async Task GetClashConnections()
|
||||||
{
|
{
|
||||||
var ret = await ClashApiHandler.Instance.GetClashConnectionsAsync();
|
var ret = await ClashApiManager.Instance.GetClashConnectionsAsync();
|
||||||
if (ret == null)
|
if (ret == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -118,7 +118,7 @@ public class ClashConnectionsViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
_connectionItems.Clear();
|
_connectionItems.Clear();
|
||||||
}
|
}
|
||||||
await ClashApiHandler.Instance.ClashConnectionClose(id);
|
await ClashApiManager.Instance.ClashConnectionClose(id);
|
||||||
await GetClashConnections();
|
await GetClashConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class ClashProxiesViewModel : MyReactiveObject
|
||||||
|
|
||||||
public ClashProxiesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public ClashProxiesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
ProxiesReloadCmd = ReactiveCommand.CreateFromTask(async () =>
|
ProxiesReloadCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
@ -152,13 +152,13 @@ public class ClashProxiesViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
{ "mode", mode.ToString().ToLower() }
|
{ "mode", mode.ToString().ToLower() }
|
||||||
};
|
};
|
||||||
await ClashApiHandler.Instance.ClashConfigUpdate(headers);
|
await ClashApiManager.Instance.ClashConfigUpdate(headers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task GetClashProxies(bool refreshUI)
|
private async Task GetClashProxies(bool refreshUI)
|
||||||
{
|
{
|
||||||
var ret = await ClashApiHandler.Instance.GetClashProxiesAsync();
|
var ret = await ClashApiManager.Instance.GetClashProxiesAsync();
|
||||||
if (ret?.Item1 == null || ret.Item2 == null)
|
if (ret?.Item1 == null || ret.Item2 == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -182,7 +182,7 @@ public class ClashProxiesViewModel : MyReactiveObject
|
||||||
var selectedName = SelectedGroup?.Name;
|
var selectedName = SelectedGroup?.Name;
|
||||||
_proxyGroups.Clear();
|
_proxyGroups.Clear();
|
||||||
|
|
||||||
var proxyGroups = ClashApiHandler.Instance.GetClashProxyGroups();
|
var proxyGroups = ClashApiManager.Instance.GetClashProxyGroups();
|
||||||
if (proxyGroups != null && proxyGroups.Count > 0)
|
if (proxyGroups != null && proxyGroups.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var it in proxyGroups)
|
foreach (var it in proxyGroups)
|
||||||
|
@ -352,11 +352,11 @@ public class ClashProxiesViewModel : MyReactiveObject
|
||||||
var selectedProxy = TryGetProxy(name);
|
var selectedProxy = TryGetProxy(name);
|
||||||
if (selectedProxy == null || selectedProxy.type != "Selector")
|
if (selectedProxy == null || selectedProxy.type != "Selector")
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ClashApiHandler.Instance.ClashSetActiveProxy(name, nameNode);
|
await ClashApiManager.Instance.ClashSetActiveProxy(name, nameNode);
|
||||||
|
|
||||||
selectedProxy.now = nameNode;
|
selectedProxy.now = nameNode;
|
||||||
var group = _proxyGroups.FirstOrDefault(it => it.Name == SelectedGroup.Name);
|
var group = _proxyGroups.FirstOrDefault(it => it.Name == SelectedGroup.Name);
|
||||||
|
@ -368,12 +368,12 @@ public class ClashProxiesViewModel : MyReactiveObject
|
||||||
|
|
||||||
SelectedGroup = group2;
|
SelectedGroup = group2;
|
||||||
}
|
}
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task ProxiesDelayTest(bool blAll = true)
|
private async Task ProxiesDelayTest(bool blAll = true)
|
||||||
{
|
{
|
||||||
ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) =>
|
ClashApiManager.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) =>
|
||||||
{
|
{
|
||||||
if (item == null || result.IsNullOrEmpty())
|
if (item == null || result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
public DNSSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public DNSSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
SaveCmd = ReactiveCommand.CreateFromTask(SaveSettingAsync);
|
SaveCmd = ReactiveCommand.CreateFromTask(SaveSettingAsync);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task Init()
|
private async Task Init()
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
var item = _config.SimpleDNSItem;
|
var item = _config.SimpleDNSItem;
|
||||||
UseSystemHosts = item.UseSystemHosts;
|
UseSystemHosts = item.UseSystemHosts;
|
||||||
AddCommonHosts = item.AddCommonHosts;
|
AddCommonHosts = item.AddCommonHosts;
|
||||||
|
@ -76,14 +76,14 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
Hosts = item.Hosts;
|
Hosts = item.Hosts;
|
||||||
DirectExpectedIPs = item.DirectExpectedIPs;
|
DirectExpectedIPs = item.DirectExpectedIPs;
|
||||||
|
|
||||||
var item1 = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
|
var item1 = await AppManager.Instance.GetDNSItem(ECoreType.Xray);
|
||||||
RayCustomDNSEnableCompatible = item1.Enabled;
|
RayCustomDNSEnableCompatible = item1.Enabled;
|
||||||
UseSystemHostsCompatible = item1.UseSystemHosts;
|
UseSystemHostsCompatible = item1.UseSystemHosts;
|
||||||
DomainStrategy4FreedomCompatible = item1?.DomainStrategy4Freedom ?? string.Empty;
|
DomainStrategy4FreedomCompatible = item1?.DomainStrategy4Freedom ?? string.Empty;
|
||||||
DomainDNSAddressCompatible = item1?.DomainDNSAddress ?? string.Empty;
|
DomainDNSAddressCompatible = item1?.DomainDNSAddress ?? string.Empty;
|
||||||
NormalDNSCompatible = item1?.NormalDNS ?? string.Empty;
|
NormalDNSCompatible = item1?.NormalDNS ?? string.Empty;
|
||||||
|
|
||||||
var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
|
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
SBCustomDNSEnableCompatible = item2.Enabled;
|
SBCustomDNSEnableCompatible = item2.Enabled;
|
||||||
DomainStrategy4Freedom2Compatible = item2?.DomainStrategy4Freedom ?? string.Empty;
|
DomainStrategy4Freedom2Compatible = item2?.DomainStrategy4Freedom ?? string.Empty;
|
||||||
DomainDNSAddress2Compatible = item2?.DomainDNSAddress ?? string.Empty;
|
DomainDNSAddress2Compatible = item2?.DomainDNSAddress ?? string.Empty;
|
||||||
|
@ -117,7 +117,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (NormalDNSCompatible.Contains('{') || NormalDNSCompatible.Contains('}'))
|
if (NormalDNSCompatible.Contains('{') || NormalDNSCompatible.Contains('}'))
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible);
|
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(NormalDNS2Compatible);
|
||||||
if (obj2 == null)
|
if (obj2 == null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,12 +136,12 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible);
|
var obj2 = JsonUtils.Deserialize<Dns4Sbox>(TunDNS2Compatible);
|
||||||
if (obj2 == null)
|
if (obj2 == null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
NoticeManager.Instance.Enqueue(ResUI.FillCorrectDNSText);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var item1 = await AppHandler.Instance.GetDNSItem(ECoreType.Xray);
|
var item1 = await AppManager.Instance.GetDNSItem(ECoreType.Xray);
|
||||||
item1.Enabled = RayCustomDNSEnableCompatible;
|
item1.Enabled = RayCustomDNSEnableCompatible;
|
||||||
item1.DomainStrategy4Freedom = DomainStrategy4FreedomCompatible;
|
item1.DomainStrategy4Freedom = DomainStrategy4FreedomCompatible;
|
||||||
item1.DomainDNSAddress = DomainDNSAddressCompatible;
|
item1.DomainDNSAddress = DomainDNSAddressCompatible;
|
||||||
|
@ -149,7 +149,7 @@ public class DNSSettingViewModel : MyReactiveObject
|
||||||
item1.NormalDNS = NormalDNSCompatible;
|
item1.NormalDNS = NormalDNSCompatible;
|
||||||
await ConfigHandler.SaveDNSItems(_config, item1);
|
await ConfigHandler.SaveDNSItems(_config, item1);
|
||||||
|
|
||||||
var item2 = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
|
var item2 = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||||
item2.Enabled = SBCustomDNSEnableCompatible;
|
item2.Enabled = SBCustomDNSEnableCompatible;
|
||||||
item2.DomainStrategy4Freedom = DomainStrategy4Freedom2Compatible;
|
item2.DomainStrategy4Freedom = DomainStrategy4Freedom2Compatible;
|
||||||
item2.DomainDNSAddress = DomainDNSAddress2Compatible;
|
item2.DomainDNSAddress = DomainDNSAddress2Compatible;
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||||
|
|
||||||
public FullConfigTemplateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public FullConfigTemplateViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
|
@ -53,13 +53,13 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task Init()
|
private async Task Init()
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
||||||
EnableFullConfigTemplate4Ray = item?.Enabled ?? false;
|
EnableFullConfigTemplate4Ray = item?.Enabled ?? false;
|
||||||
FullConfigTemplate4Ray = item?.Config ?? string.Empty;
|
FullConfigTemplate4Ray = item?.Config ?? string.Empty;
|
||||||
AddProxyOnly4Ray = item?.AddProxyOnly ?? false;
|
AddProxyOnly4Ray = item?.AddProxyOnly ?? false;
|
||||||
ProxyDetour4Ray = item?.ProxyDetour ?? string.Empty;
|
ProxyDetour4Ray = item?.ProxyDetour ?? string.Empty;
|
||||||
|
|
||||||
var item2 = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
var item2 = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
||||||
EnableFullConfigTemplate4Singbox = item2?.Enabled ?? false;
|
EnableFullConfigTemplate4Singbox = item2?.Enabled ?? false;
|
||||||
FullConfigTemplate4Singbox = item2?.Config ?? string.Empty;
|
FullConfigTemplate4Singbox = item2?.Config ?? string.Empty;
|
||||||
FullTunConfigTemplate4Singbox = item2?.TunConfig ?? string.Empty;
|
FullTunConfigTemplate4Singbox = item2?.TunConfig ?? string.Empty;
|
||||||
|
@ -75,13 +75,13 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||||
if (!await SaveSingboxConfigAsync())
|
if (!await SaveSingboxConfigAsync())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
_ = _updateView?.Invoke(EViewAction.CloseWindow, null);
|
_ = _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> SaveXrayConfigAsync()
|
private async Task<bool> SaveXrayConfigAsync()
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.Xray);
|
||||||
item.Enabled = EnableFullConfigTemplate4Ray;
|
item.Enabled = EnableFullConfigTemplate4Ray;
|
||||||
item.Config = null;
|
item.Config = null;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class FullConfigTemplateViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task<bool> SaveSingboxConfigAsync()
|
private async Task<bool> SaveSingboxConfigAsync()
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
var item = await AppManager.Instance.GetFullConfigTemplateItem(ECoreType.sing_box);
|
||||||
item.Enabled = EnableFullConfigTemplate4Singbox;
|
item.Enabled = EnableFullConfigTemplate4Singbox;
|
||||||
item.Config = null;
|
item.Config = null;
|
||||||
item.TunConfig = null;
|
item.TunConfig = null;
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
public GlobalHotkeySettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public GlobalHotkeySettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
_globalHotkeys = JsonUtils.DeepCopy(_config.GlobalHotkeys);
|
_globalHotkeys = JsonUtils.DeepCopy(_config.GlobalHotkeys);
|
||||||
|
@ -58,7 +58,7 @@ public class GlobalHotkeySettingViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
|
|
||||||
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
#region WhenAnyValue && ReactiveCommand
|
#region WhenAnyValue && ReactiveCommand
|
||||||
|
@ -178,7 +178,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (await _updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true)
|
if (await _updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RebootAsAdminCmd = ReactiveCommand.CreateFromTask(async () =>
|
RebootAsAdminCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
@ -226,13 +226,13 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
await ConfigHandler.InitBuiltinRouting(_config);
|
await ConfigHandler.InitBuiltinRouting(_config);
|
||||||
await ConfigHandler.InitBuiltinDNS(_config);
|
await ConfigHandler.InitBuiltinDNS(_config);
|
||||||
await ConfigHandler.InitBuiltinFullConfigTemplate(_config);
|
await ConfigHandler.InitBuiltinFullConfigTemplate(_config);
|
||||||
await ProfileExHandler.Instance.Init();
|
await ProfileExManager.Instance.Init();
|
||||||
await CoreHandler.Instance.Init(_config, UpdateHandler);
|
await CoreManager.Instance.Init(_config, UpdateHandler);
|
||||||
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);
|
TaskManager.Instance.RegUpdateTask(_config, UpdateTaskHandler);
|
||||||
|
|
||||||
if (_config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed)
|
if (_config.GuiItem.EnableStatistics || _config.GuiItem.DisplayRealTimeSpeed)
|
||||||
{
|
{
|
||||||
await StatisticsHandler.Instance.Init(_config, UpdateStatisticsHandler);
|
await StatisticsManager.Instance.Init(_config, UpdateStatisticsHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlReloadEnabled = true;
|
BlReloadEnabled = true;
|
||||||
|
@ -247,16 +247,16 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
|
|
||||||
private void UpdateHandler(bool notify, string msg)
|
private void UpdateHandler(bool notify, string msg)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.SendMessage(msg);
|
NoticeManager.Instance.SendMessage(msg);
|
||||||
if (notify)
|
if (notify)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(msg);
|
NoticeManager.Instance.Enqueue(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTaskHandler(bool success, string msg)
|
private void UpdateTaskHandler(bool success, string msg)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.SendMessageEx(msg);
|
NoticeManager.Instance.SendMessageEx(msg);
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
var indexIdOld = _config.IndexId;
|
var indexIdOld = _config.IndexId;
|
||||||
|
@ -303,10 +303,10 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
MessageBus.Current.SendMessage("", EMsgCommand.AppExit.ToString());
|
MessageBus.Current.SendMessage("", EMsgCommand.AppExit.ToString());
|
||||||
|
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
await ProfileExHandler.Instance.SaveTo();
|
await ProfileExManager.Instance.SaveTo();
|
||||||
await StatisticsHandler.Instance.SaveTo();
|
await StatisticsManager.Instance.SaveTo();
|
||||||
await CoreHandler.Instance.CoreStop();
|
await CoreManager.Instance.CoreStop();
|
||||||
StatisticsHandler.Instance.Close();
|
StatisticsManager.Instance.Close();
|
||||||
|
|
||||||
Logging.SaveLog("MyAppExitAsync End");
|
Logging.SaveLog("MyAppExitAsync End");
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (!Utils.UpgradeAppExists(out var upgradeFileName))
|
if (!Utils.UpgradeAppExists(out var upgradeFileName))
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.SendMessageAndEnqueue(ResUI.UpgradeAppNotExistTip);
|
NoticeManager.Instance.SendMessageAndEnqueue(ResUI.UpgradeAppNotExistTip);
|
||||||
Logging.SaveLog("UpgradeApp does not exist");
|
Logging.SaveLog("UpgradeApp does not exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -404,11 +404,11 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
RefreshSubscriptions();
|
RefreshSubscriptions();
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
NoticeHandler.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret));
|
NoticeManager.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +445,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (result.IsNullOrEmpty())
|
if (result.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.NoValidQRcodeFound);
|
NoticeManager.Instance.Enqueue(ResUI.NoValidQRcodeFound);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -454,11 +454,11 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
RefreshSubscriptions();
|
RefreshSubscriptions();
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan);
|
NoticeManager.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +531,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task ClearServerStatistics()
|
private async Task ClearServerStatistics()
|
||||||
{
|
{
|
||||||
await StatisticsHandler.Instance.ClearAllServerStatistics();
|
await StatisticsManager.Instance.ClearAllServerStatistics();
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,13 +602,13 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
private async Task LoadCore()
|
private async Task LoadCore()
|
||||||
{
|
{
|
||||||
var node = await ConfigHandler.GetDefaultServer(_config);
|
var node = await ConfigHandler.GetDefaultServer(_config);
|
||||||
await CoreHandler.Instance.LoadCore(node);
|
await CoreManager.Instance.LoadCore(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task CloseCore()
|
public async Task CloseCore()
|
||||||
{
|
{
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
await CoreHandler.Instance.CoreStop();
|
await CoreManager.Instance.CoreStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AutoHideStartup()
|
private async Task AutoHideStartup()
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class MsgViewModel : MyReactiveObject
|
||||||
|
|
||||||
public MsgViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public MsgViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
MsgFilter = _config.MsgUIItem.MainMsgFilter ?? string.Empty;
|
MsgFilter = _config.MsgUIItem.MainMsgFilter ?? string.Empty;
|
||||||
AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true;
|
AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true;
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
public OptionSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public OptionSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
@ -276,7 +276,7 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||||
if (localPort.ToString().IsNullOrEmpty() || !Utils.IsNumeric(localPort.ToString())
|
if (localPort.ToString().IsNullOrEmpty() || !Utils.IsNumeric(localPort.ToString())
|
||||||
|| localPort <= 0 || localPort >= Global.MaxPort)
|
|| localPort <= 0 || localPort >= Global.MaxPort)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort);
|
NoticeManager.Instance.Enqueue(ResUI.FillLocalListeningPort);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var needReboot = (EnableStatistics != _config.GuiItem.EnableStatistics
|
var needReboot = (EnableStatistics != _config.GuiItem.EnableStatistics
|
||||||
|
@ -369,14 +369,14 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||||
if (await ConfigHandler.SaveConfig(_config) == 0)
|
if (await ConfigHandler.SaveConfig(_config) == 0)
|
||||||
{
|
{
|
||||||
await AutoStartupHandler.UpdateTask(_config);
|
await AutoStartupHandler.UpdateTask(_config);
|
||||||
AppHandler.Instance.Reset();
|
AppManager.Instance.Reset();
|
||||||
|
|
||||||
NoticeHandler.Instance.Enqueue(needReboot ? ResUI.NeedRebootTips : ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(needReboot ? ResUI.NeedRebootTips : ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
|
|
||||||
public ProfilesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public ProfilesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
#region WhenAnyValue && ReactiveCommand
|
#region WhenAnyValue && ReactiveCommand
|
||||||
|
@ -284,8 +284,8 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (result.IndexId.IsNullOrEmpty())
|
if (result.IndexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.SendMessageEx(result.Delay);
|
NoticeManager.Instance.SendMessageEx(result.Delay);
|
||||||
NoticeHandler.Instance.Enqueue(result.Delay);
|
NoticeManager.Instance.Enqueue(result.Delay);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var item = _profileItems.FirstOrDefault(it => it.IndexId == result.IndexId);
|
var item = _profileItems.FirstOrDefault(it => it.IndexId == result.IndexId);
|
||||||
|
@ -403,7 +403,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
|
|
||||||
_subItems.Add(new SubItem { Remarks = ResUI.AllGroupServers });
|
_subItems.Add(new SubItem { Remarks = ResUI.AllGroupServers });
|
||||||
|
|
||||||
foreach (var item in await AppHandler.Instance.SubItems())
|
foreach (var item in await AppManager.Instance.SubItems())
|
||||||
{
|
{
|
||||||
_subItems.Add(item);
|
_subItems.Add(item);
|
||||||
}
|
}
|
||||||
|
@ -419,12 +419,12 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
||||||
{
|
{
|
||||||
var lstModel = await AppHandler.Instance.ProfileItems(_config.SubIndexId, filter);
|
var lstModel = await AppManager.Instance.ProfileItems(_config.SubIndexId, filter);
|
||||||
|
|
||||||
await ConfigHandler.SetDefaultServer(_config, lstModel);
|
await ConfigHandler.SetDefaultServer(_config, lstModel);
|
||||||
|
|
||||||
var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? [];
|
var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsManager.Instance.ServerStat : null) ?? [];
|
||||||
var lstProfileExs = await ProfileExHandler.Instance.GetProfileExs();
|
var lstProfileExs = await ProfileExManager.Instance.GetProfileExs();
|
||||||
lstModel = (from t in lstModel
|
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()
|
from t22 in t2b.DefaultIfEmpty()
|
||||||
|
@ -474,7 +474,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
foreach (var profile in orderProfiles)
|
foreach (var profile in orderProfiles)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(profile.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(profile.IndexId);
|
||||||
if (item is not null)
|
if (item is not null)
|
||||||
{
|
{
|
||||||
lstSelected.Add(item);
|
lstSelected.Add(item);
|
||||||
|
@ -495,10 +495,10 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(SelectedProfile.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
eConfigType = item.ConfigType;
|
eConfigType = item.ConfigType;
|
||||||
|
@ -536,7 +536,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
var exists = lstSelected.Exists(t => t.IndexId == _config.IndexId);
|
var exists = lstSelected.Exists(t => t.IndexId == _config.IndexId);
|
||||||
|
|
||||||
await ConfigHandler.RemoveServers(_config, lstSelected);
|
await ConfigHandler.RemoveServers(_config, lstSelected);
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
if (lstSelected.Count == _profileItems.Count)
|
if (lstSelected.Count == _profileItems.Count)
|
||||||
{
|
{
|
||||||
_profileItems.Clear();
|
_profileItems.Clear();
|
||||||
|
@ -556,7 +556,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
Reload();
|
Reload();
|
||||||
}
|
}
|
||||||
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
|
NoticeManager.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CopyServer()
|
private async Task CopyServer()
|
||||||
|
@ -569,7 +569,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
if (await ConfigHandler.CopyServer(_config, lstSelected) == 0)
|
if (await ConfigHandler.CopyServer(_config, lstSelected) == 0)
|
||||||
{
|
{
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,10 +592,10 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var item = await AppHandler.Instance.GetProfileItem(indexId);
|
var item = await AppManager.Instance.GetProfileItem(indexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,10 +621,10 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
|
|
||||||
public async Task ShareServerAsync()
|
public async Task ShareServerAsync()
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(SelectedProfile.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var url = FmtHandler.GetShareUri(item);
|
var url = FmtHandler.GetShareUri(item);
|
||||||
|
@ -647,7 +647,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
var ret = await ConfigHandler.AddCustomServer4Multiple(_config, lstSelected, coreType, multipleLoad);
|
var ret = await ConfigHandler.AddCustomServer4Multiple(_config, lstSelected, coreType, multipleLoad);
|
||||||
if (ret.Success != true)
|
if (ret.Success != true)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ret?.Data?.ToString() == _config.IndexId)
|
if (ret?.Data?.ToString() == _config.IndexId)
|
||||||
|
@ -682,7 +682,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
var count = await ConfigHandler.RemoveInvalidServerResult(_config, _config.SubIndexId);
|
var count = await ConfigHandler.RemoveInvalidServerResult(_config, _config.SubIndexId);
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveInvalidServerResultTip, count));
|
NoticeManager.Instance.Enqueue(string.Format(ResUI.RemoveInvalidServerResultTip, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
//move server
|
//move server
|
||||||
|
@ -700,7 +700,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
|
|
||||||
await ConfigHandler.MoveToGroup(_config, lstSelected, SelectedMoveToGroup.Id);
|
await ConfigHandler.MoveToGroup(_config, lstSelected, SelectedMoveToGroup.Id);
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
|
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
SelectedMoveToGroup = null;
|
SelectedMoveToGroup = null;
|
||||||
|
@ -712,7 +712,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
var item = _lstProfile.FirstOrDefault(t => t.IndexId == SelectedProfile.IndexId);
|
var item = _lstProfile.FirstOrDefault(t => t.IndexId == SelectedProfile.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,10 +762,10 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task Export2ClientConfigAsync(bool blClipboard)
|
private async Task Export2ClientConfigAsync(bool blClipboard)
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetProfileItem(SelectedProfile.IndexId);
|
var item = await AppManager.Instance.GetProfileItem(SelectedProfile.IndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectServer);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (blClipboard)
|
if (blClipboard)
|
||||||
|
@ -773,12 +773,12 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
var result = await CoreConfigHandler.GenerateClientConfig(item, null);
|
var result = await CoreConfigHandler.GenerateClientConfig(item, null);
|
||||||
if (result.Success != true)
|
if (result.Success != true)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(result.Msg);
|
NoticeManager.Instance.Enqueue(result.Msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _updateView?.Invoke(EViewAction.SetClipboardData, result.Data);
|
await _updateView?.Invoke(EViewAction.SetClipboardData, result.Data);
|
||||||
NoticeHandler.Instance.SendMessage(ResUI.OperationSuccess);
|
NoticeManager.Instance.SendMessage(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -796,11 +796,11 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
var result = await CoreConfigHandler.GenerateClientConfig(item, fileName);
|
var result = await CoreConfigHandler.GenerateClientConfig(item, fileName);
|
||||||
if (result.Success != true)
|
if (result.Success != true)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(result.Msg);
|
NoticeManager.Instance.Enqueue(result.Msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.SendMessageAndEnqueue(string.Format(ResUI.SaveClientConfigurationIn, fileName));
|
NoticeManager.Instance.SendMessageAndEnqueue(string.Format(ResUI.SaveClientConfigurationIn, fileName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,7 +833,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString());
|
await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString());
|
||||||
}
|
}
|
||||||
NoticeHandler.Instance.SendMessage(ResUI.BatchExportURLSuccessfully);
|
NoticeManager.Instance.SendMessage(ResUI.BatchExportURLSuccessfully);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -850,7 +850,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item = await AppHandler.Instance.GetSubItem(_config.SubIndexId);
|
item = await AppManager.Instance.GetSubItem(_config.SubIndexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
|
||||||
|
|
||||||
public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
@ -83,7 +83,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
|
||||||
|
|
||||||
if (!hasRule)
|
if (!hasRule)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Network/Port/Protocol/Domain/IP/Process"));
|
NoticeManager.Instance.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Network/Port/Protocol/Domain/IP/Process"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
//NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
public RoutingRuleSettingViewModel(RoutingItem routingItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
public RoutingRuleSettingViewModel(RoutingItem routingItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
var canEditRemove = this.WhenAnyValue(
|
var canEditRemove = this.WhenAnyValue(
|
||||||
|
@ -151,7 +151,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty())
|
if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||||
|
@ -174,7 +174,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty())
|
if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty())
|
if (SelectedSource is null || SelectedSource.OutboundTag.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
string remarks = SelectedRouting.Remarks;
|
string remarks = SelectedRouting.Remarks;
|
||||||
if (remarks.IsNullOrEmpty())
|
if (remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var item = SelectedRouting;
|
var item = SelectedRouting;
|
||||||
|
@ -239,12 +239,12 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
if (await ConfigHandler.SaveRoutingItem(_config, item) == 0)
|
if (await ConfigHandler.SaveRoutingItem(_config, item) == 0)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
RefreshRulesItems();
|
RefreshRulesItems();
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
RefreshRulesItems();
|
RefreshRulesItems();
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
var url = SelectedRouting.Url;
|
var url = SelectedRouting.Url;
|
||||||
if (url.IsNullOrEmpty())
|
if (url.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.MsgNeedUrl);
|
NoticeManager.Instance.Enqueue(ResUI.MsgNeedUrl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,7 +300,7 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
RefreshRulesItems();
|
RefreshRulesItems();
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
public RoutingSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public RoutingSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
var canEditRemove = this.WhenAnyValue(
|
var canEditRemove = this.WhenAnyValue(
|
||||||
|
@ -84,7 +84,7 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
_routingItems.Clear();
|
_routingItems.Clear();
|
||||||
|
|
||||||
var routings = await AppHandler.Instance.RoutingItems();
|
var routings = await AppManager.Instance.RoutingItems();
|
||||||
foreach (var item in routings)
|
foreach (var item in routings)
|
||||||
{
|
{
|
||||||
var it = new RoutingItemModel()
|
var it = new RoutingItemModel()
|
||||||
|
@ -109,12 +109,12 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
if (await ConfigHandler.SaveConfig(_config) == 0)
|
if (await ConfigHandler.SaveConfig(_config) == 0)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.Id);
|
item = await AppManager.Instance.GetRoutingItem(SelectedSource?.Id);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -146,7 +146,7 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (SelectedSource is null || SelectedSource.Remarks.IsNullOrEmpty())
|
if (SelectedSource is null || SelectedSource.Remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||||
|
@ -155,7 +155,7 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
foreach (var it in SelectedSources ?? [SelectedSource])
|
foreach (var it in SelectedSources ?? [SelectedSource])
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetRoutingItem(it?.Id);
|
var item = await AppManager.Instance.GetRoutingItem(it?.Id);
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
await ConfigHandler.RemoveRoutingItem(item);
|
await ConfigHandler.RemoveRoutingItem(item);
|
||||||
|
@ -168,10 +168,10 @@ public class RoutingSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
public async Task RoutingAdvancedSetDefault()
|
public async Task RoutingAdvancedSetDefault()
|
||||||
{
|
{
|
||||||
var item = await AppHandler.Instance.GetRoutingItem(SelectedSource?.Id);
|
var item = await AppManager.Instance.GetRoutingItem(SelectedSource?.Id);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseSelectRules);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectRules);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
|
|
||||||
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
SelectedRouting = new();
|
SelectedRouting = new();
|
||||||
SelectedServer = new();
|
SelectedServer = new();
|
||||||
RunningServerToolTipText = "-";
|
RunningServerToolTipText = "-";
|
||||||
|
@ -228,7 +228,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
private async Task CopyProxyCmdToClipboard()
|
private async Task CopyProxyCmdToClipboard()
|
||||||
{
|
{
|
||||||
var cmd = Utils.IsWindows() ? "set" : "export";
|
var cmd = Utils.IsWindows() ? "set" : "export";
|
||||||
var address = $"{Global.Loopback}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}";
|
var address = $"{Global.Loopback}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}";
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
sb.AppendLine($"{cmd} http_proxy={Global.HttpProtocol}{address}");
|
sb.AppendLine($"{cmd} http_proxy={Global.HttpProtocol}{address}");
|
||||||
|
@ -283,7 +283,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task RefreshServersMenu()
|
private async Task RefreshServersMenu()
|
||||||
{
|
{
|
||||||
var lstModel = await AppHandler.Instance.ProfileItems(_config.SubIndexId, "");
|
var lstModel = await AppManager.Instance.ProfileItems(_config.SubIndexId, "");
|
||||||
|
|
||||||
_servers.Clear();
|
_servers.Clear();
|
||||||
if (lstModel.Count > _config.GuiItem.TrayMenuServersLimit)
|
if (lstModel.Count > _config.GuiItem.TrayMenuServersLimit)
|
||||||
|
@ -336,7 +336,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
|
|
||||||
var msg = await Task.Run(ConnectionHandler.RunAvailabilityCheck);
|
var msg = await Task.Run(ConnectionHandler.RunAvailabilityCheck);
|
||||||
|
|
||||||
NoticeHandler.Instance.SendMessageEx(msg);
|
NoticeManager.Instance.SendMessageEx(msg);
|
||||||
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
|
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +355,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
_config.SystemProxyItem.SysProxyType = type;
|
_config.SystemProxyItem.SysProxyType = type;
|
||||||
await ChangeSystemProxyAsync(type, true);
|
await ChangeSystemProxyAsync(type, true);
|
||||||
NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType.ToString()}");
|
NoticeManager.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType.ToString()}");
|
||||||
|
|
||||||
SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType;
|
SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType;
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
|
@ -381,7 +381,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
_routingItems.Clear();
|
_routingItems.Clear();
|
||||||
|
|
||||||
BlRouting = true;
|
BlRouting = true;
|
||||||
var routings = await AppHandler.Instance.RoutingItems();
|
var routings = await AppManager.Instance.RoutingItems();
|
||||||
foreach (var item in routings)
|
foreach (var item in routings)
|
||||||
{
|
{
|
||||||
_routingItems.Add(item);
|
_routingItems.Add(item);
|
||||||
|
@ -404,7 +404,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var item = await AppHandler.Instance.GetRoutingItem(SelectedRouting?.Id);
|
var item = await AppManager.Instance.GetRoutingItem(SelectedRouting?.Id);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -412,7 +412,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
|
|
||||||
if (await ConfigHandler.SetDefaultRouting(_config, item) == 0)
|
if (await ConfigHandler.SetDefaultRouting(_config, item) == 0)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.SendMessageEx(ResUI.TipChangeRouting);
|
NoticeManager.Instance.SendMessageEx(ResUI.TipChangeRouting);
|
||||||
Locator.Current.GetService<MainWindowViewModel>()?.Reload();
|
Locator.Current.GetService<MainWindowViewModel>()?.Reload();
|
||||||
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||||
}
|
}
|
||||||
|
@ -471,11 +471,11 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else if (Utils.IsLinux())
|
else if (Utils.IsLinux())
|
||||||
{
|
{
|
||||||
return AppHandler.Instance.LinuxSudoPwd.IsNotEmpty();
|
return AppManager.Instance.LinuxSudoPwd.IsNotEmpty();
|
||||||
}
|
}
|
||||||
else if (Utils.IsOSX())
|
else if (Utils.IsOSX())
|
||||||
{
|
{
|
||||||
return AppHandler.Instance.LinuxSudoPwd.IsNotEmpty();
|
return AppManager.Instance.LinuxSudoPwd.IsNotEmpty();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -487,10 +487,10 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
public async Task InboundDisplayStatus()
|
public async Task InboundDisplayStatus()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new();
|
StringBuilder sb = new();
|
||||||
sb.Append($"[{EInboundProtocol.mixed}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}");
|
sb.Append($"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}");
|
||||||
if (_config.Inbound.First().SecondLocalPortEnabled)
|
if (_config.Inbound.First().SecondLocalPortEnabled)
|
||||||
{
|
{
|
||||||
sb.Append($",{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks2)}");
|
sb.Append($",{AppManager.Instance.GetLocalPort(EInboundProtocol.socks2)}");
|
||||||
}
|
}
|
||||||
sb.Append(']');
|
sb.Append(']');
|
||||||
InboundDisplay = $"{ResUI.LabLocal}:{sb}";
|
InboundDisplay = $"{ResUI.LabLocal}:{sb}";
|
||||||
|
@ -498,8 +498,8 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
if (_config.Inbound.First().AllowLANConn)
|
if (_config.Inbound.First().AllowLANConn)
|
||||||
{
|
{
|
||||||
var lan = _config.Inbound.First().NewPort4LAN
|
var lan = _config.Inbound.First().NewPort4LAN
|
||||||
? $"[{EInboundProtocol.mixed}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks3)}]"
|
? $"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks3)}]"
|
||||||
: $"[{EInboundProtocol.mixed}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks)}]";
|
: $"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}]";
|
||||||
InboundLanDisplay = $"{ResUI.LabLAN}:{lan}";
|
InboundLanDisplay = $"{ResUI.LabLAN}:{lan}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class SubEditViewModel : MyReactiveObject
|
||||||
|
|
||||||
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
SaveCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
|
@ -29,7 +29,7 @@ public class SubEditViewModel : MyReactiveObject
|
||||||
var remarks = SelectedSource.Remarks;
|
var remarks = SelectedSource.Remarks;
|
||||||
if (remarks.IsNullOrEmpty())
|
if (remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
NoticeManager.Instance.Enqueue(ResUI.PleaseFillRemarks);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,25 +39,25 @@ public class SubEditViewModel : MyReactiveObject
|
||||||
var uri = Utils.TryUri(url);
|
var uri = Utils.TryUri(url);
|
||||||
if (uri == null)
|
if (uri == null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.InvalidUrlTip);
|
NoticeManager.Instance.Enqueue(ResUI.InvalidUrlTip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Do not allow http protocol
|
//Do not allow http protocol
|
||||||
if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost))
|
if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost))
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.InsecureUrlProtocol);
|
NoticeManager.Instance.Enqueue(ResUI.InsecureUrlProtocol);
|
||||||
//return;
|
//return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await ConfigHandler.AddSubItem(_config, SelectedSource) == 0)
|
if (await ConfigHandler.AddSubItem(_config, SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class SubSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
public SubSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
public SubSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
var canEditRemove = this.WhenAnyValue(
|
var canEditRemove = this.WhenAnyValue(
|
||||||
|
@ -61,7 +61,7 @@ public class SubSettingViewModel : MyReactiveObject
|
||||||
public async Task RefreshSubItems()
|
public async Task RefreshSubItems()
|
||||||
{
|
{
|
||||||
_subItems.Clear();
|
_subItems.Clear();
|
||||||
_subItems.AddRange(await AppHandler.Instance.SubItems());
|
_subItems.AddRange(await AppManager.Instance.SubItems());
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task EditSubAsync(bool blNew)
|
public async Task EditSubAsync(bool blNew)
|
||||||
|
@ -73,7 +73,7 @@ public class SubSettingViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item = await AppHandler.Instance.GetSubItem(SelectedSource?.Id);
|
item = await AppManager.Instance.GetSubItem(SelectedSource?.Id);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -98,7 +98,7 @@ public class SubSettingViewModel : MyReactiveObject
|
||||||
await ConfigHandler.DeleteSubItem(_config, it.Id);
|
await ConfigHandler.DeleteSubItem(_config, it.Id);
|
||||||
}
|
}
|
||||||
await RefreshSubItems();
|
await RefreshSubItems();
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
IsModified = true;
|
IsModified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ public partial class App : Application
|
||||||
{
|
{
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
AppHandler.Instance.InitComponents();
|
AppManager.Instance.InitComponents();
|
||||||
|
|
||||||
desktop.Exit += OnExit;
|
desktop.Exit += OnExit;
|
||||||
desktop.MainWindow = new MainWindow();
|
desktop.MainWindow = new MainWindow();
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sizeItem = ConfigHandler.GetWindowSizeItem(AppHandler.Instance.Config, GetType().Name);
|
var sizeItem = ConfigHandler.GetWindowSizeItem(AppManager.Instance.Config, GetType().Name);
|
||||||
if (sizeItem == null)
|
if (sizeItem == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -46,7 +46,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
||||||
base.OnClosed(e);
|
base.OnClosed(e);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ConfigHandler.SaveWindowSizeItem(AppHandler.Instance.Config, GetType().Name, Width, Height);
|
ConfigHandler.SaveWindowSizeItem(AppManager.Instance.Config, GetType().Name, Width, Height);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ internal class Program
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AppHandler.Instance.InitApp())
|
if (!AppManager.Instance.InitApp())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,6 @@ internal class Program
|
||||||
.WithFontByDefault()
|
.WithFontByDefault()
|
||||||
.LogToTrace()
|
.LogToTrace()
|
||||||
.UseReactiveUI()
|
.UseReactiveUI()
|
||||||
.With(new MacOSPlatformOptions { ShowInDock = AppHandler.Instance.Config.UiItem.MacOSShowInDock });
|
.With(new MacOSPlatformOptions { ShowInDock = AppManager.Instance.Config.UiItem.MacOSShowInDock });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ public class ThemeSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
public ThemeSettingViewModel()
|
public ThemeSettingViewModel()
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
|
|
||||||
BindingUI();
|
BindingUI();
|
||||||
RestoreUI();
|
RestoreUI();
|
||||||
|
@ -75,7 +75,7 @@ public class ThemeSettingViewModel : MyReactiveObject
|
||||||
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
||||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||||
ConfigHandler.SaveConfig(_config);
|
ConfigHandler.SaveConfig(_config);
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips);
|
NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
|
||||||
|
|
||||||
case EConfigType.Shadowsocks:
|
case EConfigType.Shadowsocks:
|
||||||
gridSs.IsVisible = true;
|
gridSs.IsVisible = true;
|
||||||
cmbSecurity3.ItemsSource = AppHandler.Instance.GetShadowsocksSecurities(profileItem);
|
cmbSecurity3.ItemsSource = AppManager.Instance.GetShadowsocksSecurities(profileItem);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EConfigType.SOCKS:
|
case EConfigType.SOCKS:
|
||||||
|
|
|
@ -15,7 +15,7 @@ public partial class DNSSettingWindow : WindowBase<DNSSettingViewModel>
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
btnCancel.Click += (s, e) => this.Close();
|
btnCancel.Click += (s, e) => this.Close();
|
||||||
ViewModel = new DNSSettingViewModel(UpdateViewHandler);
|
ViewModel = new DNSSettingViewModel(UpdateViewHandler);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ public partial class FullConfigTemplateWindow : WindowBase<FullConfigTemplateVie
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
btnCancel.Click += (s, e) => this.Close();
|
btnCancel.Click += (s, e) => this.Close();
|
||||||
ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler);
|
ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight };
|
_manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight };
|
||||||
|
|
||||||
this.KeyDown += MainWindow_KeyDown;
|
this.KeyDown += MainWindow_KeyDown;
|
||||||
|
@ -352,7 +352,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||||
{
|
{
|
||||||
//ShowHideWindow(false);
|
//ShowHideWindow(false);
|
||||||
|
|
||||||
NoticeHandler.Instance.SendMessageAndEnqueue("Not yet implemented.(还未实现)");
|
NoticeManager.Instance.SendMessageAndEnqueue("Not yet implemented.(还未实现)");
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
//if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
//if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
//{
|
//{
|
||||||
|
@ -478,7 +478,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||||
|
|
||||||
private void AddHelpMenuItem()
|
private void AddHelpMenuItem()
|
||||||
{
|
{
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo();
|
||||||
foreach (var it in coreInfo
|
foreach (var it in coreInfo
|
||||||
.Where(t => t.CoreType != ECoreType.v2fly
|
.Where(t => t.CoreType != ECoreType.v2fly
|
||||||
&& t.CoreType != ECoreType.hysteria))
|
&& t.CoreType != ECoreType.hysteria))
|
||||||
|
|
|
@ -15,7 +15,7 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
btnCancel.Click += (s, e) => this.Close();
|
btnCancel.Click += (s, e) => this.Close();
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
|
|
||||||
ViewModel = new OptionSettingViewModel(UpdateViewHandler);
|
ViewModel = new OptionSettingViewModel(UpdateViewHandler);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
_window = window;
|
_window = window;
|
||||||
|
|
||||||
menuSelectAll.Click += menuSelectAll_Click;
|
menuSelectAll.Click += menuSelectAll_Click;
|
||||||
|
|
|
@ -20,7 +20,7 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
//ViewModel = new StatusBarViewModel(UpdateViewHandler);
|
//ViewModel = new StatusBarViewModel(UpdateViewHandler);
|
||||||
//Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
|
//Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
|
||||||
ViewModel = Locator.Current.GetService<StatusBarViewModel>();
|
ViewModel = Locator.Current.GetService<StatusBarViewModel>();
|
||||||
|
@ -113,7 +113,7 @@ public partial class StatusBarView : ReactiveUserControl<StatusBarViewModel>
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppHandler.Instance.LinuxSudoPwd = password;
|
AppManager.Instance.LinuxSudoPwd = password;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public partial class SudoPasswordInputView : UserControl
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Password verification failed, display error and let user try again
|
// Password verification failed, display error and let user try again
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.SudoIncorrectPasswordTip);
|
NoticeManager.Instance.Enqueue(ResUI.SudoIncorrectPasswordTip);
|
||||||
txtPassword.Focus();
|
txtPassword.Focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,14 +36,14 @@ public partial class App : Application
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!AppHandler.Instance.InitApp())
|
if (!AppManager.Instance.InitApp())
|
||||||
{
|
{
|
||||||
UI.Show($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用");
|
UI.Show($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用");
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AppHandler.Instance.InitComponents();
|
AppManager.Instance.InitComponents();
|
||||||
base.OnStartup(e);
|
base.OnStartup(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sizeItem = ConfigHandler.GetWindowSizeItem(AppHandler.Instance.Config, GetType().Name);
|
var sizeItem = ConfigHandler.GetWindowSizeItem(AppManager.Instance.Config, GetType().Name);
|
||||||
if (sizeItem == null)
|
if (sizeItem == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -36,7 +36,7 @@ public class WindowBase<TViewModel> : ReactiveWindow<TViewModel> where TViewMode
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ConfigHandler.SaveWindowSizeItem(AppHandler.Instance.Config, GetType().Name, Width, Height);
|
ConfigHandler.SaveWindowSizeItem(AppManager.Instance.Config, GetType().Name, Width, Height);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class MaterialDesignFonts
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fontFamily = AppHandler.Instance.Config.UiItem.CurrentFontFamily;
|
var fontFamily = AppManager.Instance.Config.UiItem.CurrentFontFamily;
|
||||||
if (fontFamily.IsNotEmpty())
|
if (fontFamily.IsNotEmpty())
|
||||||
{
|
{
|
||||||
var fontPath = Utils.GetFontsPath();
|
var fontPath = Utils.GetFontsPath();
|
||||||
|
|
|
@ -30,7 +30,7 @@ public sealed class HotkeyHandler
|
||||||
private void Init()
|
private void Init()
|
||||||
{
|
{
|
||||||
_hotkeyTriggerDic.Clear();
|
_hotkeyTriggerDic.Clear();
|
||||||
foreach (var item in AppHandler.Instance.Config.GlobalHotkeys)
|
foreach (var item in AppManager.Instance.Config.GlobalHotkeys)
|
||||||
{
|
{
|
||||||
if (item.KeyCode != null && (Key)item.KeyCode != Key.None)
|
if (item.KeyCode != null && (Key)item.KeyCode != Key.None)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class ThemeSettingViewModel : MyReactiveObject
|
||||||
|
|
||||||
public ThemeSettingViewModel()
|
public ThemeSettingViewModel()
|
||||||
{
|
{
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
|
|
||||||
RegisterSystemColorSet(_config, Application.Current.MainWindow, ModifyTheme);
|
RegisterSystemColorSet(_config, Application.Current.MainWindow, ModifyTheme);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ public class ThemeSettingViewModel : MyReactiveObject
|
||||||
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
_config.UiItem.CurrentLanguage = CurrentLanguage;
|
||||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||||
ConfigHandler.SaveConfig(_config);
|
ConfigHandler.SaveConfig(_config);
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips);
|
NoticeManager.Instance.Enqueue(ResUI.NeedRebootTips);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public partial class AddServer2Window
|
||||||
this.BindCommand(ViewModel, vm => vm.EditServerCmd, v => v.btnEdit).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.EditServerCmd, v => v.btnEdit).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveServerCmd, v => v.btnSave).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SaveServerCmd, v => v.btnSave).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
@ -45,7 +45,7 @@ public partial class AddServerWindow
|
||||||
|
|
||||||
case EConfigType.Shadowsocks:
|
case EConfigType.Shadowsocks:
|
||||||
gridSs.Visibility = Visibility.Visible;
|
gridSs.Visibility = Visibility.Visible;
|
||||||
cmbSecurity3.ItemsSource = AppHandler.Instance.GetShadowsocksSecurities(profileItem);
|
cmbSecurity3.ItemsSource = AppManager.Instance.GetShadowsocksSecurities(profileItem);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EConfigType.SOCKS:
|
case EConfigType.SOCKS:
|
||||||
|
@ -196,7 +196,7 @@ public partial class AddServerWindow
|
||||||
});
|
});
|
||||||
|
|
||||||
this.Title = $"{profileItem.ConfigType}";
|
this.Title = $"{profileItem.ConfigType}";
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
@ -14,7 +14,7 @@ public partial class DNSSettingWindow
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
|
|
||||||
ViewModel = new DNSSettingViewModel(UpdateViewHandler);
|
ViewModel = new DNSSettingViewModel(UpdateViewHandler);
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public partial class DNSSettingWindow
|
||||||
.BindTo(this, x => x.txtAdvancedDNSSettingsInvalid.Visibility)
|
.BindTo(this, x => x.txtAdvancedDNSSettingsInvalid.Visibility)
|
||||||
.DisposeWith(disposables);
|
.DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
@ -14,7 +14,7 @@ public partial class FullConfigTemplateWindow
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
|
|
||||||
ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler);
|
ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ public partial class FullConfigTemplateWindow
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
@ -30,7 +30,7 @@ public partial class GlobalHotkeySettingWindow
|
||||||
{
|
{
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
|
|
||||||
Init();
|
Init();
|
||||||
BindingData();
|
BindingData();
|
||||||
|
|
|
@ -24,7 +24,7 @@ public partial class MainWindow
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false);
|
ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false);
|
||||||
|
|
||||||
App.Current.SessionEnding += Current_SessionEnding;
|
App.Current.SessionEnding += Current_SessionEnding;
|
||||||
|
@ -439,7 +439,7 @@ public partial class MainWindow
|
||||||
|
|
||||||
private void AddHelpMenuItem()
|
private void AddHelpMenuItem()
|
||||||
{
|
{
|
||||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
|
var coreInfo = CoreInfoManager.Instance.GetCoreInfo();
|
||||||
foreach (var it in coreInfo
|
foreach (var it in coreInfo
|
||||||
.Where(t => t.CoreType != ECoreType.v2fly
|
.Where(t => t.CoreType != ECoreType.v2fly
|
||||||
&& t.CoreType != ECoreType.hysteria))
|
&& t.CoreType != ECoreType.hysteria))
|
||||||
|
|
|
@ -17,7 +17,7 @@ public partial class OptionSettingWindow
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
this.Owner = Application.Current.MainWindow;
|
this.Owner = Application.Current.MainWindow;
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
|
|
||||||
ViewModel = new OptionSettingViewModel(UpdateViewHandler);
|
ViewModel = new OptionSettingViewModel(UpdateViewHandler);
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ public partial class OptionSettingWindow
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
@ -23,7 +23,7 @@ public partial class ProfilesView
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
lstGroup.MaxHeight = Math.Floor(SystemParameters.WorkArea.Height * 0.20 / 40) * 40;
|
lstGroup.MaxHeight = Math.Floor(SystemParameters.WorkArea.Height * 0.20 / 40) * 40;
|
||||||
|
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
|
|
||||||
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
||||||
txtServerFilter.PreviewKeyDown += TxtServerFilter_PreviewKeyDown;
|
txtServerFilter.PreviewKeyDown += TxtServerFilter_PreviewKeyDown;
|
||||||
|
|
|
@ -49,7 +49,7 @@ public partial class RoutingRuleDetailsWindow
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
@ -55,7 +55,7 @@ public partial class RoutingRuleSettingWindow
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
@ -42,7 +42,7 @@ public partial class RoutingSettingWindow
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
@ -16,7 +16,7 @@ public partial class StatusBarView
|
||||||
public StatusBarView()
|
public StatusBarView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppManager.Instance.Config;
|
||||||
ViewModel = new StatusBarViewModel(UpdateViewHandler);
|
ViewModel = new StatusBarViewModel(UpdateViewHandler);
|
||||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
|
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(StatusBarViewModel));
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public partial class SubEditWindow
|
||||||
|
|
||||||
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
|
@ -32,7 +32,7 @@ public partial class SubSettingWindow
|
||||||
this.BindCommand(ViewModel, vm => vm.SubEditCmd, v => v.menuSubEdit).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SubEditCmd, v => v.menuSubEdit).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.SubShareCmd, v => v.menuSubShare).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SubShareCmd, v => v.menuSubShare).DisposeWith(disposables);
|
||||||
});
|
});
|
||||||
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.CurrentTheme);
|
WindowsUtils.SetDarkBorder(this, AppManager.Instance.Config.UiItem.CurrentTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
|
|
Loading…
Reference in a new issue