mirror of
https://github.com/2dust/v2rayN.git
synced 2026-03-03 22:53:05 +00:00
Compare commits
1 commit
08a6eb951c
...
c5cc53c963
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5cc53c963 |
11 changed files with 119 additions and 236 deletions
|
|
@ -844,7 +844,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> 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 AppManager.Instance.ProfileModels(subId, "");
|
var lstModel = await AppManager.Instance.ProfileItems(subId, "");
|
||||||
if (lstModel.Count <= 0)
|
if (lstModel.Count <= 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -1213,8 +1213,7 @@ public static class ConfigHandler
|
||||||
}
|
}
|
||||||
var extraItem = new ProtocolExtraItem
|
var extraItem = new ProtocolExtraItem
|
||||||
{
|
{
|
||||||
ChildItems = childProfileIndexId,
|
ChildItems = childProfileIndexId, MultipleLoad = multipleLoad,
|
||||||
MultipleLoad = multipleLoad,
|
|
||||||
};
|
};
|
||||||
profile.SetProtocolExtra(extraItem);
|
profile.SetProtocolExtra(extraItem);
|
||||||
var ret = await AddServerCommon(config, profile, true);
|
var ret = await AddServerCommon(config, profile, true);
|
||||||
|
|
@ -1278,7 +1277,7 @@ 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 AppManager.Instance.ProfileModels(subid, "");
|
var lstModel = await AppManager.Instance.ProfileItems(subid, "");
|
||||||
if (lstModel is { Count: <= 0 })
|
if (lstModel is { Count: <= 0 })
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -191,17 +191,10 @@ public sealed class AppManager
|
||||||
return (await ProfileItems(subid))?.Select(t => t.IndexId)?.ToList();
|
return (await ProfileItems(subid))?.Select(t => t.IndexId)?.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<ProfileItemModel>?> ProfileModels(string subid, string filter)
|
public async Task<List<ProfileItemModel>?> ProfileItems(string subid, string filter)
|
||||||
{
|
{
|
||||||
var sql = @$"select a.IndexId
|
var sql = @$"select a.*
|
||||||
,a.ConfigType
|
,b.remarks subRemarks
|
||||||
,a.Remarks
|
|
||||||
,a.Address
|
|
||||||
,a.Port
|
|
||||||
,a.Network
|
|
||||||
,a.StreamSecurity
|
|
||||||
,a.Subid
|
|
||||||
,b.remarks as subRemarks
|
|
||||||
from ProfileItem a
|
from ProfileItem a
|
||||||
left join SubItem b on a.subid = b.id
|
left join SubItem b on a.subid = b.id
|
||||||
where 1=1 ";
|
where 1=1 ";
|
||||||
|
|
@ -271,26 +264,107 @@ public sealed class AppManager
|
||||||
|
|
||||||
public async Task MigrateProfileExtra()
|
public async Task MigrateProfileExtra()
|
||||||
{
|
{
|
||||||
await MigrateProfileExtraGroup();
|
|
||||||
|
|
||||||
#pragma warning disable CS0618
|
#pragma warning disable CS0618
|
||||||
|
var list = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync();
|
||||||
|
var groupItems = new ConcurrentDictionary<string, ProfileGroupItem>(list.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!));
|
||||||
|
|
||||||
const int pageSize = 100;
|
const int pageSize = 500;
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
var sql = $"SELECT * FROM ProfileItem " +
|
var sql = $"SELECT * FROM ProfileItem WHERE ConfigVersion < 3 LIMIT {pageSize} OFFSET {offset}";
|
||||||
$"WHERE ConfigVersion < 3 " +
|
|
||||||
$"AND ConfigType NOT IN ({(int)EConfigType.PolicyGroup}, {(int)EConfigType.ProxyChain}) " +
|
|
||||||
$"LIMIT {pageSize} OFFSET {offset}";
|
|
||||||
var batch = await SQLiteHelper.Instance.QueryAsync<ProfileItem>(sql);
|
var batch = await SQLiteHelper.Instance.QueryAsync<ProfileItem>(sql);
|
||||||
if (batch is null || batch.Count == 0)
|
if (batch is null || batch.Count == 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var batchSuccessCount = await MigrateProfileExtraSub(batch);
|
var batchSuccessCount = 0;
|
||||||
|
foreach (var item in batch)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var extra = item.GetProtocolExtra();
|
||||||
|
|
||||||
|
if (item.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
|
||||||
|
{
|
||||||
|
extra = extra with { GroupType = nameof(item.ConfigType) };
|
||||||
|
groupItems.TryGetValue(item.IndexId, out var groupItem);
|
||||||
|
if (groupItem != null && !groupItem.NotHasChild())
|
||||||
|
{
|
||||||
|
extra = extra with
|
||||||
|
{
|
||||||
|
ChildItems = groupItem.ChildItems,
|
||||||
|
SubChildItems = groupItem.SubChildItems,
|
||||||
|
Filter = groupItem.Filter,
|
||||||
|
MultipleLoad = groupItem.MultipleLoad,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (item.ConfigType)
|
||||||
|
{
|
||||||
|
case EConfigType.Shadowsocks:
|
||||||
|
extra = extra with { SsMethod = item.Security.NullIfEmpty() };
|
||||||
|
break;
|
||||||
|
case EConfigType.VMess:
|
||||||
|
extra = extra with
|
||||||
|
{
|
||||||
|
AlterId = item.AlterId.ToString(),
|
||||||
|
VmessSecurity = item.Security.NullIfEmpty(),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case EConfigType.VLESS:
|
||||||
|
extra = extra with
|
||||||
|
{
|
||||||
|
Flow = item.Flow.NullIfEmpty(),
|
||||||
|
VlessEncryption = item.Security,
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case EConfigType.Hysteria2:
|
||||||
|
extra = extra with
|
||||||
|
{
|
||||||
|
SalamanderPass = item.Path.NullIfEmpty(),
|
||||||
|
Ports = item.Ports.NullIfEmpty(),
|
||||||
|
UpMbps = _config.HysteriaItem.UpMbps,
|
||||||
|
DownMbps = _config.HysteriaItem.DownMbps,
|
||||||
|
HopInterval = _config.HysteriaItem.HopInterval.ToString(),
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case EConfigType.TUIC:
|
||||||
|
item.Username = item.Id;
|
||||||
|
item.Id = item.Security;
|
||||||
|
item.Password = item.Security;
|
||||||
|
break;
|
||||||
|
case EConfigType.HTTP:
|
||||||
|
case EConfigType.SOCKS:
|
||||||
|
item.Username = item.Security;
|
||||||
|
break;
|
||||||
|
case EConfigType.WireGuard:
|
||||||
|
extra = extra with
|
||||||
|
{
|
||||||
|
WgPublicKey = item.PublicKey.NullIfEmpty(),
|
||||||
|
WgInterfaceAddress = item.RequestHost.NullIfEmpty(),
|
||||||
|
WgReserved = item.Path.NullIfEmpty(),
|
||||||
|
WgMtu = int.TryParse(item.ShortId, out var mtu) ? mtu : 1280
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
item.SetProtocolExtra(extra);
|
||||||
|
|
||||||
|
item.Password = item.Id;
|
||||||
|
|
||||||
|
item.ConfigVersion = 3;
|
||||||
|
await SQLiteHelper.Instance.UpdateAsync(item);
|
||||||
|
batchSuccessCount++;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logging.SaveLog($"MigrateProfileExtra Error: {ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Only increment offset by the number of failed items that remain in the result set
|
// Only increment offset by the number of failed items that remain in the result set
|
||||||
// Successfully updated items are automatically excluded from future queries due to ConfigVersion = 3
|
// Successfully updated items are automatically excluded from future queries due to ConfigVersion = 3
|
||||||
|
|
@ -301,173 +375,6 @@ public sealed class AppManager
|
||||||
#pragma warning restore CS0618
|
#pragma warning restore CS0618
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<int> MigrateProfileExtraSub(List<ProfileItem> batch)
|
|
||||||
{
|
|
||||||
var updateProfileItems = new List<ProfileItem>();
|
|
||||||
|
|
||||||
foreach (var item in batch)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var extra = item.GetProtocolExtra();
|
|
||||||
switch (item.ConfigType)
|
|
||||||
{
|
|
||||||
case EConfigType.Shadowsocks:
|
|
||||||
extra = extra with { SsMethod = item.Security.NullIfEmpty() };
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EConfigType.VMess:
|
|
||||||
extra = extra with
|
|
||||||
{
|
|
||||||
AlterId = item.AlterId.ToString(),
|
|
||||||
VmessSecurity = item.Security.NullIfEmpty(),
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EConfigType.VLESS:
|
|
||||||
extra = extra with
|
|
||||||
{
|
|
||||||
Flow = item.Flow.NullIfEmpty(),
|
|
||||||
VlessEncryption = item.Security,
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EConfigType.Hysteria2:
|
|
||||||
extra = extra with
|
|
||||||
{
|
|
||||||
SalamanderPass = item.Path.NullIfEmpty(),
|
|
||||||
Ports = item.Ports.NullIfEmpty(),
|
|
||||||
UpMbps = _config.HysteriaItem.UpMbps,
|
|
||||||
DownMbps = _config.HysteriaItem.DownMbps,
|
|
||||||
HopInterval = _config.HysteriaItem.HopInterval.ToString(),
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EConfigType.TUIC:
|
|
||||||
item.Username = item.Id;
|
|
||||||
item.Id = item.Security;
|
|
||||||
item.Password = item.Security;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EConfigType.HTTP:
|
|
||||||
case EConfigType.SOCKS:
|
|
||||||
item.Username = item.Security;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EConfigType.WireGuard:
|
|
||||||
extra = extra with
|
|
||||||
{
|
|
||||||
WgPublicKey = item.PublicKey.NullIfEmpty(),
|
|
||||||
WgInterfaceAddress = item.RequestHost.NullIfEmpty(),
|
|
||||||
WgReserved = item.Path.NullIfEmpty(),
|
|
||||||
WgMtu = int.TryParse(item.ShortId, out var mtu) ? mtu : 1280
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
item.SetProtocolExtra(extra);
|
|
||||||
|
|
||||||
item.Password = item.Id;
|
|
||||||
|
|
||||||
item.ConfigVersion = 3;
|
|
||||||
|
|
||||||
updateProfileItems.Add(item);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logging.SaveLog($"MigrateProfileExtra Error: {ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateProfileItems.Count > 0)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var count = await SQLiteHelper.Instance.UpdateAllAsync(updateProfileItems);
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logging.SaveLog($"MigrateProfileExtraGroup update error: {ex}");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task<bool> MigrateProfileExtraGroup()
|
|
||||||
{
|
|
||||||
#pragma warning disable CS0618
|
|
||||||
var list = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync();
|
|
||||||
var groupItems = new ConcurrentDictionary<string, ProfileGroupItem>(list.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!));
|
|
||||||
|
|
||||||
var sql = $"SELECT * FROM ProfileItem WHERE ConfigVersion < 3 AND ConfigType IN ({(int)EConfigType.PolicyGroup}, {(int)EConfigType.ProxyChain})";
|
|
||||||
var items = await SQLiteHelper.Instance.QueryAsync<ProfileItem>(sql);
|
|
||||||
|
|
||||||
if (items is null || items.Count == 0)
|
|
||||||
{
|
|
||||||
Logging.SaveLog("MigrateProfileExtraGroup: No items to migrate.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logging.SaveLog($"MigrateProfileExtraGroup: Found {items.Count} group items to migrate.");
|
|
||||||
|
|
||||||
var updateProfileItems = new List<ProfileItem>();
|
|
||||||
|
|
||||||
foreach (var item in items)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var extra = item.GetProtocolExtra();
|
|
||||||
|
|
||||||
extra = extra with { GroupType = nameof(item.ConfigType) };
|
|
||||||
groupItems.TryGetValue(item.IndexId, out var groupItem);
|
|
||||||
if (groupItem != null && !groupItem.NotHasChild())
|
|
||||||
{
|
|
||||||
extra = extra with
|
|
||||||
{
|
|
||||||
ChildItems = groupItem.ChildItems,
|
|
||||||
SubChildItems = groupItem.SubChildItems,
|
|
||||||
Filter = groupItem.Filter,
|
|
||||||
MultipleLoad = groupItem.MultipleLoad,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
item.SetProtocolExtra(extra);
|
|
||||||
|
|
||||||
item.ConfigVersion = 3;
|
|
||||||
updateProfileItems.Add(item);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logging.SaveLog($"MigrateProfileExtraGroup item error [{item.IndexId}]: {ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateProfileItems.Count > 0)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var count = await SQLiteHelper.Instance.UpdateAllAsync(updateProfileItems);
|
|
||||||
Logging.SaveLog($"MigrateProfileExtraGroup: Successfully updated {updateProfileItems.Count} items.");
|
|
||||||
return updateProfileItems.Count == count;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Logging.SaveLog($"MigrateProfileExtraGroup update error: {ex}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
//await ProfileGroupItemManager.Instance.ClearAll();
|
|
||||||
#pragma warning restore CS0618
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion SqliteHelper
|
#endregion SqliteHelper
|
||||||
|
|
||||||
#region Core Type
|
#region Core Type
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public class GroupProfileManager
|
||||||
return await HasCycle(indexId, extraInfo, new HashSet<string>(), new HashSet<string>());
|
return await HasCycle(indexId, extraInfo, new HashSet<string>(), new HashSet<string>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<bool> HasCycle(string? indexId, ProtocolExtraItem? extraInfo, HashSet<string> visited, HashSet<string> stack)
|
public static async Task<bool> HasCycle(string? indexId, ProtocolExtraItem? extraInfo, HashSet<string> visited, HashSet<string> stack)
|
||||||
{
|
{
|
||||||
if (indexId.IsNullOrEmpty() || extraInfo == null)
|
if (indexId.IsNullOrEmpty() || extraInfo == null)
|
||||||
{
|
{
|
||||||
|
|
@ -81,15 +81,14 @@ public class GroupProfileManager
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
|
var items = await GetSelectedChildProfileItems(protocolExtra);
|
||||||
var items = new List<ProfileItem>();
|
var subItems = await GetSubChildProfileItems(protocolExtra);
|
||||||
items.AddRange(await GetSubChildProfileItems(protocolExtra));
|
items.AddRange(subItems);
|
||||||
items.AddRange(await GetSelectedChildProfileItems(protocolExtra));
|
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<List<ProfileItem>> GetSelectedChildProfileItems(ProtocolExtraItem? extra)
|
public static async Task<List<ProfileItem>> GetSelectedChildProfileItems(ProtocolExtraItem? extra)
|
||||||
{
|
{
|
||||||
if (extra == null || extra.ChildItems.IsNullOrEmpty())
|
if (extra == null || extra.ChildItems.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -106,10 +105,10 @@ public class GroupProfileManager
|
||||||
p.ConfigType != EConfigType.Custom
|
p.ConfigType != EConfigType.Custom
|
||||||
)
|
)
|
||||||
.ToList();
|
.ToList();
|
||||||
return childProfiles ?? new();
|
return childProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<List<ProfileItem>> GetSubChildProfileItems(ProtocolExtraItem? extra)
|
public static async Task<List<ProfileItem>> GetSubChildProfileItems(ProtocolExtraItem? extra)
|
||||||
{
|
{
|
||||||
if (extra == null || extra.SubChildItems.IsNullOrEmpty())
|
if (extra == null || extra.SubChildItems.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ProfileItem
|
public class ProfileItem : ReactiveObject
|
||||||
{
|
{
|
||||||
private ProtocolExtraItem? _protocolExtraCache;
|
private ProtocolExtraItem? _protocolExtraCache;
|
||||||
|
|
||||||
|
|
@ -10,7 +10,6 @@ public class ProfileItem
|
||||||
IndexId = string.Empty;
|
IndexId = string.Empty;
|
||||||
ConfigType = EConfigType.VMess;
|
ConfigType = EConfigType.VMess;
|
||||||
ConfigVersion = 3;
|
ConfigVersion = 3;
|
||||||
Subid = string.Empty;
|
|
||||||
Address = string.Empty;
|
Address = string.Empty;
|
||||||
Port = 0;
|
Port = 0;
|
||||||
Password = string.Empty;
|
Password = string.Empty;
|
||||||
|
|
@ -22,6 +21,7 @@ public class ProfileItem
|
||||||
Path = string.Empty;
|
Path = string.Empty;
|
||||||
StreamSecurity = string.Empty;
|
StreamSecurity = string.Empty;
|
||||||
AllowInsecure = string.Empty;
|
AllowInsecure = string.Empty;
|
||||||
|
Subid = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region function
|
#region function
|
||||||
|
|
@ -148,26 +148,26 @@ public class ProfileItem
|
||||||
public string IndexId { get; set; }
|
public string IndexId { get; set; }
|
||||||
|
|
||||||
public EConfigType ConfigType { get; set; }
|
public EConfigType ConfigType { get; set; }
|
||||||
public ECoreType? CoreType { get; set; }
|
|
||||||
public int ConfigVersion { get; set; }
|
public int ConfigVersion { get; set; }
|
||||||
public string Subid { get; set; }
|
|
||||||
public bool IsSub { get; set; } = true;
|
|
||||||
public int? PreSocksPort { get; set; }
|
|
||||||
public bool DisplayLog { get; set; } = true;
|
|
||||||
public string Remarks { get; set; }
|
|
||||||
public string Address { get; set; }
|
public string Address { get; set; }
|
||||||
public int Port { get; set; }
|
public int Port { get; set; }
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
public string Network { get; set; }
|
public string Network { get; set; }
|
||||||
|
public string Remarks { get; set; }
|
||||||
public string HeaderType { get; set; }
|
public string HeaderType { get; set; }
|
||||||
public string RequestHost { get; set; }
|
public string RequestHost { get; set; }
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
public string StreamSecurity { get; set; }
|
public string StreamSecurity { get; set; }
|
||||||
public string AllowInsecure { get; set; }
|
public string AllowInsecure { get; set; }
|
||||||
|
public string Subid { get; set; }
|
||||||
|
public bool IsSub { get; set; } = true;
|
||||||
public string Sni { get; set; }
|
public string Sni { get; set; }
|
||||||
public string Alpn { get; set; } = string.Empty;
|
public string Alpn { get; set; } = string.Empty;
|
||||||
|
public ECoreType? CoreType { get; set; }
|
||||||
|
public int? PreSocksPort { get; set; }
|
||||||
public string Fingerprint { get; set; }
|
public string Fingerprint { get; set; }
|
||||||
|
public bool DisplayLog { get; set; } = true;
|
||||||
public string PublicKey { get; set; }
|
public string PublicKey { get; set; }
|
||||||
public string ShortId { get; set; }
|
public string ShortId { get; set; }
|
||||||
public string SpiderX { get; set; }
|
public string SpiderX { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,16 @@
|
||||||
namespace ServiceLib.Models;
|
namespace ServiceLib.Models;
|
||||||
|
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ProfileItemModel : ReactiveObject
|
public class ProfileItemModel : ProfileItem
|
||||||
{
|
{
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
public string IndexId { get; set; }
|
|
||||||
public EConfigType ConfigType { get; set; }
|
|
||||||
public string Remarks { get; set; }
|
|
||||||
public string Address { get; set; }
|
|
||||||
public int Port { get; set; }
|
|
||||||
public string Network { get; set; }
|
|
||||||
public string StreamSecurity { get; set; }
|
|
||||||
public string Subid { get; set; }
|
|
||||||
public string SubRemarks { get; set; }
|
public string SubRemarks { get; set; }
|
||||||
public int Sort { get; set; }
|
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public int Delay { get; set; }
|
public int Delay { get; set; }
|
||||||
|
|
||||||
public decimal Speed { get; set; }
|
public decimal Speed { get; set; }
|
||||||
|
public int Sort { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string DelayVal { get; set; }
|
public string DelayVal { get; set; }
|
||||||
|
|
@ -37,15 +29,4 @@ public class ProfileItemModel : ReactiveObject
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string TotalDown { get; set; }
|
public string TotalDown { get; set; }
|
||||||
|
|
||||||
public string GetSummary()
|
|
||||||
{
|
|
||||||
var summary = $"[{ConfigType}] {Remarks}";
|
|
||||||
if (!ConfigType.IsComplexType())
|
|
||||||
{
|
|
||||||
summary += $"({Address}:{Port})";
|
|
||||||
}
|
|
||||||
|
|
||||||
return summary;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,15 +49,12 @@ public class AddServerViewModel : MyReactiveObject
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string WgPublicKey { get; set; }
|
public string WgPublicKey { get; set; }
|
||||||
|
|
||||||
//[Reactive]
|
//[Reactive]
|
||||||
//public string WgPresharedKey { get; set; }
|
//public string WgPresharedKey { get; set; }
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string WgInterfaceAddress { get; set; }
|
public string WgInterfaceAddress { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string WgReserved { get; set; }
|
public string WgReserved { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public int WgMtu { get; set; }
|
public int WgMtu { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ public class ProfilesSelectViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
private async Task<List<ProfileItemModel>?> GetProfileItemsEx(string subid, string filter)
|
||||||
{
|
{
|
||||||
var lstModel = await AppManager.Instance.ProfileModels(_subIndexId, filter);
|
var lstModel = await AppManager.Instance.ProfileItems(_subIndexId, filter);
|
||||||
lstModel = (from t in lstModel
|
lstModel = (from t in lstModel
|
||||||
select new ProfileItemModel
|
select new ProfileItemModel
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -428,7 +428,7 @@ 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 AppManager.Instance.ProfileModels(_config.SubIndexId, filter);
|
var lstModel = await AppManager.Instance.ProfileItems(_config.SubIndexId, filter);
|
||||||
|
|
||||||
await ConfigHandler.SetDefaultServer(_config, lstModel);
|
await ConfigHandler.SetDefaultServer(_config, lstModel);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task RefreshServersMenu()
|
private async Task RefreshServersMenu()
|
||||||
{
|
{
|
||||||
var lstModel = await AppManager.Instance.ProfileModels(_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)
|
||||||
|
|
@ -315,7 +315,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
BlServers = true;
|
BlServers = true;
|
||||||
for (var k = 0; k < lstModel.Count; k++)
|
for (var k = 0; k < lstModel.Count; k++)
|
||||||
{
|
{
|
||||||
var it = lstModel[k];
|
ProfileItem it = lstModel[k];
|
||||||
var name = it.GetSummary();
|
var name = it.GetSummary();
|
||||||
|
|
||||||
var item = new ComboItem() { ID = it.IndexId, Text = name };
|
var item = new ComboItem() { ID = it.IndexId, Text = name };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue