diff --git a/v2rayN/ServiceLib.Tests/Handler/ConfigHandlerCustomSubscriptionTests.cs b/v2rayN/ServiceLib.Tests/Handler/ConfigHandlerCustomSubscriptionTests.cs
index 414e1c75..be35a9ad 100644
--- a/v2rayN/ServiceLib.Tests/Handler/ConfigHandlerCustomSubscriptionTests.cs
+++ b/v2rayN/ServiceLib.Tests/Handler/ConfigHandlerCustomSubscriptionTests.cs
@@ -32,7 +32,7 @@ public class ConfigHandlerCustomSubscriptionTests
oldProfile.IsSub = true;
await SQLiteHelper.Instance.InsertAsync(oldProfile);
- var count = await ConfigDbHandler.AddBatchServers(config, FullXrayConfigs, subId, true);
+ var count = await ConfigDbHandler.AddBatchServers( FullXrayConfigs, subId, true);
var profiles = await ConfigDbQuery.ProfileItems(subId) ?? [];
await count.Should().BeEqualTo(2);
@@ -66,7 +66,7 @@ public class ConfigHandlerCustomSubscriptionTests
await SQLiteHelper.Instance.InsertAsync(existing);
var invalidSubscription = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("not a valid profile"));
- var count = await ConfigDbHandler.AddBatchServers(config, invalidSubscription, subId, true);
+ var count = await ConfigDbHandler.AddBatchServers( invalidSubscription, subId, true);
var profiles = await ConfigDbQuery.ProfileItems(subId) ?? [];
await (count < 1).Should().BeTrue();
diff --git a/v2rayN/ServiceLib/Handler/Builder/CoreConfigContextBuilder.cs b/v2rayN/ServiceLib/Handler/Builder/CoreConfigContextBuilder.cs
index 2fa6013b..bce1da84 100644
--- a/v2rayN/ServiceLib/Handler/Builder/CoreConfigContextBuilder.cs
+++ b/v2rayN/ServiceLib/Handler/Builder/CoreConfigContextBuilder.cs
@@ -46,7 +46,7 @@ public class CoreConfigContextBuilder
SimpleDnsItem = config.SimpleDNSItem,
ProtectDomainList = [],
RawDnsItem = await ConfigDbQuery.GetDNSItem(coreType),
- RoutingItem = await ConfigDbHandler.GetDefaultRouting(config),
+ RoutingItem = await ConfigDbHandler.GetDefaultRouting(),
IsWindows = Utils.IsWindows(),
IsMacOS = Utils.IsMacOS(),
IsLinux = Utils.IsLinux(),
diff --git a/v2rayN/ServiceLib/Handler/Data/ConfigDbHandler.cs b/v2rayN/ServiceLib/Handler/Data/ConfigDbHandler.cs
index 2e77feaf..11317198 100644
--- a/v2rayN/ServiceLib/Handler/Data/ConfigDbHandler.cs
+++ b/v2rayN/ServiceLib/Handler/Data/ConfigDbHandler.cs
@@ -13,16 +13,6 @@ public static class ConfigDbHandler
#region Server
- ///
- /// Add a server profile to the current configuration from ConfigState.
- ///
- /// Server profile to add
- /// Result of the operation (0 if successful, -1 if failed)
- public static Task AddServer(ProfileItem profileItem)
- {
- return AddServer(CurrentConfig, profileItem);
- }
-
///
/// Add a server profile to the configuration
/// Dispatches the request to the appropriate method based on the config type
@@ -30,7 +20,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Server profile to add
/// Result of the operation (0 if successful, -1 if failed)
- public static async Task AddServer(Config config, ProfileItem profileItem)
+ public static async Task AddServer(ProfileItem profileItem)
{
var item = await ConfigDbQuery.GetProfileItem(profileItem.IndexId);
if (item is null)
@@ -71,18 +61,18 @@ public static class ConfigDbHandler
var ret = item.ConfigType switch
{
- EConfigType.VMess => await AddVMessServer(config, item),
- EConfigType.Shadowsocks => await AddShadowsocksServer(config, item),
- EConfigType.SOCKS => await AddSocksServer(config, item),
- EConfigType.HTTP => await AddHttpServer(config, item),
- EConfigType.Trojan => await AddTrojanServer(config, item),
- EConfigType.VLESS => await AddVlessServer(config, item),
- EConfigType.Hysteria2 => await AddHysteria2Server(config, item),
- EConfigType.TUIC => await AddTuicServer(config, item),
- EConfigType.WireGuard => await AddWireguardServer(config, item),
- EConfigType.Anytls => await AddAnytlsServer(config, item),
- EConfigType.Naive => await AddNaiveServer(config, item),
- EConfigType.MASQUE => await AddMasqueServer(config, item),
+ EConfigType.VMess => await AddVMessServer(item),
+ EConfigType.Shadowsocks => await AddShadowsocksServer(item),
+ EConfigType.SOCKS => await AddSocksServer(item),
+ EConfigType.HTTP => await AddHttpServer(item),
+ EConfigType.Trojan => await AddTrojanServer(item),
+ EConfigType.VLESS => await AddVlessServer(item),
+ EConfigType.Hysteria2 => await AddHysteria2Server(item),
+ EConfigType.TUIC => await AddTuicServer(item),
+ EConfigType.WireGuard => await AddWireguardServer(item),
+ EConfigType.Anytls => await AddAnytlsServer(item),
+ EConfigType.Naive => await AddNaiveServer(item),
+ EConfigType.MASQUE => await AddMasqueServer(item),
_ => -1,
};
return ret;
@@ -96,7 +86,7 @@ public static class ConfigDbHandler
/// VMess profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddVMessServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddVMessServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.VMess;
@@ -118,7 +108,7 @@ public static class ConfigDbHandler
return -1;
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -129,7 +119,7 @@ public static class ConfigDbHandler
/// Current configuration
/// List of server profiles to remove
/// 0 if successful
- public static async Task RemoveServers(Config config, List indexes)
+ public static async Task RemoveServers(List indexes)
{
var subid = "TempRemoveSubId";
foreach (var item in indexes)
@@ -138,7 +128,7 @@ public static class ConfigDbHandler
}
await SQLiteHelper.Instance.UpdateAllAsync(indexes);
- await RemoveServersViaSubid(config, subid, false);
+ await RemoveServersViaSubid(subid, false);
return 0;
}
@@ -150,7 +140,7 @@ public static class ConfigDbHandler
/// Current configuration
/// List of server profiles to clone
/// 0 if successful
- public static async Task CopyServer(Config config, List indexes)
+ public static async Task CopyServer(List indexes)
{
foreach (var it in indexes)
{
@@ -167,20 +157,20 @@ public static class ConfigDbHandler
if (profileItem.ConfigType == EConfigType.Custom)
{
profileItem.Address = Utils.GetConfigPath(profileItem.Address);
- if (await AddCustomServer(config, profileItem, false) == 0)
+ if (await AddCustomServer(profileItem, false) == 0)
{
}
}
else if (profileItem.ConfigType == EConfigType.Outbound)
{
profileItem.Address = Utils.GetConfigPath(profileItem.Address);
- if (await AddCustomOutboundServer(config, profileItem, false) == 0)
+ if (await AddCustomOutboundServer(profileItem, false) == 0)
{
}
}
else
{
- await AddServerCommon(config, profileItem, true);
+ await AddServerCommon(profileItem, true);
}
}
@@ -197,7 +187,7 @@ public static class ConfigDbHandler
/// Direction to move the server
/// Target position when using EMove.Position
/// 0 if successful, -1 if failed
- public static async Task MoveServer(Config config, List lstProfile, int index, EMove eMove, int pos = -1)
+ public static async Task MoveServer(List lstProfile, int index, EMove eMove, int pos = -1)
{
var count = lstProfile.Count;
if (index < 0 || index > lstProfile.Count - 1)
@@ -264,7 +254,6 @@ public static class ConfigDbHandler
}
public static Task MoveServersTo(
- Config config,
IReadOnlyList orderedProfileIds,
IReadOnlyList sourceIndices,
int insertIndex)
@@ -332,7 +321,7 @@ public static class ConfigDbHandler
/// Profile item with the file path in Address
/// Whether to delete the source file after copying
/// 0 if successful, -1 if failed
- public static async Task AddCustomServer(Config config, ProfileItem profileItem, bool blDelete)
+ public static async Task AddCustomServer(ProfileItem profileItem, bool blDelete)
{
var fileName = profileItem.Address;
if (!File.Exists(fileName))
@@ -364,12 +353,12 @@ public static class ConfigDbHandler
profileItem.Remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}";
}
- await AddServerCommon(config, profileItem, true);
+ await AddServerCommon(profileItem, true);
return 0;
}
- public static async Task AddCustomOutboundServer(Config config, ProfileItem profileItem, bool blDelete, bool toFile = true)
+ public static async Task AddCustomOutboundServer(ProfileItem profileItem, bool blDelete, bool toFile = true)
{
var fileName = profileItem.Address;
if (!File.Exists(fileName))
@@ -401,7 +390,7 @@ public static class ConfigDbHandler
profileItem.Remarks = $"import custom outbound@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}";
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -413,7 +402,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Profile item with updated properties
/// 0 if successful, -1 if failed
- public static async Task EditCustomServer(Config config, ProfileItem profileItem)
+ public static async Task EditCustomServer(ProfileItem profileItem)
{
var item = await ConfigDbQuery.GetProfileItem(profileItem.IndexId);
if (item is null)
@@ -451,7 +440,7 @@ public static class ConfigDbHandler
/// Shadowsocks profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddShadowsocksServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddShadowsocksServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.Shadowsocks;
@@ -471,7 +460,7 @@ public static class ConfigDbHandler
return -1;
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -484,13 +473,13 @@ public static class ConfigDbHandler
/// SOCKS profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddSocksServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddSocksServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.SOCKS;
profileItem.Address = profileItem.Address.TrimEx();
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -503,13 +492,13 @@ public static class ConfigDbHandler
/// HTTP profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddHttpServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddHttpServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.HTTP;
profileItem.Address = profileItem.Address.TrimEx();
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -522,7 +511,7 @@ public static class ConfigDbHandler
/// Trojan profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddTrojanServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddTrojanServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.Trojan;
@@ -537,7 +526,7 @@ public static class ConfigDbHandler
return -1;
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -551,7 +540,7 @@ public static class ConfigDbHandler
/// Hysteria2 profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddHysteria2Server(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.Hysteria2;
@@ -615,7 +604,7 @@ public static class ConfigDbHandler
});
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -629,7 +618,7 @@ public static class ConfigDbHandler
/// TUIC profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddTuicServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddTuicServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.TUIC;
profileItem.CoreType = ECoreType.sing_box;
@@ -660,7 +649,7 @@ public static class ConfigDbHandler
return -1;
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -673,7 +662,7 @@ public static class ConfigDbHandler
/// WireGuard profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddWireguardServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddWireguardServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.WireGuard;
@@ -712,7 +701,7 @@ public static class ConfigDbHandler
return -1;
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -725,7 +714,7 @@ public static class ConfigDbHandler
/// Anytls profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddAnytlsServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddAnytlsServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.Anytls;
profileItem.CoreType = ECoreType.sing_box;
@@ -741,7 +730,7 @@ public static class ConfigDbHandler
{
return -1;
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -753,7 +742,7 @@ public static class ConfigDbHandler
/// Naive profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddNaiveServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddNaiveServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.Naive;
profileItem.CoreType = ECoreType.sing_box;
@@ -773,11 +762,11 @@ public static class ConfigDbHandler
{
return -1;
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
- public static async Task AddMasqueServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddMasqueServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.MASQUE;
@@ -792,7 +781,7 @@ public static class ConfigDbHandler
{
return -1;
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -805,14 +794,14 @@ public static class ConfigDbHandler
/// Column name to sort by
/// Sort in ascending order if true, descending if false
/// 0 if successful, -1 if failed
- public static async Task SortServers(Config config, string subId, string colName, bool asc)
+ public static async Task SortServers(string subId, string colName, bool asc)
{
var lstModel = await ConfigDbQuery.ProfileModels(subId, "");
if (lstModel.Count <= 0)
{
return -1;
}
- var lstServerStat = (config.GuiItem.EnableStatistics ? StatisticsManager.Instance.ServerStat : null) ?? [];
+ var lstServerStat = (CurrentConfig.GuiItem.EnableStatistics ? StatisticsManager.Instance.ServerStat : null) ?? [];
var lstProfileExs = await ProfileExManager.Instance.GetProfileExs();
var lstProfile = (from t in lstModel
join t2 in lstServerStat on t.IndexId equals t2.IndexId into t2b
@@ -923,7 +912,7 @@ public static class ConfigDbHandler
/// VLESS profile to add
/// Whether to save to file
/// 0 if successful, -1 if failed
- public static async Task AddVlessServer(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddVlessServer(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigType = EConfigType.VLESS;
@@ -945,7 +934,7 @@ public static class ConfigDbHandler
return -1;
}
- await AddServerCommon(config, profileItem, toFile);
+ await AddServerCommon(profileItem, toFile);
return 0;
}
@@ -957,7 +946,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Subscription ID to deduplicate
/// Tuple with total count and remaining count after deduplication
- public static async Task> DedupServerList(Config config, string subId)
+ public static async Task> DedupServerList(string subId)
{
var lstProfile = await ConfigDbQuery.ProfileItems(subId);
if (lstProfile == null)
@@ -967,7 +956,7 @@ public static class ConfigDbHandler
List lstKeep = [];
List lstRemove = [];
- if (!config.GuiItem.KeepOlderDedupl)
+ if (!CurrentConfig.GuiItem.KeepOlderDedupl)
{
lstProfile.Reverse();
}
@@ -989,7 +978,7 @@ public static class ConfigDbHandler
lstKeep.Add(item);
}
}
- await RemoveServers(config, lstRemove);
+ await RemoveServers(lstRemove);
return new Tuple(lstProfile.Count, lstKeep.Count);
}
@@ -1002,7 +991,7 @@ public static class ConfigDbHandler
/// Profile item to add
/// Whether to save to database
/// 0 if successful
- public static async Task AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true)
+ public static async Task AddServerCommon(ProfileItem profileItem, bool toFile = true)
{
profileItem.ConfigVersion = 4;
@@ -1017,7 +1006,7 @@ public static class ConfigDbHandler
{
if (profileItem.Fingerprint.IsNullOrEmpty() && profileItem.StreamSecurity == Global.StreamSecurityReality)
{
- profileItem.Fingerprint = config.CoreBasicItem.DefFingerprint;
+ profileItem.Fingerprint = CurrentConfig.CoreBasicItem.DefFingerprint;
}
}
}
@@ -1192,7 +1181,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Index ID of the profile to remove
/// 0 if successful
- private static async Task RemoveProfileItem(Config config, string indexId)
+ private static async Task RemoveProfileItem(string indexId)
{
try
{
@@ -1223,7 +1212,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Sub-item for grouping
/// Result object with success state and data
- public static async Task AddGroupAllServer(Config config, SubItem? subItem)
+ public static async Task AddGroupAllServer(SubItem? subItem)
{
var result = new RetResult();
@@ -1256,7 +1245,7 @@ public static class ConfigDbHandler
Filter = Global.PolicyGroupDefaultAllFilter,
};
profile.SetProtocolExtra(extraItem);
- var ret = await AddServerCommon(config, profile, true);
+ var ret = await AddServerCommon(profile, true);
result.Success = ret == 0;
result.Data = indexId;
return result;
@@ -1288,7 +1277,7 @@ public static class ConfigDbHandler
{ "MX", "墨西哥|\\b[Mm][Xx]\\b|🇲🇽|[Mm]exico" }
};
- public static async Task AddGroupRegionServer(Config config, SubItem? subItem)
+ public static async Task AddGroupRegionServer(SubItem? subItem)
{
var result = new RetResult();
var subId = subItem?.Id;
@@ -1337,7 +1326,7 @@ public static class ConfigDbHandler
continue;
}
- var ret = await AddServerCommon(config, profile, true);
+ var ret = await AddServerCommon(profile, true);
if (ret == 0)
{
indexIdList.Add(indexId);
@@ -1355,7 +1344,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Subscription ID to filter servers
/// Number of removed servers or -1 if failed
- public static async Task RemoveInvalidServerResult(Config config, string subid)
+ public static async Task RemoveInvalidServerResult(string subid)
{
var lstModel = await ConfigDbQuery.ProfileModels(subid, "");
lstModel.RemoveAll(t => t.ConfigType.IsComplexType());
@@ -1369,7 +1358,7 @@ public static class ConfigDbHandler
where t2.Delay == -1
select t).ToList();
- await RemoveServers(config, JsonUtils.Deserialize>(JsonUtils.Serialize(lstProfile)));
+ await RemoveServers(JsonUtils.Deserialize>(JsonUtils.Serialize(lstProfile)));
return lstProfile.Count;
}
@@ -1387,7 +1376,7 @@ public static class ConfigDbHandler
/// Subscription ID to associate with the servers
/// Whether this is from a subscription
/// Number of successfully imported servers or -1 if failed
- private static async Task AddBatchServersCommon(Config config, string strData, string subid, bool isSub)
+ private static async Task AddBatchServersCommon(string strData, string subid, bool isSub)
{
if (strData.IsNullOrEmpty())
{
@@ -1417,7 +1406,7 @@ public static class ConfigDbHandler
//maybe sub
if (!isSub && (str.StartsWith(Global.HttpsProtocol) || str.StartsWith(Global.HttpProtocol)))
{
- if (await AddSubItem(config, str) == 0)
+ if (await AddSubItem(str) == 0)
{
countServers++;
}
@@ -1457,17 +1446,17 @@ public static class ConfigDbHandler
var addStatus = profileItem.ConfigType switch
{
- EConfigType.VMess => await AddVMessServer(config, profileItem, false),
- EConfigType.Shadowsocks => await AddShadowsocksServer(config, profileItem, false),
- EConfigType.SOCKS => await AddSocksServer(config, profileItem, false),
- EConfigType.Trojan => await AddTrojanServer(config, profileItem, false),
- EConfigType.VLESS => await AddVlessServer(config, profileItem, false),
- EConfigType.Hysteria2 => await AddHysteria2Server(config, profileItem, false),
- EConfigType.TUIC => await AddTuicServer(config, profileItem, false),
- EConfigType.WireGuard => await AddWireguardServer(config, profileItem, false),
- EConfigType.Anytls => await AddAnytlsServer(config, profileItem, false),
- EConfigType.Naive => await AddNaiveServer(config, profileItem, false),
- EConfigType.MASQUE => await AddMasqueServer(config, profileItem, false),
+ EConfigType.VMess => await AddVMessServer(profileItem, false),
+ EConfigType.Shadowsocks => await AddShadowsocksServer(profileItem, false),
+ EConfigType.SOCKS => await AddSocksServer(profileItem, false),
+ EConfigType.Trojan => await AddTrojanServer(profileItem, false),
+ EConfigType.VLESS => await AddVlessServer(profileItem, false),
+ EConfigType.Hysteria2 => await AddHysteria2Server(profileItem, false),
+ EConfigType.TUIC => await AddTuicServer(profileItem, false),
+ EConfigType.WireGuard => await AddWireguardServer(profileItem, false),
+ EConfigType.Anytls => await AddAnytlsServer(profileItem, false),
+ EConfigType.Naive => await AddNaiveServer(profileItem, false),
+ EConfigType.MASQUE => await AddMasqueServer(profileItem, false),
_ => -1,
};
@@ -1496,7 +1485,7 @@ public static class ConfigDbHandler
/// Subscription ID to associate with the servers
/// Whether this is from a subscription
/// Number of successfully imported servers or -1 if failed
- private static async Task AddBatchServers4Custom(Config config, string strData, string subid, bool isSub)
+ private static async Task AddBatchServers4Custom(string strData, string subid, bool isSub)
{
if (strData.IsNullOrEmpty())
{
@@ -1507,14 +1496,13 @@ public static class ConfigDbHandler
if (subItem?.CustomCoreType is null)
{
- return await AddBatchServersDefaultCustom(config, strData, subid, isSub, subItem);
+ return await AddBatchServersDefaultCustom(strData, subid, isSub, subItem);
}
- return await AddBatchServersSpecificCustom(config, strData, subid, isSub, subItem);
+ return await AddBatchServersSpecificCustom(strData, subid, isSub, subItem);
}
private static async Task AddBatchServersDefaultCustom(
- Config config,
string strData,
string subid,
bool isSub,
@@ -1537,7 +1525,7 @@ public static class ConfigDbHandler
}
if (lstProfiles.Count > 0)
{
- var count = await AddBatchCustomServers(config, lstProfiles, subid, isSub, subItem);
+ var count = await AddBatchCustomServers(lstProfiles, subid, isSub, subItem);
if (count > 0)
{
return count;
@@ -1561,11 +1549,10 @@ public static class ConfigDbHandler
profileItem.IsSub = isSub;
profileItem.PreSocksPort = subItem?.PreSocksPort;
- return await AddCustomServer(config, profileItem, true) == 0 ? 1 : -1;
+ return await AddCustomServer(profileItem, true) == 0 ? 1 : -1;
}
private static async Task AddBatchServersSpecificCustom(
- Config config,
string strData,
string subid,
bool isSub,
@@ -1583,18 +1570,17 @@ public static class ConfigDbHandler
if (lstProfiles?.Count > 0)
{
- var count = await AddBatchCustomServers(config, lstProfiles, subid, isSub, subItem);
+ var count = await AddBatchCustomServers(lstProfiles, subid, isSub, subItem);
if (count > 0)
{
return count;
}
}
- return await SaveCustomRawFileServer(config, strData, subid, isSub, subItem, customCoreType);
+ return await SaveCustomRawFileServer(strData, subid, isSub, subItem, customCoreType);
}
private static async Task AddBatchCustomServers(
- Config config,
List lstProfiles,
string subid,
bool isSub,
@@ -1609,14 +1595,14 @@ public static class ConfigDbHandler
if (it.ConfigType == EConfigType.Custom)
{
it.PreSocksPort = subItem?.PreSocksPort;
- if (await AddCustomServer(config, it, true) == 0)
+ if (await AddCustomServer(it, true) == 0)
{
count++;
}
}
else
{
- if (await AddCustomOutboundServer(config, it, true) == 0)
+ if (await AddCustomOutboundServer(it, true) == 0)
{
count++;
}
@@ -1626,7 +1612,6 @@ public static class ConfigDbHandler
}
private static async Task SaveCustomRawFileServer(
- Config config,
string strData,
string subid,
bool isSub,
@@ -1648,7 +1633,7 @@ public static class ConfigDbHandler
PreSocksPort = subItem.PreSocksPort,
};
- return await AddCustomServer(config, profileItem, true) == 0 ? 1 : -1;
+ return await AddCustomServer(profileItem, true) == 0 ? 1 : -1;
static string DetectFileExtension(string data)
{
@@ -1703,7 +1688,7 @@ public static class ConfigDbHandler
/// Subscription ID to associate with the servers
/// Whether this is from a subscription
/// Number of successfully imported servers or -1 if failed
- private static async Task AddBatchServers4SsSIP008(Config config, string strData, string subid, bool isSub)
+ private static async Task AddBatchServers4SsSIP008(string strData, string subid, bool isSub)
{
if (strData.IsNullOrEmpty())
{
@@ -1718,7 +1703,7 @@ public static class ConfigDbHandler
{
ssItem.Subid = subid;
ssItem.IsSub = isSub;
- if (await AddShadowsocksServer(config, ssItem) == 0)
+ if (await AddShadowsocksServer(ssItem) == 0)
{
counter++;
}
@@ -1730,7 +1715,7 @@ public static class ConfigDbHandler
return -1;
}
- private static async Task AddBatchServers4Wireguard(Config config, string strData, string subid, bool isSub)
+ private static async Task AddBatchServers4Wireguard(string strData, string subid, bool isSub)
{
if (strData.IsNullOrEmpty())
{
@@ -1749,7 +1734,7 @@ public static class ConfigDbHandler
{
item.Subid = subid;
item.IsSub = isSub;
- if (await AddWireguardServer(config, item) == 0)
+ if (await AddWireguardServer(item) == 0)
{
counter++;
}
@@ -1760,7 +1745,7 @@ public static class ConfigDbHandler
return -1;
}
- private static async Task AddBatchServers4InnerUri(Config config, string strData, string subid, bool isSub)
+ private static async Task AddBatchServers4InnerUri(string strData, string subid, bool isSub)
{
if (strData.IsNullOrEmpty())
{
@@ -1779,19 +1764,19 @@ public static class ConfigDbHandler
var addStatus = profileItem.ConfigType switch
{
- EConfigType.VMess => await AddVMessServer(config, profileItem, false),
- EConfigType.Shadowsocks => await AddShadowsocksServer(config, profileItem, false),
- EConfigType.HTTP => await AddHttpServer(config, profileItem, false),
- EConfigType.SOCKS => await AddSocksServer(config, profileItem, false),
- EConfigType.Trojan => await AddTrojanServer(config, profileItem, false),
- EConfigType.VLESS => await AddVlessServer(config, profileItem, false),
- EConfigType.Hysteria2 => await AddHysteria2Server(config, profileItem, false),
- EConfigType.TUIC => await AddTuicServer(config, profileItem, false),
- EConfigType.WireGuard => await AddWireguardServer(config, profileItem, false),
- EConfigType.Anytls => await AddAnytlsServer(config, profileItem, false),
- EConfigType.Naive => await AddNaiveServer(config, profileItem, false),
- EConfigType.PolicyGroup or EConfigType.ProxyChain => await AddServerCommon(config, profileItem, false),
- EConfigType.Outbound => await AddCustomOutboundServer(config, profileItem, true, false),
+ EConfigType.VMess => await AddVMessServer(profileItem, false),
+ EConfigType.Shadowsocks => await AddShadowsocksServer(profileItem, false),
+ EConfigType.HTTP => await AddHttpServer(profileItem, false),
+ EConfigType.SOCKS => await AddSocksServer(profileItem, false),
+ EConfigType.Trojan => await AddTrojanServer(profileItem, false),
+ EConfigType.VLESS => await AddVlessServer(profileItem, false),
+ EConfigType.Hysteria2 => await AddHysteria2Server(profileItem, false),
+ EConfigType.TUIC => await AddTuicServer(profileItem, false),
+ EConfigType.WireGuard => await AddWireguardServer(profileItem, false),
+ EConfigType.Anytls => await AddAnytlsServer(profileItem, false),
+ EConfigType.Naive => await AddNaiveServer(profileItem, false),
+ EConfigType.PolicyGroup or EConfigType.ProxyChain => await AddServerCommon(profileItem, false),
+ EConfigType.Outbound => await AddCustomOutboundServer(profileItem, true, false),
_ => -1,
};
if (addStatus == 0)
@@ -1820,7 +1805,7 @@ public static class ConfigDbHandler
/// Subscription ID to associate with the servers
/// Whether this is from a subscription
/// Number of successfully imported servers or -1 if failed
- public static async Task AddBatchServers(Config config, string strData, string subid, bool isSub)
+ public static async Task AddBatchServers(string strData, string subid, bool isSub)
{
if (strData.IsNullOrEmpty())
{
@@ -1831,47 +1816,47 @@ public static class ConfigDbHandler
if (isSub && subid.IsNotEmpty())
{
lstOriSub = await ConfigDbQuery.ProfileItems(subid);
- activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == config.IndexId);
+ activeProfile = lstOriSub?.FirstOrDefault(t => t.IndexId == CurrentConfig.IndexId);
}
var counter = 0;
if (Utils.IsBase64String(strData))
{
- counter = await AddBatchServersCommon(config, Utils.Base64Decode(strData), subid, isSub);
+ counter = await AddBatchServersCommon(Utils.Base64Decode(strData), subid, isSub);
}
if (counter < 1)
{
- counter = await AddBatchServersCommon(config, strData, subid, isSub);
+ counter = await AddBatchServersCommon(strData, subid, isSub);
}
if (counter < 1)
{
- counter = await AddBatchServersCommon(config, Utils.Base64Decode(strData), subid, isSub);
+ counter = await AddBatchServersCommon(Utils.Base64Decode(strData), subid, isSub);
}
if (counter < 1)
{
- counter = await AddBatchServers4SsSIP008(config, strData, subid, isSub);
+ counter = await AddBatchServers4SsSIP008(strData, subid, isSub);
}
//maybe wireguard config
if (counter < 1)
{
- counter = await AddBatchServers4Wireguard(config, strData, subid, isSub);
+ counter = await AddBatchServers4Wireguard(strData, subid, isSub);
}
//May be standard uri mixed with internal uri
var innerUriCount = 0;
if (Utils.IsBase64String(strData))
{
- innerUriCount = await AddBatchServers4InnerUri(config, Utils.Base64Decode(strData), subid, isSub);
+ innerUriCount = await AddBatchServers4InnerUri(Utils.Base64Decode(strData), subid, isSub);
}
if (innerUriCount < 1)
{
- innerUriCount = await AddBatchServers4InnerUri(config, strData, subid, isSub);
+ innerUriCount = await AddBatchServers4InnerUri(strData, subid, isSub);
}
if (innerUriCount < 1)
{
- innerUriCount = await AddBatchServers4InnerUri(config, Utils.Base64Decode(strData), subid, isSub);
+ innerUriCount = await AddBatchServers4InnerUri(Utils.Base64Decode(strData), subid, isSub);
}
if (innerUriCount > 0)
{
@@ -1888,12 +1873,12 @@ public static class ConfigDbHandler
//maybe other sub
if (counter < 1)
{
- counter = await AddBatchServers4Custom(config, strData, subid, isSub);
+ counter = await AddBatchServers4Custom(strData, subid, isSub);
}
if (counter > 0 && lstOriSub is { Count: > 0 })
{
- await RemoveServers(config, lstOriSub.Where(item => item.IsSub).ToList());
+ await RemoveServers(lstOriSub.Where(item => item.IsSub).ToList());
}
//Select active node
@@ -1935,7 +1920,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Subscription URL
/// 0 if successful, -1 if failed
- public static async Task AddSubItem(Config config, string url)
+ public static async Task AddSubItem(string url)
{
//already exists
var count = await SQLiteHelper.Instance.TableAsync().CountAsync(e => e.Url == url);
@@ -1965,7 +1950,7 @@ public static class ConfigDbHandler
var queryVars = Utils.ParseQueryString(uri.Query);
subItem.Remarks = queryVars["remarks"] ?? "import_sub";
- return await AddSubItem(config, subItem);
+ return await AddSubItem(subItem);
}
///
@@ -1974,7 +1959,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Subscription item to add or update
/// 0 if successful, -1 if failed
- public static async Task AddSubItem(Config config, SubItem subItem)
+ public static async Task AddSubItem(SubItem subItem)
{
var item = await ConfigDbQuery.GetSubItem(subItem.Id);
if (item is null)
@@ -2034,7 +2019,7 @@ public static class ConfigDbHandler
/// Subscription ID
/// Whether to only remove servers marked as subscription items
/// 0 if successful, -1 if failed
- public static async Task RemoveServersViaSubid(Config config, string subid, bool isSub)
+ public static async Task RemoveServersViaSubid(string subid, bool isSub)
{
if (subid.IsNullOrEmpty())
{
@@ -2063,7 +2048,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Subscription ID to delete
/// 0 if successful
- public static async Task DeleteSubItem(Config config, string id)
+ public static async Task DeleteSubItem(string id)
{
var item = await ConfigDbQuery.GetSubItem(id);
if (item is null)
@@ -2071,12 +2056,12 @@ public static class ConfigDbHandler
return 0;
}
await SQLiteHelper.Instance.DeleteAsync(item);
- await RemoveServersViaSubid(config, id, false);
+ await RemoveServersViaSubid(id, false);
- if (item.Id == config.SubIndexId)
+ if (item.Id == CurrentConfig.SubIndexId)
{
var subs = await ConfigDbQuery.SubItems();
- config.SubIndexId = subs.LastOrDefault()?.Id;
+ CurrentConfig.SubIndexId = subs.LastOrDefault()?.Id;
}
return 0;
@@ -2089,7 +2074,7 @@ public static class ConfigDbHandler
/// List of profiles to move
/// Target subscription ID
/// 0 if successful
- public static async Task MoveToGroup(Config config, List lstProfile, string subid)
+ public static async Task MoveToGroup(List lstProfile, string subid)
{
foreach (var item in lstProfile)
{
@@ -2110,7 +2095,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Routing item to save
/// 0 if successful, -1 if failed
- public static async Task SaveRoutingItem(Config config, RoutingItem item)
+ public static async Task SaveRoutingItem(RoutingItem item)
{
if (item.Id.IsNullOrEmpty())
{
@@ -2253,7 +2238,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Routing item to set as default
/// 0 if successful
- public static async Task SetDefaultRouting(Config config, RoutingItem routingItem)
+ public static async Task SetDefaultRouting(RoutingItem routingItem)
{
var items = await ConfigDbQuery.RoutingItems();
if (items.Any(t => t.Id == routingItem.Id && t.IsActive == true))
@@ -2284,13 +2269,13 @@ public static class ConfigDbHandler
///
/// Current configuration
/// The default routing item
- public static async Task GetDefaultRouting(Config config)
+ public static async Task GetDefaultRouting()
{
var item = await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync(it => it.IsActive == true);
if (item is null)
{
var item2 = await SQLiteHelper.Instance.TableAsync().FirstOrDefaultAsync();
- await SetDefaultRouting(config, item2);
+ await SetDefaultRouting(item2);
return item2;
}
@@ -2303,15 +2288,15 @@ public static class ConfigDbHandler
/// Current configuration
/// Whether to import advanced rules
/// 0 if successful
- public static async Task InitRouting(Config config, bool blImportAdvancedRules = false)
+ public static async Task InitRouting(bool blImportAdvancedRules = false)
{
- if (config.ConstItem.RouteRulesTemplateSourceUrl.IsNullOrEmpty())
+ if (CurrentConfig.ConstItem.RouteRulesTemplateSourceUrl.IsNullOrEmpty())
{
- await InitBuiltinRouting(config, blImportAdvancedRules);
+ await InitBuiltinRouting(blImportAdvancedRules);
}
else
{
- await InitExternalRouting(config, blImportAdvancedRules);
+ await InitExternalRouting(blImportAdvancedRules);
}
return 0;
@@ -2324,19 +2309,19 @@ public static class ConfigDbHandler
/// Current configuration
/// Whether to import advanced rules
/// 0 if successful
- public static async Task InitExternalRouting(Config config, bool blImportAdvancedRules = false)
+ public static async Task InitExternalRouting(bool blImportAdvancedRules = false)
{
using var downloadHandle = await DownloadService.CreateDownloadServiceWithCheck();
- var templateContent = await downloadHandle.TryDownloadString(config.ConstItem.RouteRulesTemplateSourceUrl);
+ var templateContent = await downloadHandle.TryDownloadString(CurrentConfig.ConstItem.RouteRulesTemplateSourceUrl);
if (templateContent.IsNullOrEmpty())
{
- return await InitBuiltinRouting(config, blImportAdvancedRules); // fallback
+ return await InitBuiltinRouting(blImportAdvancedRules); // fallback
}
var template = JsonUtils.Deserialize(templateContent);
if (template == null)
{
- return await InitBuiltinRouting(config, blImportAdvancedRules); // fallback
+ return await InitBuiltinRouting(blImportAdvancedRules); // fallback
}
var items = await ConfigDbQuery.RoutingItems();
@@ -2373,7 +2358,7 @@ public static class ConfigDbHandler
//first rule as default at first startup
if (!blImportAdvancedRules && i == 0)
{
- await SetDefaultRouting(config, item);
+ await SetDefaultRouting(item);
}
}
@@ -2387,7 +2372,7 @@ public static class ConfigDbHandler
/// Current configuration
/// Whether to import advanced rules
/// 0 if successful
- public static async Task InitBuiltinRouting(Config config, bool blImportAdvancedRules = false)
+ public static async Task InitBuiltinRouting(bool blImportAdvancedRules = false)
{
var ver = "V4-";
var items = await ConfigDbQuery.RoutingItems();
@@ -2404,14 +2389,14 @@ public static class ConfigDbHandler
{
//migrate
//TODO Temporary code to be removed later
- if (config.RoutingBasicItem.RoutingIndexId.IsNotEmpty())
+ if (CurrentConfig.RoutingBasicItem.RoutingIndexId.IsNotEmpty())
{
- var item = items.FirstOrDefault(t => t.Id == config.RoutingBasicItem.RoutingIndexId);
+ var item = items.FirstOrDefault(t => t.Id == CurrentConfig.RoutingBasicItem.RoutingIndexId);
if (item != null)
{
- await SetDefaultRouting(config, item);
+ await SetDefaultRouting(item);
}
- config.RoutingBasicItem.RoutingIndexId = string.Empty;
+ CurrentConfig.RoutingBasicItem.RoutingIndexId = string.Empty;
}
return 0;
@@ -2447,7 +2432,7 @@ public static class ConfigDbHandler
if (!blImportAdvancedRules)
{
- await SetDefaultRouting(config, item2);
+ await SetDefaultRouting(item2);
}
return 0;
}
@@ -2472,7 +2457,7 @@ public static class ConfigDbHandler
///
/// Current configuration
/// 0 if successful
- public static async Task InitBuiltinDNS(Config config)
+ public static async Task InitBuiltinDNS()
{
var items = await ConfigDbQuery.DNSItems();
@@ -2501,7 +2486,7 @@ public static class ConfigDbHandler
CoreType = ECoreType.Xray,
Enabled = false,
};
- await SaveDNSItems(config, item);
+ await SaveDNSItems(item);
var item2 = new DNSItem()
{
@@ -2509,7 +2494,7 @@ public static class ConfigDbHandler
CoreType = ECoreType.sing_box,
Enabled = false,
};
- await SaveDNSItems(config, item2);
+ await SaveDNSItems(item2);
}
return 0;
@@ -2521,7 +2506,7 @@ public static class ConfigDbHandler
/// Current configuration
/// DNS item to save
/// 0 if successful, -1 if failed
- public static async Task SaveDNSItems(Config config, DNSItem item)
+ public static async Task SaveDNSItems(DNSItem item)
{
if (item == null)
{
@@ -2622,7 +2607,7 @@ public static class ConfigDbHandler
#region Custom Config
- public static async Task InitBuiltinFullConfigTemplate(Config config)
+ public static async Task InitBuiltinFullConfigTemplate()
{
var items = await ConfigDbQuery.FullConfigTemplateItem();
if (items.Count <= 0)
@@ -2632,20 +2617,20 @@ public static class ConfigDbHandler
Remarks = "V2ray",
CoreType = ECoreType.Xray,
};
- await SaveFullConfigTemplate(config, item);
+ await SaveFullConfigTemplate(item);
var item2 = new FullConfigTemplateItem()
{
Remarks = "sing-box",
CoreType = ECoreType.sing_box,
};
- await SaveFullConfigTemplate(config, item2);
+ await SaveFullConfigTemplate(item2);
}
return 0;
}
- public static async Task SaveFullConfigTemplate(Config config, FullConfigTemplateItem item)
+ public static async Task SaveFullConfigTemplate(FullConfigTemplateItem item)
{
if (item == null)
{
@@ -2678,25 +2663,25 @@ public static class ConfigDbHandler
/// Current configuration
/// Type of preset (Default, Russia, Iran)
/// True if successful
- public static async Task ApplyRegionalPreset(Config config, EPresetType type)
+ public static async Task ApplyRegionalPreset(EPresetType type)
{
switch (type)
{
case EPresetType.Default:
- config.ConstItem.GeoSourceUrl = "";
- config.ConstItem.SrsSourceUrl = "";
- config.ConstItem.RouteRulesTemplateSourceUrl = "";
+ CurrentConfig.ConstItem.GeoSourceUrl = "";
+ CurrentConfig.ConstItem.SrsSourceUrl = "";
+ CurrentConfig.ConstItem.RouteRulesTemplateSourceUrl = "";
await SQLiteHelper.Instance.DeleteAllAsync();
- await InitBuiltinDNS(config);
+ await InitBuiltinDNS();
- config.SimpleDNSItem = InitBuiltinSimpleDNS();
+ CurrentConfig.SimpleDNSItem = InitBuiltinSimpleDNS();
break;
case EPresetType.Russia:
- config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[1];
- config.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[1];
- config.ConstItem.RouteRulesTemplateSourceUrl = Global.RoutingRulesSources[1];
+ CurrentConfig.ConstItem.GeoSourceUrl = Global.GeoFilesSources[1];
+ CurrentConfig.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[1];
+ CurrentConfig.ConstItem.RouteRulesTemplateSourceUrl = Global.RoutingRulesSources[1];
var xrayDnsRussia = await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json");
var singboxDnsRussia = await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json");
@@ -2706,20 +2691,20 @@ public static class ConfigDbHandler
{
xrayDnsRussia.Enabled = true;
singboxDnsRussia.Enabled = true;
- config.SimpleDNSItem = InitBuiltinSimpleDNS();
+ CurrentConfig.SimpleDNSItem = InitBuiltinSimpleDNS();
}
else
{
- config.SimpleDNSItem = simpleDnsRussia;
+ CurrentConfig.SimpleDNSItem = simpleDnsRussia;
}
- await SaveDNSItems(config, xrayDnsRussia);
- await SaveDNSItems(config, singboxDnsRussia);
+ await SaveDNSItems(xrayDnsRussia);
+ await SaveDNSItems(singboxDnsRussia);
break;
case EPresetType.Iran:
- config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[2];
- config.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[2];
- config.ConstItem.RouteRulesTemplateSourceUrl = Global.RoutingRulesSources[2];
+ CurrentConfig.ConstItem.GeoSourceUrl = Global.GeoFilesSources[2];
+ CurrentConfig.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[2];
+ CurrentConfig.ConstItem.RouteRulesTemplateSourceUrl = Global.RoutingRulesSources[2];
var xrayDnsIran = await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[2] + "v2ray.json");
var singboxDnsIran = await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[2] + "sing_box.json");
@@ -2729,14 +2714,14 @@ public static class ConfigDbHandler
{
xrayDnsIran.Enabled = true;
singboxDnsIran.Enabled = true;
- config.SimpleDNSItem = InitBuiltinSimpleDNS();
+ CurrentConfig.SimpleDNSItem = InitBuiltinSimpleDNS();
}
else
{
- config.SimpleDNSItem = simpleDnsIran;
+ CurrentConfig.SimpleDNSItem = simpleDnsIran;
}
- await SaveDNSItems(config, xrayDnsIran);
- await SaveDNSItems(config, singboxDnsIran);
+ await SaveDNSItems(xrayDnsIran);
+ await SaveDNSItems(singboxDnsIran);
break;
}
@@ -2901,7 +2886,6 @@ public static class ConfigDbHandler
private static async Task MigrateProfileExtraV2ToV3Sub(List batch)
{
var updateProfileItems = new List();
- var config = ConfigTextHandler.Config;
foreach (var item in batch)
{
@@ -2935,9 +2919,9 @@ public static class ConfigDbHandler
{
SalamanderPass = item.Path.NullIfEmpty(),
Ports = item.Ports.NullIfEmpty(),
- UpMbps = config.HysteriaItem.UpMbps,
- DownMbps = config.HysteriaItem.DownMbps,
- HopInterval = config.HysteriaItem.HopInterval.ToString(),
+ UpMbps = CurrentConfig.HysteriaItem.UpMbps,
+ DownMbps = CurrentConfig.HysteriaItem.DownMbps,
+ HopInterval = CurrentConfig.HysteriaItem.HopInterval.ToString(),
};
break;
diff --git a/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs b/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs
index 36832725..7edf9377 100644
--- a/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs
+++ b/v2rayN/ServiceLib/Handler/SubscriptionHandler.cs
@@ -106,7 +106,7 @@ public class SubscriptionHandler(
await updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgStartParsingSubscription}");
// Add servers to configuration
- var ret = await ConfigDbHandler.AddBatchServers(_config, result, id, true);
+ var ret = await ConfigDbHandler.AddBatchServers(result, id, true);
if (ret <= 0)
{
Logging.SaveLog("FailedImportSubscription");
diff --git a/v2rayN/ServiceLib/Manager/TaskManager.cs b/v2rayN/ServiceLib/Manager/TaskManager.cs
index d3672b19..ece852e2 100644
--- a/v2rayN/ServiceLib/Manager/TaskManager.cs
+++ b/v2rayN/ServiceLib/Manager/TaskManager.cs
@@ -113,7 +113,7 @@ public class TaskManager
});
await handler.UpdateProcess(item.Id);
item.UpdateTime = updateTime;
- await ConfigDbHandler.AddSubItem(_config, item);
+ await ConfigDbHandler.AddSubItem(item);
await Task.Delay(1000);
}
}
diff --git a/v2rayN/ServiceLib/ViewModels/AddGroupServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddGroupServerViewModel.cs
index d89bcf0d..54870170 100644
--- a/v2rayN/ServiceLib/ViewModels/AddGroupServerViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/AddGroupServerViewModel.cs
@@ -245,7 +245,7 @@ public partial class AddGroupServerViewModel : MyReactiveObject, ICloseable
SelectedSource.SetProtocolExtra(protocolExtra);
- if (await ConfigDbHandler.AddServerCommon(_config, SelectedSource) == 0)
+ if (await ConfigDbHandler.AddServerCommon(SelectedSource) == 0)
{
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
RequestClose?.Invoke(this, EventArgs.Empty);
diff --git a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs
index 916941fd..4832528e 100644
--- a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs
@@ -71,7 +71,7 @@ public partial class AddServer2ViewModel : MyReactiveObject, ICloseable
IsSingboxEndpoint = IsSingboxEndpoint ? true : null,
});
- if (await ConfigDbHandler.EditCustomServer(_config, SelectedSource) == 0)
+ if (await ConfigDbHandler.EditCustomServer(SelectedSource) == 0)
{
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
RequestClose?.Invoke(this, EventArgs.Empty);
@@ -92,7 +92,7 @@ public partial class AddServer2ViewModel : MyReactiveObject, ICloseable
var item = await ConfigDbQuery.GetProfileItem(SelectedSource.IndexId);
item ??= SelectedSource;
item.Address = fileName;
- var result = item.ConfigType == EConfigType.Outbound ? await ConfigDbHandler.AddCustomOutboundServer(_config, item, false) : await ConfigDbHandler.AddCustomServer(_config, item, false);
+ var result = item.ConfigType == EConfigType.Outbound ? await ConfigDbHandler.AddCustomOutboundServer(item, false) : await ConfigDbHandler.AddCustomServer(item, false);
if (result == 0)
{
NoticeManager.Instance.Enqueue(ResUI.SuccessfullyImportedCustomServer);
diff --git a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs
index dc864902..6eddfda6 100644
--- a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs
@@ -1,5 +1,3 @@
-
-
namespace ServiceLib.ViewModels;
public partial class AddServerViewModel : MyReactiveObject, ICloseable
@@ -594,7 +592,7 @@ public partial class AddServerViewModel : MyReactiveObject, ICloseable
});
SelectedSource.SetTransportExtra(transport);
- if (await ConfigDbHandler.AddServer(_config, SelectedSource) == 0)
+ if (await ConfigDbHandler.AddServer(SelectedSource) == 0)
{
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
RequestClose?.Invoke(this, EventArgs.Empty);
@@ -625,6 +623,7 @@ public partial class AddServerViewModel : MyReactiveObject, ICloseable
XdriveS3PathStyle = true;
break;
+
case "Google Drive":
XdriveService = "google-drive";
SelectedSource.StreamSecurity = Global.StreamSecurity;
@@ -649,6 +648,7 @@ public partial class AddServerViewModel : MyReactiveObject, ICloseable
}
break;
+
case "AWS S3 (Global)":
XdriveService = "s3";
if (XdriveS3Region.IsNullOrEmpty())
@@ -658,6 +658,7 @@ public partial class AddServerViewModel : MyReactiveObject, ICloseable
XdriveS3PathStyle = false;
break;
+
case "Yandex Cloud S3":
XdriveService = "s3";
if (XdriveS3Region.IsNullOrEmpty())
@@ -667,6 +668,7 @@ public partial class AddServerViewModel : MyReactiveObject, ICloseable
XdriveS3PathStyle = true;
break;
+
case "ArvanCloud S3":
XdriveService = "s3";
if (XdriveS3Region.IsNullOrEmpty())
@@ -676,6 +678,7 @@ public partial class AddServerViewModel : MyReactiveObject, ICloseable
XdriveS3PathStyle = true;
break;
+
case "Custom S3":
XdriveService = "s3";
break;
diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs
index a9248400..f092f1c4 100644
--- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs
@@ -207,7 +207,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
item1.UseSystemHosts = UseSystemHostsCompatible;
item1.NormalDNS = NormalDNSCompatible;
item1.TunDNS = TunDNSCompatible;
- await ConfigDbHandler.SaveDNSItems(_config, item1);
+ await ConfigDbHandler.SaveDNSItems(item1);
var item2 = await ConfigDbQuery.GetDNSItem(ECoreType.sing_box);
item2.Enabled = SBCustomDNSEnableCompatible;
@@ -215,7 +215,7 @@ public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
item2.DomainDNSAddress = DomainDNSAddress2Compatible;
item2.NormalDNS = JsonUtils.Serialize(JsonUtils.Deserialize(NormalDNS2Compatible));
item2.TunDNS = JsonUtils.Serialize(JsonUtils.Deserialize(TunDNS2Compatible));
- await ConfigDbHandler.SaveDNSItems(_config, item2);
+ await ConfigDbHandler.SaveDNSItems(item2);
await ConfigTextHandler.SaveConfig();
RequestClose?.Invoke(this, EventArgs.Empty);
diff --git a/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs b/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs
index 9a79aa58..925e9c61 100644
--- a/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/FullConfigTemplateViewModel.cs
@@ -104,7 +104,7 @@ public partial class FullConfigTemplateViewModel : MyReactiveObject, ICloseable
item.AddProxyOnly = AddProxyOnly4Ray;
item.ProxyDetour = ProxyDetour4Ray;
- await ConfigDbHandler.SaveFullConfigTemplate(_config, item);
+ await ConfigDbHandler.SaveFullConfigTemplate(item);
return true;
}
@@ -122,7 +122,7 @@ public partial class FullConfigTemplateViewModel : MyReactiveObject, ICloseable
item.AddProxyOnly = AddProxyOnly4Singbox;
item.ProxyDetour = ProxyDetour4Singbox;
- await ConfigDbHandler.SaveFullConfigTemplate(_config, item);
+ await ConfigDbHandler.SaveFullConfigTemplate(item);
return true;
}
}
diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
index c66b4bb3..0c37c7c5 100644
--- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
@@ -331,8 +331,8 @@ public partial class MainWindowViewModel : MyReactiveObject
}
//await ConfigHandler.InitBuiltinRouting(_config);
- await ConfigDbHandler.InitBuiltinDNS(_config);
- await ConfigDbHandler.InitBuiltinFullConfigTemplate(_config);
+ await ConfigDbHandler.InitBuiltinDNS();
+ await ConfigDbHandler.InitBuiltinFullConfigTemplate();
await ProfileExManager.Instance.Init();
await CoreManager.Instance.Init(_config, UpdateHandler);
await CertPemManager.Instance.Init(_config);
@@ -499,7 +499,7 @@ public partial class MainWindowViewModel : MyReactiveObject
}
stringData = result;
}
- var ret = await ConfigDbHandler.AddBatchServers(_config, stringData, _config.SubIndexId, false);
+ var ret = await ConfigDbHandler.AddBatchServers(stringData, _config.SubIndexId, false);
if (ret > 0)
{
await RefreshSubscriptions();
@@ -549,7 +549,7 @@ public partial class MainWindowViewModel : MyReactiveObject
}
else
{
- var ret = await ConfigDbHandler.AddBatchServers(_config, result, _config.SubIndexId, false);
+ var ret = await ConfigDbHandler.AddBatchServers(result, _config.SubIndexId, false);
if (ret > 0)
{
await RefreshSubscriptions();
@@ -610,7 +610,7 @@ public partial class MainWindowViewModel : MyReactiveObject
var ret = await AppManager.Instance.WindowDialog.ShowDialogAsync(routingSettingViewModel);
if (ret == true)
{
- await ConfigDbHandler.InitBuiltinRouting(_config);
+ await ConfigDbHandler.InitBuiltinRouting();
RxSchedulers.MainThreadScheduler.Schedule(async () =>
{
await StatusBarViewModel.RefreshRoutingsMenu();
@@ -788,8 +788,8 @@ public partial class MainWindowViewModel : MyReactiveObject
public async Task ApplyRegionalPreset(EPresetType type)
{
- await ConfigDbHandler.ApplyRegionalPreset(_config, type);
- await ConfigDbHandler.InitRouting(_config);
+ await ConfigDbHandler.ApplyRegionalPreset(type);
+ await ConfigDbHandler.InitRouting();
RxSchedulers.MainThreadScheduler.Schedule(async () =>
{
await StatusBarViewModel.RefreshRoutingsMenu();
diff --git a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs
index 593a61cd..680051d6 100644
--- a/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/ProfilesViewModel.cs
@@ -514,7 +514,7 @@ public partial class ProfilesViewModel : MyReactiveObject
}
var exists = lstSelected.Exists(t => t.IndexId == _config.IndexId);
- await ConfigDbHandler.RemoveServers(_config, lstSelected);
+ await ConfigDbHandler.RemoveServers(lstSelected);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
if (lstSelected.Count == ProfileItems.Count)
{
@@ -534,7 +534,7 @@ public partial class ProfilesViewModel : MyReactiveObject
return;
}
- var tuple = await ConfigDbHandler.DedupServerList(_config, _config.SubIndexId);
+ var tuple = await ConfigDbHandler.DedupServerList(_config.SubIndexId);
if (tuple.Item1 > 0 || tuple.Item2 > 0)
{
await RefreshServers();
@@ -550,7 +550,7 @@ public partial class ProfilesViewModel : MyReactiveObject
{
return;
}
- if (await ConfigDbHandler.CopyServer(_config, lstSelected) == 0)
+ if (await ConfigDbHandler.CopyServer(lstSelected) == 0)
{
await RefreshServers();
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
@@ -609,7 +609,7 @@ public partial class ProfilesViewModel : MyReactiveObject
private async Task GenGroupAllServer()
{
- var ret = await ConfigDbHandler.AddGroupAllServer(_config, SelectedSub);
+ var ret = await ConfigDbHandler.AddGroupAllServer( SelectedSub);
if (ret.Success != true)
{
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
@@ -621,7 +621,7 @@ public partial class ProfilesViewModel : MyReactiveObject
private async Task GenGroupRegionServer()
{
- var ret = await ConfigDbHandler.AddGroupRegionServer(_config, SelectedSub);
+ var ret = await ConfigDbHandler.AddGroupRegionServer( SelectedSub);
if (ret.Success != true)
{
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
@@ -641,7 +641,7 @@ public partial class ProfilesViewModel : MyReactiveObject
_dicHeaderSort.TryAdd(colName, true);
_dicHeaderSort.TryGetValue(colName, out var asc);
- if (await ConfigDbHandler.SortServers(_config, _config.SubIndexId, colName, asc) != 0)
+ if (await ConfigDbHandler.SortServers( _config.SubIndexId, colName, asc) != 0)
{
return;
}
@@ -651,7 +651,7 @@ public partial class ProfilesViewModel : MyReactiveObject
public async Task RemoveInvalidServerResult()
{
- var count = await ConfigDbHandler.RemoveInvalidServerResult(_config, _config.SubIndexId);
+ var count = await ConfigDbHandler.RemoveInvalidServerResult( _config.SubIndexId);
await RefreshServers();
NoticeManager.Instance.Enqueue(string.Format(ResUI.RemoveInvalidServerResultTip, count));
}
@@ -665,7 +665,7 @@ public partial class ProfilesViewModel : MyReactiveObject
return;
}
- await ConfigDbHandler.MoveToGroup(_config, lstSelected, SelectedMoveToGroup.Id);
+ await ConfigDbHandler.MoveToGroup( lstSelected, SelectedMoveToGroup.Id);
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
await RefreshServers();
@@ -683,7 +683,7 @@ public partial class ProfilesViewModel : MyReactiveObject
return;
}
- if (await ConfigDbHandler.MoveServer(_config, lstProfile, index, eMove) == 0)
+ if (await ConfigDbHandler.MoveServer( lstProfile, index, eMove) == 0)
{
await RefreshServers();
}
@@ -695,7 +695,7 @@ public partial class ProfilesViewModel : MyReactiveObject
if (startIndex >= 0 && targetIndex >= 0 && startIndex != targetIndex)
{
var lstProfile = ProfileItems?.Select(t => t.IndexId).ToList() ?? [];
- if (await ConfigDbHandler.MoveServer(_config, lstProfile, startIndex, EMove.Position, targetIndex) == 0)
+ if (await ConfigDbHandler.MoveServer( lstProfile, startIndex, EMove.Position, targetIndex) == 0)
{
await RefreshServers();
}
@@ -717,8 +717,7 @@ public partial class ProfilesViewModel : MyReactiveObject
.Select(item => item.IndexId)
.ToList();
- var result = await ConfigDbHandler.MoveServersTo(
- _config,
+ var result = await ConfigDbHandler.MoveServersTo(
orderedProfileIds,
sourceIndices,
insertIndex);
@@ -921,7 +920,7 @@ public partial class ProfilesViewModel : MyReactiveObject
{
return;
}
- await ConfigDbHandler.DeleteSubItem(_config, item.Id);
+ await ConfigDbHandler.DeleteSubItem( item.Id);
await RefreshSubscriptions();
await SubSelectedChangedAsync();
diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs
index da5add5d..ecc87927 100644
--- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs
@@ -233,7 +233,7 @@ public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable
item.RuleNum = _rules.Count;
item.RuleSet = JsonUtils.Serialize(_rules, false);
- if (await ConfigDbHandler.SaveRoutingItem(_config, item) == 0)
+ if (await ConfigDbHandler.SaveRoutingItem( item) == 0)
{
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
RequestClose?.Invoke(this, EventArgs.Empty);
diff --git a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs
index b45bdb4a..a3963088 100644
--- a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs
@@ -77,7 +77,7 @@ public partial class RoutingSettingViewModel : MyReactiveObject
DomainStrategy = _config.RoutingBasicItem.DomainStrategy;
DomainStrategy4Singbox = _config.RoutingBasicItem.DomainStrategy4Singbox;
- await ConfigDbHandler.InitBuiltinRouting(_config);
+ await ConfigDbHandler.InitBuiltinRouting();
await RefreshRoutingItems();
}
@@ -174,7 +174,7 @@ public partial class RoutingSettingViewModel : MyReactiveObject
return;
}
- if (await ConfigDbHandler.SetDefaultRouting(_config, item) == 0)
+ if (await ConfigDbHandler.SetDefaultRouting( item) == 0)
{
await RefreshRoutingItems();
IsModified = true;
@@ -183,7 +183,7 @@ public partial class RoutingSettingViewModel : MyReactiveObject
private async Task RoutingAdvancedImportRules()
{
- if (await ConfigDbHandler.InitRouting(_config, true) == 0)
+ if (await ConfigDbHandler.InitRouting(true) == 0)
{
await RefreshRoutingItems();
IsModified = true;
diff --git a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
index ddcfb489..d6f4808a 100644
--- a/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
@@ -218,7 +218,7 @@ public partial class StatusBarViewModel : MyReactiveObject
private async Task Init()
{
- await ConfigDbHandler.InitBuiltinRouting(_config);
+ await ConfigDbHandler.InitBuiltinRouting();
await RefreshRoutingsMenu();
await InboundDisplayStatus();
// The view refreshes its icon on initialization; interaction handlers are not registered yet.
@@ -413,7 +413,7 @@ public partial class StatusBarViewModel : MyReactiveObject
return;
}
- if (await ConfigDbHandler.SetDefaultRouting(_config, item) == 0)
+ if (await ConfigDbHandler.SetDefaultRouting(item) == 0)
{
NoticeManager.Instance.SendMessageEx(ResUI.TipChangeRouting);
ReloadRequested.Publish();
diff --git a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs
index d47e3a7e..914d6a29 100644
--- a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs
@@ -89,7 +89,7 @@ public partial class SubEditViewModel : MyReactiveObject, ICloseable
SelectedSource.PrevProfile = PrevProfile;
SelectedSource.NextProfile = NextProfile;
- if (await ConfigDbHandler.AddSubItem(_config, SelectedSource) == 0)
+ if (await ConfigDbHandler.AddSubItem( SelectedSource) == 0)
{
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
RequestClose?.Invoke(this, EventArgs.Empty);
diff --git a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs
index c657b85f..43ab4215 100644
--- a/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs
+++ b/v2rayN/ServiceLib/ViewModels/SubSettingViewModel.cs
@@ -92,7 +92,7 @@ public partial class SubSettingViewModel : MyReactiveObject
foreach (var it in SelectedSources ?? [SelectedSource])
{
- await ConfigDbHandler.DeleteSubItem(_config, it.Id);
+ await ConfigDbHandler.DeleteSubItem( it.Id);
}
await RefreshSubItems();
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
diff --git a/v2rayN/v2rayN.WebAPI/Services/BuiltinDnsProfileBootstrap.cs b/v2rayN/v2rayN.WebAPI/Services/BuiltinDnsProfileBootstrap.cs
index b9ca55de..fef9e9b8 100644
--- a/v2rayN/v2rayN.WebAPI/Services/BuiltinDnsProfileBootstrap.cs
+++ b/v2rayN/v2rayN.WebAPI/Services/BuiltinDnsProfileBootstrap.cs
@@ -9,9 +9,8 @@ internal static class BuiltinDnsProfileBootstrap
];
public static async Task EnsureAsync(
- Config config,
Func>> load,
- Func> save)
+ Func> save)
{
var existing = await load();
foreach (var (coreType, remarks) in BuiltinProfiles)
@@ -27,7 +26,7 @@ internal static class BuiltinDnsProfileBootstrap
CoreType = coreType,
Enabled = false,
};
- if (await save(config, item) != 0)
+ if (await save(item) != 0)
{
throw new IOException($"The built-in {coreType} DNS profile could not be created.");
}
diff --git a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Profiles.cs b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Profiles.cs
index 1950b4d5..a74f3984 100644
--- a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Profiles.cs
+++ b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Profiles.cs
@@ -60,7 +60,7 @@ public sealed partial class V2rayRuntime
var count = await _mutations.RunAsync(async () =>
{
- var imported = await ConfigDbHandler.AddBatchServers(Config, request.Content, groupId, request.IsSubscription);
+ var imported = await ConfigDbHandler.AddBatchServers(request.Content, groupId, request.IsSubscription);
if (imported > 0)
{
await EnsureConfigSaveSucceededAsync(() => ConfigTextHandler.SaveConfig());
@@ -160,13 +160,13 @@ public sealed partial class V2rayRuntime
try
{
result = await _mutations.RunAsync(() => profile.ConfigType.IsGroupType()
- ? ConfigDbHandler.AddServerCommon(Config, profile)
+ ? ConfigDbHandler.AddServerCommon(profile)
: profile.ConfigType switch
{
- EConfigType.Custom when isNew => ConfigDbHandler.AddCustomServer(Config, profile, blDelete: false),
- EConfigType.Outbound when isNew => ConfigDbHandler.AddCustomOutboundServer(Config, profile, blDelete: false, toFile: true),
- EConfigType.Custom or EConfigType.Outbound => ConfigDbHandler.EditCustomServer(Config, profile),
- _ => ConfigDbHandler.AddServer(Config, profile),
+ EConfigType.Custom when isNew => ConfigDbHandler.AddCustomServer(profile, blDelete: false),
+ EConfigType.Outbound when isNew => ConfigDbHandler.AddCustomOutboundServer(profile, blDelete: false, toFile: true),
+ EConfigType.Custom or EConfigType.Outbound => ConfigDbHandler.EditCustomServer(profile),
+ _ => ConfigDbHandler.AddServer(profile),
});
}
catch (Exception exception)
@@ -263,7 +263,7 @@ public sealed partial class V2rayRuntime
await _mutations.RunAsync(async () =>
{
- if (await ConfigDbHandler.RemoveServers(Config, selected) != 0)
+ if (await ConfigDbHandler.RemoveServers(selected) != 0)
{
throw new IOException("ServiceLib could not remove the selected profiles.");
}
@@ -297,7 +297,7 @@ public sealed partial class V2rayRuntime
return OperationView.Fail("profile_not_found", ApiMessageKeys.ProfileNotFound);
}
- if (await _mutations.RunAsync(() => ConfigDbHandler.CopyServer(Config, items)) != 0)
+ if (await _mutations.RunAsync(() => ConfigDbHandler.CopyServer(items)) != 0)
{
return OperationView.Fail("profile_copy_failed", ApiMessageKeys.CommonInvalidInput);
}
@@ -319,7 +319,7 @@ public sealed partial class V2rayRuntime
return OperationView.Fail("profile_not_found", ApiMessageKeys.ProfileNotFound);
}
- if (await _mutations.RunAsync(() => ConfigDbHandler.MoveToGroup(Config, items, request.SubscriptionId ?? string.Empty)) != 0)
+ if (await _mutations.RunAsync(() => ConfigDbHandler.MoveToGroup(items, request.SubscriptionId ?? string.Empty)) != 0)
{
return OperationView.Fail("profile_move_failed", ApiMessageKeys.CommonInvalidInput);
}
@@ -338,7 +338,7 @@ public sealed partial class V2rayRuntime
return OperationView.Fail("profile_not_in_group", ApiMessageKeys.ProfileNotInGroup);
}
- var result = await _mutations.RunAsync(() => ConfigDbHandler.MoveServer(Config, orderedIds, index, request.Direction, request.Position));
+ var result = await _mutations.RunAsync(() => ConfigDbHandler.MoveServer(orderedIds, index, request.Direction, request.Position));
_events.Publish("profiles-changed", new { subscriptionId = groupId });
return result == 0
? OperationView.Ok(ApiMessageKeys.ProfileOrderSaved)
@@ -353,7 +353,7 @@ public sealed partial class V2rayRuntime
return OperationView.Fail("profile_sort_column_invalid", ApiMessageKeys.CommonInvalidInput);
}
- var result = await _mutations.RunAsync(() => ConfigDbHandler.SortServers(Config, groupId, request.Column, request.Ascending));
+ var result = await _mutations.RunAsync(() => ConfigDbHandler.SortServers(groupId, request.Column, request.Ascending));
_events.Publish("profiles-changed", new { subscriptionId = groupId });
return result == 0
? OperationView.Ok(ApiMessageKeys.ProfileOrderSaved)
@@ -362,14 +362,14 @@ public sealed partial class V2rayRuntime
public async Task RemoveDuplicateProfilesAsync(string? subscriptionId)
{
- var result = await _mutations.RunAsync(() => ConfigDbHandler.DedupServerList(Config, subscriptionId ?? Config.SubIndexId ?? string.Empty));
+ var result = await _mutations.RunAsync(() => ConfigDbHandler.DedupServerList(subscriptionId ?? Config.SubIndexId ?? string.Empty));
_events.Publish("profiles-changed", new { subscriptionId = subscriptionId ?? Config.SubIndexId });
return OperationView.Ok(ApiMessageKeys.ProfileDeduplicated, new { removed = result.Item1 - result.Item2 });
}
public async Task RemoveInvalidProfilesAsync(string? subscriptionId)
{
- var count = await _mutations.RunAsync(() => ConfigDbHandler.RemoveInvalidServerResult(Config, subscriptionId ?? Config.SubIndexId ?? string.Empty));
+ var count = await _mutations.RunAsync(() => ConfigDbHandler.RemoveInvalidServerResult(subscriptionId ?? Config.SubIndexId ?? string.Empty));
_events.Publish("profiles-changed", new { subscriptionId = subscriptionId ?? Config.SubIndexId });
return count < 0
? OperationView.Ok(ApiMessageKeys.CommonCompleted, new { removed = 0 })
@@ -389,8 +389,8 @@ public sealed partial class V2rayRuntime
}
var result = await _mutations.RunAsync(() => byRegion
- ? ConfigDbHandler.AddGroupRegionServer(Config, subscription)
- : ConfigDbHandler.AddGroupAllServer(Config, subscription));
+ ? ConfigDbHandler.AddGroupRegionServer(subscription)
+ : ConfigDbHandler.AddGroupAllServer(subscription));
if (!result.Success)
{
return OperationView.Fail("profile_group_empty", ApiMessageKeys.ProfileGrouped, result.Data);
diff --git a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Settings.cs b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Settings.cs
index 87f3b34f..58c9036c 100644
--- a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Settings.cs
+++ b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.Settings.cs
@@ -563,7 +563,7 @@ public sealed partial class V2rayRuntime
|| current.DomainDNSAddress != input.DomainDNSAddress
|| current.Remarks != (input.Remarks ?? current.Remarks);
var item = ApplyDnsProfileInput(current, coreType, input);
- return (Result: await ConfigDbHandler.SaveDNSItems(Config, item), Changed: changed);
+ return (Result: await ConfigDbHandler.SaveDNSItems( item), Changed: changed);
});
if (result.Result == -2)
{
@@ -696,7 +696,7 @@ public sealed partial class V2rayRuntime
item.RuleNum = parsedRules.Count;
}
var result = parsedRules.Count == 0
- ? await ConfigDbHandler.SaveRoutingItem(Config, item)
+ ? await ConfigDbHandler.SaveRoutingItem( item)
: await ConfigDbHandler.AddBatchRoutingRules(item, JsonUtils.Serialize(parsedRules, false));
return (Result: result, Item: (RoutingItem?)item, Changed: changed);
});
@@ -735,7 +735,7 @@ public sealed partial class V2rayRuntime
var fallback = remaining.FirstOrDefault();
if (fallback is not null)
{
- if (await ConfigDbHandler.SetDefaultRouting(Config, fallback) != 0)
+ if (await ConfigDbHandler.SetDefaultRouting( fallback) != 0)
{
throw new IOException("ServiceLib could not select the fallback routing profile.");
}
@@ -772,7 +772,7 @@ public sealed partial class V2rayRuntime
return (Result: -2, Changed: false);
}
var changed = !item.IsActive;
- return (Result: changed ? await ConfigDbHandler.SetDefaultRouting(Config, item) : 0, Changed: changed);
+ return (Result: changed ? await ConfigDbHandler.SetDefaultRouting( item) : 0, Changed: changed);
});
if (result.Result == -2)
{
@@ -993,7 +993,7 @@ public sealed partial class V2rayRuntime
}
var before = await GetActiveRoutingSignatureAsync();
- var result = await _mutations.RunAsync(() => ConfigDbHandler.InitRouting(Config, true));
+ var result = await _mutations.RunAsync(() => ConfigDbHandler.InitRouting( true));
if (result != 0)
{
return OperationView.Fail("routing_import_failed", ApiMessageKeys.RoutingSaveFailed);
@@ -1048,7 +1048,7 @@ public sealed partial class V2rayRuntime
return -2;
}
var item = ApplyCoreConfigTemplateInput(current, coreType, input);
- return await ConfigDbHandler.SaveFullConfigTemplate(Config, item);
+ return await ConfigDbHandler.SaveFullConfigTemplate( item);
});
if (result == -2)
{
@@ -1160,7 +1160,7 @@ public sealed partial class V2rayRuntime
await SQLiteHelper.Instance.DeleteAllAsync();
foreach (var item in stage.DnsItems)
{
- if (await ConfigDbHandler.SaveDNSItems(Config, item) != 0)
+ if (await ConfigDbHandler.SaveDNSItems( item) != 0)
{
throw new IOException($"The {item.CoreType} DNS profile could not be saved.");
}
@@ -1168,7 +1168,7 @@ public sealed partial class V2rayRuntime
// Default routing uses embedded data only; this call performs no network I/O
// because the route template source was cleared in the staged plan.
- if (await ConfigDbHandler.InitRouting(Config, false) != 0)
+ if (await ConfigDbHandler.InitRouting( false) != 0)
{
throw new IOException("The built-in routing profiles could not be initialized.");
}
@@ -1177,7 +1177,7 @@ public sealed partial class V2rayRuntime
{
foreach (var item in stage.DnsItems)
{
- if (await ConfigDbHandler.SaveDNSItems(Config, item) != 0)
+ if (await ConfigDbHandler.SaveDNSItems( item) != 0)
{
throw new IOException($"The {item.CoreType} DNS profile could not be saved.");
}
@@ -1216,7 +1216,7 @@ public sealed partial class V2rayRuntime
var defaultItem = stage.Routing.DefaultRemarks is { } remarks
? stage.Routing.Items.FirstOrDefault(item => item.Remarks == remarks)
: null;
- if (defaultItem is not null && await ConfigDbHandler.SetDefaultRouting(Config, defaultItem) != 0)
+ if (defaultItem is not null && await ConfigDbHandler.SetDefaultRouting( defaultItem) != 0)
{
throw new IOException("The first staged routing profile could not be activated.");
}
@@ -1226,7 +1226,7 @@ public sealed partial class V2rayRuntime
{
var existingDefault = currentRoutes.FirstOrDefault(item => item.Id == existingDefaultId);
if (existingDefault is not null && !existingDefault.IsActive
- && await ConfigDbHandler.SetDefaultRouting(Config, existingDefault) != 0)
+ && await ConfigDbHandler.SetDefaultRouting( existingDefault) != 0)
{
throw new IOException("The migrated default routing profile could not be activated.");
}
diff --git a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.cs b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.cs
index 2dad72d7..d2b3d0e3 100644
--- a/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.cs
+++ b/v2rayN/v2rayN.WebAPI/Services/V2rayRuntime.cs
@@ -247,17 +247,16 @@ public sealed partial class V2rayRuntime(
}
await EnsureConfigSaveSucceededAsync(() => ConfigTextHandler.SaveConfig());
});
- await ConfigDbHandler.InitBuiltinDNS(Config);
+ await ConfigDbHandler.InitBuiltinDNS();
await BuiltinDnsProfileBootstrap.EnsureAsync(
- Config,
async () => await ConfigDbQuery.DNSItems() ?? [],
ConfigDbHandler.SaveDNSItems);
- await ConfigDbHandler.InitBuiltinFullConfigTemplate(Config);
+ await ConfigDbHandler.InitBuiltinFullConfigTemplate();
// Keep startup aligned with Desktop's StatusBarViewModel. In particular,
// InitBuiltinRouting owns the RoutingIndexId -> IsActive migration and must
// run even when a restored Desktop database already has routing rows.
- await ConfigDbHandler.InitBuiltinRouting(Config);
- _ = await ConfigDbHandler.GetDefaultRouting(Config);
+ await ConfigDbHandler.InitBuiltinRouting();
+ _ = await ConfigDbHandler.GetDefaultRouting();
var restoredSubscriptions = await ConfigDbQuery.SubItems() ?? [];
var normalizedSubIndexId = NormalizeSelectedSubscriptionId(
Config.SubIndexId,
@@ -437,7 +436,7 @@ public sealed partial class V2rayRuntime(
}
var item = ToSubItem(input, null);
- var result = await _mutations.RunAsync(() => ConfigDbHandler.AddSubItem(Config, item));
+ var result = await _mutations.RunAsync(() => ConfigDbHandler.AddSubItem(item));
if (result != 0)
{
return new(false, "subscription_save_failed", ApiMessageKeys.SubscriptionSaveFailed, null);
@@ -466,7 +465,7 @@ public sealed partial class V2rayRuntime(
var item = ToSubItem(input, existing);
item.Id = id;
- var result = await ConfigDbHandler.AddSubItem(Config, item);
+ var result = await ConfigDbHandler.AddSubItem(item);
if (result != 0)
{
return new SubscriptionMutationResult(false, "subscription_save_failed", ApiMessageKeys.SubscriptionSaveFailed, null);
@@ -496,7 +495,7 @@ public sealed partial class V2rayRuntime(
await _mutations.RunAsync(async () =>
{
- if (await ConfigDbHandler.DeleteSubItem(Config, id) != 0)
+ if (await ConfigDbHandler.DeleteSubItem(id) != 0)
{
throw new IOException("ServiceLib could not delete the subscription.");
}
@@ -1178,7 +1177,7 @@ public sealed partial class V2rayRuntime(
if (item is not null)
{
item.UpdateTime = updateTime;
- if (await ConfigDbHandler.AddSubItem(Config, item) != 0)
+ if (await ConfigDbHandler.AddSubItem(item) != 0)
{
throw new IOException("ServiceLib could not save the subscription timestamp.");
}
@@ -1191,7 +1190,7 @@ public sealed partial class V2rayRuntime(
if (item.Enabled)
{
item.UpdateTime = updateTime;
- if (await ConfigDbHandler.AddSubItem(Config, item) != 0)
+ if (await ConfigDbHandler.AddSubItem(item) != 0)
{
throw new IOException("ServiceLib could not save the subscription timestamp.");
}
diff --git a/v2rayN/v2rayN.WebAPI/Tests/BuiltinDnsProfileBootstrapTests.cs b/v2rayN/v2rayN.WebAPI/Tests/BuiltinDnsProfileBootstrapTests.cs
index 0fea7ac3..6bf87531 100644
--- a/v2rayN/v2rayN.WebAPI/Tests/BuiltinDnsProfileBootstrapTests.cs
+++ b/v2rayN/v2rayN.WebAPI/Tests/BuiltinDnsProfileBootstrapTests.cs
@@ -57,9 +57,8 @@ public class BuiltinDnsProfileBootstrapTests
var rows = new List(initial);
var savedTypes = new List();
await BuiltinDnsProfileBootstrap.EnsureAsync(
- new Config(),
() => Task.FromResult>(rows.ToArray()),
- (_, item) =>
+ (item) =>
{
rows.Add(item);
savedTypes.Add(item.CoreType);
diff --git a/v2rayN/v2rayN.WebAPI/Tests/ParityValidationTests.cs b/v2rayN/v2rayN.WebAPI/Tests/ParityValidationTests.cs
index e70ccbf0..4e7e61a0 100644
--- a/v2rayN/v2rayN.WebAPI/Tests/ParityValidationTests.cs
+++ b/v2rayN/v2rayN.WebAPI/Tests/ParityValidationTests.cs
@@ -24,7 +24,7 @@ public class ParityValidationTests
await code.Should().BeEqualTo("ok");
await profile.IsValid().Should().BeFalse();
- var result = await ConfigDbHandler.AddShadowsocksServer(new Config(), profile, toFile: false);
+ var result = await ConfigDbHandler.AddShadowsocksServer( profile, toFile: false);
await result.Should().BeEqualTo(0);
await profile.ConfigVersion.Should().BeEqualTo(4);
@@ -41,7 +41,7 @@ public class ParityValidationTests
await code.Should().BeEqualTo("ok");
await profile.IsValid().Should().BeTrue();
- var result = await ConfigDbHandler.AddShadowsocksServer(new Config(), profile, toFile: false);
+ var result = await ConfigDbHandler.AddShadowsocksServer( profile, toFile: false);
await result.Should().BeEqualTo(0);
}
@@ -54,7 +54,7 @@ public class ParityValidationTests
var valid = V2rayRuntime.TryValidateProfile(profile, out _, out _);
await valid.Should().BeTrue();
- var result = await ConfigDbHandler.AddShadowsocksServer(new Config(), profile, toFile: false);
+ var result = await ConfigDbHandler.AddShadowsocksServer(profile, toFile: false);
await result.Should().BeEqualTo(-1);
}
diff --git a/v2rayN/v2rayN/Manager/WindowsManager.cs b/v2rayN/v2rayN/Manager/WindowsManager.cs
index ffe90a9b..6d3a3a24 100644
--- a/v2rayN/v2rayN/Manager/WindowsManager.cs
+++ b/v2rayN/v2rayN/Manager/WindowsManager.cs
@@ -55,7 +55,7 @@ public sealed class WindowsManager
{
try
{
- var item = await ConfigDbHandler.GetDefaultRouting(config);
+ var item = await ConfigDbHandler.GetDefaultRouting();
if (item == null || item.CustomIcon.IsNullOrEmpty() || !File.Exists(item.CustomIcon))
{
return null;