mirror of https://github.com/2dust/v2rayN
Refactor
parent
86f3ed29f9
commit
7b9f1e6788
|
@ -126,6 +126,7 @@ namespace v2rayN
|
|||
};
|
||||
|
||||
public const string Hysteria2ProtocolShare = "hy2://";
|
||||
|
||||
public static readonly Dictionary<EConfigType, string> ProtocolShares = new()
|
||||
{
|
||||
{EConfigType.VMess,"vmess://"},
|
||||
|
|
|
@ -22,10 +22,10 @@ namespace v2rayN.Handler
|
|||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static int LoadConfig(ref Config config)
|
||||
public static int LoadConfig(ref Config? config)
|
||||
{
|
||||
//载入配置文件
|
||||
string result = Utils.LoadResource(Utils.GetConfigPath(configRes));
|
||||
var result = Utils.LoadResource(Utils.GetConfigPath(configRes));
|
||||
if (!Utils.IsNullOrEmpty(result))
|
||||
{
|
||||
//转成Json
|
||||
|
@ -214,7 +214,7 @@ namespace v2rayN.Handler
|
|||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <returns></returns>
|
||||
public static int SaveConfig(ref Config config, bool reload = true)
|
||||
public static int SaveConfig(Config config, bool reload = true)
|
||||
{
|
||||
ToJsonFile(config);
|
||||
|
||||
|
@ -253,7 +253,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
|
||||
public static int ImportOldGuiConfig(ref Config config, string fileName)
|
||||
public static int ImportOldGuiConfig(Config config, string fileName)
|
||||
{
|
||||
string result = Utils.LoadResource(fileName);
|
||||
if (Utils.IsNullOrEmpty(result))
|
||||
|
@ -343,9 +343,9 @@ namespace v2rayN.Handler
|
|||
};
|
||||
}
|
||||
|
||||
GetDefaultServer(ref config);
|
||||
GetDefaultRouting(ref config);
|
||||
SaveConfig(ref config);
|
||||
GetDefaultServer(config);
|
||||
GetDefaultRouting(config);
|
||||
SaveConfig(config);
|
||||
LoadConfig(ref config);
|
||||
|
||||
return 0;
|
||||
|
@ -361,7 +361,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.VMess;
|
||||
|
||||
|
@ -383,7 +383,7 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
|
||||
SqliteHelper.Instance.UpdateAll(indexs);
|
||||
RemoveServerViaSubid(ref config, subid, false);
|
||||
RemoveServerViaSubid(config, subid, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <returns></returns>
|
||||
public static int CopyServer(ref Config config, List<ProfileItem> indexs)
|
||||
public static int CopyServer(Config config, List<ProfileItem> indexs)
|
||||
{
|
||||
foreach (var it in indexs)
|
||||
{
|
||||
|
@ -431,13 +431,13 @@ namespace v2rayN.Handler
|
|||
if (profileItem.configType == EConfigType.Custom)
|
||||
{
|
||||
profileItem.address = Utils.GetConfigPath(profileItem.address);
|
||||
if (AddCustomServer(ref config, profileItem, false) == 0)
|
||||
if (AddCustomServer(config, profileItem, false) == 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AddServerCommon(ref config, profileItem, true);
|
||||
AddServerCommon(config, profileItem, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,7 +450,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public static int SetDefaultServerIndex(ref Config config, string? indexId)
|
||||
public static int SetDefaultServerIndex(Config config, string? indexId)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(indexId))
|
||||
{
|
||||
|
@ -476,18 +476,18 @@ namespace v2rayN.Handler
|
|||
}
|
||||
if (lstProfile.Count > 0)
|
||||
{
|
||||
return SetDefaultServerIndex(ref config, lstProfile.Where(t => t.port > 0).FirstOrDefault()?.indexId);
|
||||
return SetDefaultServerIndex(config, lstProfile.Where(t => t.port > 0).FirstOrDefault()?.indexId);
|
||||
}
|
||||
return SetDefaultServerIndex(ref config, SqliteHelper.Instance.Table<ProfileItem>().Where(t => t.port > 0).Select(t => t.indexId).FirstOrDefault());
|
||||
return SetDefaultServerIndex(config, SqliteHelper.Instance.Table<ProfileItem>().Where(t => t.port > 0).Select(t => t.indexId).FirstOrDefault());
|
||||
}
|
||||
|
||||
public static ProfileItem? GetDefaultServer(ref Config config)
|
||||
public static ProfileItem? GetDefaultServer(Config config)
|
||||
{
|
||||
var item = LazyConfig.Instance.GetProfileItem(config.indexId);
|
||||
if (item is null)
|
||||
{
|
||||
var item2 = SqliteHelper.Instance.Table<ProfileItem>().FirstOrDefault();
|
||||
SetDefaultServerIndex(ref config, item2?.indexId);
|
||||
SetDefaultServerIndex(config, item2?.indexId);
|
||||
return item2;
|
||||
}
|
||||
|
||||
|
@ -502,7 +502,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="index"></param>
|
||||
/// <param name="eMove"></param>
|
||||
/// <returns></returns>
|
||||
public static int MoveServer(ref Config config, ref List<ProfileItem> lstProfile, int index, EMove eMove, int pos = -1)
|
||||
public static int MoveServer(Config config, ref List<ProfileItem> lstProfile, int index, EMove eMove, int pos = -1)
|
||||
{
|
||||
int count = lstProfile.Count;
|
||||
if (index < 0 || index > lstProfile.Count - 1)
|
||||
|
@ -574,7 +574,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddCustomServer(ref Config config, ProfileItem profileItem, bool blDelete)
|
||||
public static int AddCustomServer(Config config, ProfileItem profileItem, bool blDelete)
|
||||
{
|
||||
var fileName = profileItem.address;
|
||||
if (!File.Exists(fileName))
|
||||
|
@ -606,7 +606,7 @@ namespace v2rayN.Handler
|
|||
profileItem.remarks = $"import custom@{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}";
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, true);
|
||||
AddServerCommon(config, profileItem, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int EditCustomServer(ref Config config, ProfileItem profileItem)
|
||||
public static int EditCustomServer(Config config, ProfileItem profileItem)
|
||||
{
|
||||
if (SqliteHelper.Instance.Update(profileItem) > 0)
|
||||
{
|
||||
|
@ -637,7 +637,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddShadowsocksServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddShadowsocksServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Shadowsocks;
|
||||
|
||||
|
@ -654,7 +654,7 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -665,13 +665,13 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddSocksServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddSocksServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Socks;
|
||||
|
||||
profileItem.address = profileItem.address.TrimEx();
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -682,7 +682,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddTrojanServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddTrojanServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Trojan;
|
||||
|
||||
|
@ -697,7 +697,7 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -708,7 +708,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddHysteria2Server(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddHysteria2Server(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Hysteria2;
|
||||
profileItem.coreType = ECoreType.sing_box;
|
||||
|
@ -726,7 +726,7 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -737,7 +737,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddTuicServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddTuicServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.Tuic;
|
||||
profileItem.coreType = ECoreType.sing_box;
|
||||
|
@ -765,12 +765,12 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int SortServers(ref Config config, string subId, string colName, bool asc)
|
||||
public static int SortServers(Config config, string subId, string colName, bool asc)
|
||||
{
|
||||
var lstModel = LazyConfig.Instance.ProfileItems(subId, "");
|
||||
if (lstModel.Count <= 0)
|
||||
|
@ -872,7 +872,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="profileItem"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddVlessServer(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddVlessServer(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configType = EConfigType.VLESS;
|
||||
|
||||
|
@ -894,7 +894,7 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
AddServerCommon(ref config, profileItem, toFile);
|
||||
AddServerCommon(config, profileItem, toFile);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -923,7 +923,7 @@ namespace v2rayN.Handler
|
|||
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
|
||||
}
|
||||
|
||||
public static int AddServerCommon(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
public static int AddServerCommon(Config config, ProfileItem profileItem, bool toFile = true)
|
||||
{
|
||||
profileItem.configVersion = 2;
|
||||
|
||||
|
@ -1024,7 +1024,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="clipboardData"></param>
|
||||
/// <param name="subid"></param>
|
||||
/// <returns>成功导入的数量</returns>
|
||||
private static int AddBatchServers(ref Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
private static int AddBatchServers(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
{
|
||||
|
@ -1035,7 +1035,7 @@ namespace v2rayN.Handler
|
|||
//remove sub items
|
||||
if (isSub && !Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
RemoveServerViaSubid(ref config, subid, isSub);
|
||||
RemoveServerViaSubid(config, subid, isSub);
|
||||
subFilter = LazyConfig.Instance.GetSubItem(subid)?.filter ?? "";
|
||||
}
|
||||
|
||||
|
@ -1053,7 +1053,7 @@ namespace v2rayN.Handler
|
|||
//maybe sub
|
||||
if (!isSub && (str.StartsWith(Global.HttpsProtocol) || str.StartsWith(Global.HttpProtocol)))
|
||||
{
|
||||
if (AddSubItem(ref config, str) == 0)
|
||||
if (AddSubItem(config, str) == 0)
|
||||
{
|
||||
countServers++;
|
||||
}
|
||||
|
@ -1101,31 +1101,31 @@ namespace v2rayN.Handler
|
|||
|
||||
if (profileItem.configType == EConfigType.VMess)
|
||||
{
|
||||
addStatus = AddServer(ref config, profileItem, false);
|
||||
addStatus = AddServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Shadowsocks)
|
||||
{
|
||||
addStatus = AddShadowsocksServer(ref config, profileItem, false);
|
||||
addStatus = AddShadowsocksServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Socks)
|
||||
{
|
||||
addStatus = AddSocksServer(ref config, profileItem, false);
|
||||
addStatus = AddSocksServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Trojan)
|
||||
{
|
||||
addStatus = AddTrojanServer(ref config, profileItem, false);
|
||||
addStatus = AddTrojanServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.VLESS)
|
||||
{
|
||||
addStatus = AddVlessServer(ref config, profileItem, false);
|
||||
addStatus = AddVlessServer(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Hysteria2)
|
||||
{
|
||||
addStatus = AddHysteria2Server(ref config, profileItem, false);
|
||||
addStatus = AddHysteria2Server(config, profileItem, false);
|
||||
}
|
||||
else if (profileItem.configType == EConfigType.Tuic)
|
||||
{
|
||||
addStatus = AddTuicServer(ref config, profileItem, false);
|
||||
addStatus = AddTuicServer(config, profileItem, false);
|
||||
}
|
||||
|
||||
if (addStatus == 0)
|
||||
|
@ -1144,7 +1144,7 @@ namespace v2rayN.Handler
|
|||
return countServers;
|
||||
}
|
||||
|
||||
private static int AddBatchServers4Custom(ref Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
private static int AddBatchServers4Custom(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
{
|
||||
|
@ -1217,7 +1217,7 @@ namespace v2rayN.Handler
|
|||
|
||||
if (isSub && !Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
RemoveServerViaSubid(ref config, subid, isSub);
|
||||
RemoveServerViaSubid(config, subid, isSub);
|
||||
}
|
||||
if (isSub && lstOriSub?.Count == 1)
|
||||
{
|
||||
|
@ -1231,7 +1231,7 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (AddCustomServer(ref config, profileItem, true) == 0)
|
||||
if (AddCustomServer(config, profileItem, true) == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -1241,7 +1241,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
|
||||
private static int AddBatchServers4SsSIP008(ref Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
private static int AddBatchServers4SsSIP008(Config config, string clipboardData, string subid, bool isSub, List<ProfileItem> lstOriSub)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(clipboardData))
|
||||
{
|
||||
|
@ -1250,7 +1250,7 @@ namespace v2rayN.Handler
|
|||
|
||||
if (isSub && !Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
RemoveServerViaSubid(ref config, subid, isSub);
|
||||
RemoveServerViaSubid(config, subid, isSub);
|
||||
}
|
||||
|
||||
//SsSIP008
|
||||
|
@ -1280,7 +1280,7 @@ namespace v2rayN.Handler
|
|||
};
|
||||
ssItem.subid = subid;
|
||||
ssItem.isSub = isSub;
|
||||
if (AddShadowsocksServer(ref config, ssItem) == 0)
|
||||
if (AddShadowsocksServer(config, ssItem) == 0)
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
|
@ -1292,7 +1292,7 @@ namespace v2rayN.Handler
|
|||
return -1;
|
||||
}
|
||||
|
||||
public static int AddBatchServers(ref Config config, string clipboardData, string subid, bool isSub)
|
||||
public static int AddBatchServers(Config config, string clipboardData, string subid, bool isSub)
|
||||
{
|
||||
List<ProfileItem>? lstOriSub = null;
|
||||
if (isSub && !Utils.IsNullOrEmpty(subid))
|
||||
|
@ -1303,26 +1303,26 @@ namespace v2rayN.Handler
|
|||
var counter = 0;
|
||||
if (Utils.IsBase64String(clipboardData))
|
||||
{
|
||||
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers(config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
|
||||
}
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers(ref config, clipboardData, subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers(config, clipboardData, subid, isSub, lstOriSub);
|
||||
}
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers(ref config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers(config, Utils.Base64Decode(clipboardData), subid, isSub, lstOriSub);
|
||||
}
|
||||
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers4SsSIP008(ref config, clipboardData, subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers4SsSIP008(config, clipboardData, subid, isSub, lstOriSub);
|
||||
}
|
||||
|
||||
//maybe other sub
|
||||
if (counter < 1)
|
||||
{
|
||||
counter = AddBatchServers4Custom(ref config, clipboardData, subid, isSub, lstOriSub);
|
||||
counter = AddBatchServers4Custom(config, clipboardData, subid, isSub, lstOriSub);
|
||||
}
|
||||
|
||||
return counter;
|
||||
|
@ -1338,7 +1338,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public static int AddSubItem(ref Config config, string url)
|
||||
public static int AddSubItem(Config config, string url)
|
||||
{
|
||||
//already exists
|
||||
if (SqliteHelper.Instance.Table<SubItem>().Where(e => e.url == url).Count() > 0)
|
||||
|
@ -1353,10 +1353,10 @@ namespace v2rayN.Handler
|
|||
url = url
|
||||
};
|
||||
|
||||
return AddSubItem(ref config, subItem);
|
||||
return AddSubItem(config, subItem);
|
||||
}
|
||||
|
||||
public static int AddSubItem(ref Config config, SubItem subItem)
|
||||
public static int AddSubItem(Config config, SubItem subItem)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(subItem.id))
|
||||
{
|
||||
|
@ -1388,7 +1388,7 @@ namespace v2rayN.Handler
|
|||
/// <param name="config"></param>
|
||||
/// <param name="subid"></param>
|
||||
/// <returns></returns>
|
||||
public static int RemoveServerViaSubid(ref Config config, string subid, bool isSub)
|
||||
public static int RemoveServerViaSubid(Config config, string subid, bool isSub)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(subid))
|
||||
{
|
||||
|
@ -1411,7 +1411,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static int DeleteSubItem(ref Config config, string id)
|
||||
public static int DeleteSubItem(Config config, string id)
|
||||
{
|
||||
var item = LazyConfig.Instance.GetSubItem(id);
|
||||
if (item is null)
|
||||
|
@ -1419,7 +1419,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
SqliteHelper.Instance.Delete(item);
|
||||
RemoveServerViaSubid(ref config, id, false);
|
||||
RemoveServerViaSubid(config, id, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1439,7 +1439,7 @@ namespace v2rayN.Handler
|
|||
|
||||
#region Routing
|
||||
|
||||
public static int SaveRoutingItem(ref Config config, RoutingItem item)
|
||||
public static int SaveRoutingItem(Config config, RoutingItem item)
|
||||
{
|
||||
if (Utils.IsNullOrEmpty(item.id))
|
||||
{
|
||||
|
@ -1574,7 +1574,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static int SetDefaultRouting(ref Config config, RoutingItem routingItem)
|
||||
public static int SetDefaultRouting(Config config, RoutingItem routingItem)
|
||||
{
|
||||
if (SqliteHelper.Instance.Table<RoutingItem>().Where(t => t.id == routingItem.id).Count() > 0)
|
||||
{
|
||||
|
@ -1586,20 +1586,20 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static RoutingItem GetDefaultRouting(ref Config config)
|
||||
public static RoutingItem GetDefaultRouting(Config config)
|
||||
{
|
||||
var item = LazyConfig.Instance.GetRoutingItem(config.routingBasicItem.routingIndexId);
|
||||
if (item is null)
|
||||
{
|
||||
var item2 = SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(t => t.locked == false);
|
||||
SetDefaultRouting(ref config, item2);
|
||||
SetDefaultRouting(config, item2);
|
||||
return item2;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static int InitBuiltinRouting(ref Config config, bool blImportAdvancedRules = false)
|
||||
public static int InitBuiltinRouting(Config config, bool blImportAdvancedRules = false)
|
||||
{
|
||||
var items = LazyConfig.Instance.RoutingItems();
|
||||
if (blImportAdvancedRules || items.Count <= 0)
|
||||
|
@ -1634,11 +1634,11 @@ namespace v2rayN.Handler
|
|||
|
||||
if (!blImportAdvancedRules)
|
||||
{
|
||||
SetDefaultRouting(ref config, item2);
|
||||
SetDefaultRouting(config, item2);
|
||||
}
|
||||
}
|
||||
|
||||
if (GetLockedRoutingItem(ref config) == null)
|
||||
if (GetLockedRoutingItem(config) == null)
|
||||
{
|
||||
var item1 = new RoutingItem()
|
||||
{
|
||||
|
@ -1651,7 +1651,7 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static RoutingItem GetLockedRoutingItem(ref Config config)
|
||||
public static RoutingItem GetLockedRoutingItem(Config config)
|
||||
{
|
||||
return SqliteHelper.Instance.Table<RoutingItem>().FirstOrDefault(it => it.locked == true);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace v2rayN.Handler
|
|||
|
||||
if (_config.routingBasicItem.enableRoutingAdvanced)
|
||||
{
|
||||
var routing = ConfigHandler.GetDefaultRouting(ref _config);
|
||||
var routing = ConfigHandler.GetDefaultRouting(_config);
|
||||
if (!Utils.IsNullOrEmpty(routing.domainStrategy4Singbox))
|
||||
{
|
||||
inbound.domain_strategy = routing.domainStrategy4Singbox;
|
||||
|
@ -475,7 +475,7 @@ namespace v2rayN.Handler
|
|||
|
||||
if (_config.routingBasicItem.enableRoutingAdvanced)
|
||||
{
|
||||
var routing = ConfigHandler.GetDefaultRouting(ref _config);
|
||||
var routing = ConfigHandler.GetDefaultRouting(_config);
|
||||
if (routing != null)
|
||||
{
|
||||
var rules = Utils.FromJson<List<RulesItem>>(routing.ruleSet);
|
||||
|
@ -490,7 +490,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
else
|
||||
{
|
||||
var lockedItem = ConfigHandler.GetLockedRoutingItem(ref _config);
|
||||
var lockedItem = ConfigHandler.GetLockedRoutingItem(_config);
|
||||
if (lockedItem != null)
|
||||
{
|
||||
var rules = Utils.FromJson<List<RulesItem>>(lockedItem.ruleSet);
|
||||
|
|
|
@ -177,7 +177,7 @@ namespace v2rayN.Handler
|
|||
|
||||
if (_config.routingBasicItem.enableRoutingAdvanced)
|
||||
{
|
||||
var routing = ConfigHandler.GetDefaultRouting(ref _config);
|
||||
var routing = ConfigHandler.GetDefaultRouting(_config);
|
||||
if (routing != null)
|
||||
{
|
||||
if (!Utils.IsNullOrEmpty(routing.domainStrategy))
|
||||
|
@ -197,7 +197,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
else
|
||||
{
|
||||
var lockedItem = ConfigHandler.GetLockedRoutingItem(ref _config);
|
||||
var lockedItem = ConfigHandler.GetLockedRoutingItem(_config);
|
||||
if (lockedItem != null)
|
||||
{
|
||||
var rules = Utils.FromJson<List<RulesItem>>(lockedItem.ruleSet);
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace v2rayN.Handler
|
|||
|
||||
public void LoadCore()
|
||||
{
|
||||
var node = ConfigHandler.GetDefaultServer(ref _config);
|
||||
var node = ConfigHandler.GetDefaultServer(_config);
|
||||
if (node == null)
|
||||
{
|
||||
ShowMsg(false, ResUI.CheckServerSettings);
|
||||
|
|
|
@ -320,7 +320,6 @@ namespace v2rayN.Handler
|
|||
redirectInfo = true,
|
||||
});
|
||||
|
||||
|
||||
coreInfos.Add(new CoreInfo
|
||||
{
|
||||
coreType = ECoreType.hysteria,
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace v2rayN.Handler
|
|||
return null;
|
||||
}
|
||||
|
||||
var item = ConfigHandler.GetDefaultRouting(ref config);
|
||||
var item = ConfigHandler.GetDefaultRouting(config);
|
||||
if (item == null || Utils.IsNullOrEmpty(item.customIcon) || !File.Exists(item.customIcon))
|
||||
{
|
||||
return null;
|
||||
|
@ -183,7 +183,7 @@ namespace v2rayN.Handler
|
|||
Utils.SaveLog("subscription" + msg);
|
||||
});
|
||||
item.updateTime = updateTime;
|
||||
ConfigHandler.AddSubItem(ref config, item);
|
||||
ConfigHandler.AddSubItem(config, item);
|
||||
|
||||
await Task.Delay(5000);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
}
|
||||
|
||||
private void AddProfileEx(string indexId, ref ProfileExItem profileEx)
|
||||
private void AddProfileEx(string indexId, ref ProfileExItem? profileEx)
|
||||
{
|
||||
profileEx = new()
|
||||
{
|
||||
|
|
|
@ -271,7 +271,7 @@ namespace v2rayN.Handler
|
|||
_updateFunc(false, $"{hashCode}{result}");
|
||||
}
|
||||
|
||||
int ret = ConfigHandler.AddBatchServers(ref config, result, id, true);
|
||||
int ret = ConfigHandler.AddBatchServers(config, result, id, true);
|
||||
if (ret <= 0)
|
||||
{
|
||||
Utils.SaveLog("FailedImportSubscription");
|
||||
|
|
|
@ -451,6 +451,11 @@ namespace v2rayN.Mode
|
|||
/// grpc
|
||||
/// </summary>
|
||||
public GrpcSettings4Ray grpcSettings { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// sockopt
|
||||
/// </summary>
|
||||
public Sockopt4Ray? sockopt { get; set; }
|
||||
}
|
||||
|
||||
public class TlsSettings4Ray
|
||||
|
@ -632,4 +637,9 @@ namespace v2rayN.Mode
|
|||
/// </summary>
|
||||
public string pass { get; set; }
|
||||
}
|
||||
|
||||
public class Sockopt4Ray
|
||||
{
|
||||
public string? dialerProxy { get; set; }
|
||||
}
|
||||
}
|
|
@ -90,7 +90,7 @@ namespace v2rayN.ViewModels
|
|||
item.preSocksPort = SelectedSource.preSocksPort;
|
||||
}
|
||||
|
||||
if (ConfigHandler.EditCustomServer(ref _config, item) == 0)
|
||||
if (ConfigHandler.EditCustomServer(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
|
@ -122,7 +122,7 @@ namespace v2rayN.ViewModels
|
|||
var item = LazyConfig.Instance.GetProfileItem(SelectedSource.indexId);
|
||||
item ??= SelectedSource;
|
||||
item.address = fileName;
|
||||
if (ConfigHandler.AddCustomServer(ref _config, item, false) == 0)
|
||||
if (ConfigHandler.AddCustomServer(_config, item, false) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.SuccessfullyImportedCustomServer);
|
||||
if (!Utils.IsNullOrEmpty(item.indexId))
|
||||
|
|
|
@ -127,31 +127,31 @@ namespace v2rayN.ViewModels
|
|||
switch (item.configType)
|
||||
{
|
||||
case EConfigType.VMess:
|
||||
ret = ConfigHandler.AddServer(ref _config, item);
|
||||
ret = ConfigHandler.AddServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Shadowsocks:
|
||||
ret = ConfigHandler.AddShadowsocksServer(ref _config, item);
|
||||
ret = ConfigHandler.AddShadowsocksServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Socks:
|
||||
ret = ConfigHandler.AddSocksServer(ref _config, item);
|
||||
ret = ConfigHandler.AddSocksServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.VLESS:
|
||||
ret = ConfigHandler.AddVlessServer(ref _config, item);
|
||||
ret = ConfigHandler.AddVlessServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Trojan:
|
||||
ret = ConfigHandler.AddTrojanServer(ref _config, item);
|
||||
ret = ConfigHandler.AddTrojanServer(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Hysteria2:
|
||||
ret = ConfigHandler.AddHysteria2Server(ref _config, item);
|
||||
ret = ConfigHandler.AddHysteria2Server(_config, item);
|
||||
break;
|
||||
|
||||
case EConfigType.Tuic:
|
||||
ret = ConfigHandler.AddTuicServer(ref _config, item);
|
||||
ret = ConfigHandler.AddTuicServer(_config, item);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -571,7 +571,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
private void Init()
|
||||
{
|
||||
ConfigHandler.InitBuiltinRouting(ref _config);
|
||||
ConfigHandler.InitBuiltinRouting(_config);
|
||||
ConfigHandler.InitBuiltinDNS(_config);
|
||||
_coreHandler = new CoreHandler(_config, UpdateHandler);
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => _coreHandler, typeof(CoreHandler));
|
||||
|
@ -737,7 +737,7 @@ namespace v2rayN.ViewModels
|
|||
Utils.SaveLog("MyAppExit Begin");
|
||||
|
||||
StorageUI();
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
|
||||
//HttpProxyHandle.CloseHttpAgent(config);
|
||||
if (blWindowsShutDown)
|
||||
|
@ -857,7 +857,7 @@ namespace v2rayN.ViewModels
|
|||
RefreshServersMenu();
|
||||
|
||||
//display running server
|
||||
var running = ConfigHandler.GetDefaultServer(ref _config);
|
||||
var running = ConfigHandler.GetDefaultServer(_config);
|
||||
if (running != null)
|
||||
{
|
||||
var runningSummary = running.GetSummary();
|
||||
|
@ -995,7 +995,7 @@ namespace v2rayN.ViewModels
|
|||
public void AddServerViaClipboard()
|
||||
{
|
||||
var clipboardData = Utils.GetClipboardData();
|
||||
int ret = ConfigHandler.AddBatchServers(ref _config, clipboardData!, _subId, false);
|
||||
int ret = ConfigHandler.AddBatchServers(_config, clipboardData!, _subId, false);
|
||||
if (ret > 0)
|
||||
{
|
||||
InitSubscriptionView();
|
||||
|
@ -1022,7 +1022,7 @@ namespace v2rayN.ViewModels
|
|||
}
|
||||
else
|
||||
{
|
||||
int ret = ConfigHandler.AddBatchServers(ref _config, result, _subId, false);
|
||||
int ret = ConfigHandler.AddBatchServers(_config, result, _subId, false);
|
||||
if (ret > 0)
|
||||
{
|
||||
InitSubscriptionView();
|
||||
|
@ -1069,7 +1069,7 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.CopyServer(ref _config, lstSelecteds) == 0)
|
||||
if (ConfigHandler.CopyServer(_config, lstSelecteds) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
|
@ -1102,7 +1102,7 @@ namespace v2rayN.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.SetDefaultServerIndex(ref _config, indexId) == 0)
|
||||
if (ConfigHandler.SetDefaultServerIndex(_config, indexId) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
Reload();
|
||||
|
@ -1158,7 +1158,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
_dicHeaderSort.TryAdd(colName, true);
|
||||
_dicHeaderSort.TryGetValue(colName, out bool asc);
|
||||
if (ConfigHandler.SortServers(ref _config, _subId, colName, asc) != 0)
|
||||
if (ConfigHandler.SortServers(_config, _subId, colName, asc) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1168,7 +1168,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
public void TestServerAvailability()
|
||||
{
|
||||
var item = ConfigHandler.GetDefaultServer(ref _config);
|
||||
var item = ConfigHandler.GetDefaultServer(_config);
|
||||
if (item == null || item.configType == EConfigType.Custom)
|
||||
{
|
||||
return;
|
||||
|
@ -1222,7 +1222,7 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (ConfigHandler.MoveServer(ref _config, ref _lstProfile, index, eMove) == 0)
|
||||
if (ConfigHandler.MoveServer(_config, ref _lstProfile, index, eMove) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
}
|
||||
|
@ -1233,7 +1233,7 @@ namespace v2rayN.ViewModels
|
|||
var targetIndex = _profileItems.IndexOf(targetItem);
|
||||
if (startIndex >= 0 && targetIndex >= 0 && startIndex != targetIndex)
|
||||
{
|
||||
if (ConfigHandler.MoveServer(ref _config, ref _lstProfile, startIndex, EMove.Position, targetIndex) == 0)
|
||||
if (ConfigHandler.MoveServer(_config, ref _lstProfile, startIndex, EMove.Position, targetIndex) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
}
|
||||
|
@ -1363,7 +1363,7 @@ namespace v2rayN.ViewModels
|
|||
var ret = (new RoutingSettingWindow()).ShowDialog();
|
||||
if (ret == true)
|
||||
{
|
||||
ConfigHandler.InitBuiltinRouting(ref _config);
|
||||
ConfigHandler.InitBuiltinRouting(_config);
|
||||
RefreshRoutingsMenu();
|
||||
//RefreshServers();
|
||||
Reload();
|
||||
|
@ -1414,7 +1414,7 @@ namespace v2rayN.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
var ret = ConfigHandler.ImportOldGuiConfig(ref _config, fileName);
|
||||
var ret = ConfigHandler.ImportOldGuiConfig(_config, fileName);
|
||||
if (ret == 0)
|
||||
{
|
||||
RefreshRoutingsMenu();
|
||||
|
@ -1500,7 +1500,7 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
_coreHandler.LoadCore();
|
||||
|
||||
//ConfigHandler.SaveConfig(ref _config, false);
|
||||
//ConfigHandler.SaveConfig(_config, false);
|
||||
|
||||
ChangeSystemProxyStatus(_config.sysProxyType, false);
|
||||
});
|
||||
|
@ -1515,7 +1515,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
private void CloseV2ray()
|
||||
{
|
||||
ConfigHandler.SaveConfig(ref _config, false);
|
||||
ConfigHandler.SaveConfig(_config, false);
|
||||
|
||||
ChangeSystemProxyStatus(ESysProxyType.ForcedClear, false);
|
||||
|
||||
|
@ -1536,7 +1536,7 @@ namespace v2rayN.ViewModels
|
|||
ChangeSystemProxyStatus(type, true);
|
||||
|
||||
SystemProxySelected = (int)_config.sysProxyType;
|
||||
ConfigHandler.SaveConfig(ref _config, false);
|
||||
ConfigHandler.SaveConfig(_config, false);
|
||||
}
|
||||
|
||||
private void ChangeSystemProxyStatus(ESysProxyType type, bool blChange)
|
||||
|
@ -1604,7 +1604,7 @@ namespace v2rayN.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.SetDefaultRouting(ref _config, item) == 0)
|
||||
if (ConfigHandler.SetDefaultRouting(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.SendMessage(ResUI.TipChangeRouting, true);
|
||||
Reload();
|
||||
|
@ -1710,7 +1710,7 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
_config.uiItem.colorModeDark = ColorModeDark;
|
||||
ModifyTheme(ColorModeDark);
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1721,7 +1721,7 @@ namespace v2rayN.ViewModels
|
|||
if (_config.uiItem.followSystemTheme != FollowSystemTheme)
|
||||
{
|
||||
_config.uiItem.followSystemTheme = FollowSystemTheme;
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
if (FollowSystemTheme)
|
||||
{
|
||||
ModifyTheme(!Utils.IsLightTheme());
|
||||
|
@ -1745,7 +1745,7 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
_config.uiItem.colorPrimaryName = SelectedSwatch?.Name;
|
||||
ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color);
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1763,7 +1763,7 @@ namespace v2rayN.ViewModels
|
|||
Application.Current.Resources["StdFontSize2"] = size + 2;
|
||||
Application.Current.Resources["StdFontSizeMsg"] = size - 1;
|
||||
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1776,7 +1776,7 @@ namespace v2rayN.ViewModels
|
|||
{
|
||||
_config.uiItem.currentLanguage = CurrentLanguage;
|
||||
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
|
||||
ConfigHandler.SaveConfig(ref _config);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ namespace v2rayN.ViewModels
|
|||
//coreType
|
||||
SaveCoreType();
|
||||
|
||||
if (ConfigHandler.SaveConfig(ref _config) == 0)
|
||||
if (ConfigHandler.SaveConfig(_config) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
|
|
|
@ -250,7 +250,7 @@ namespace v2rayN.ViewModels
|
|||
item.ruleNum = _rules.Count;
|
||||
item.ruleSet = Utils.ToJson(_rules, false);
|
||||
|
||||
if (ConfigHandler.SaveRoutingItem(ref _config, item) == 0)
|
||||
if (ConfigHandler.SaveRoutingItem(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
|
|
|
@ -81,7 +81,7 @@ namespace v2rayN.ViewModels
|
|||
_view = view;
|
||||
SelectedSource = new();
|
||||
|
||||
ConfigHandler.InitBuiltinRouting(ref _config);
|
||||
ConfigHandler.InitBuiltinRouting(_config);
|
||||
|
||||
enableRoutingAdvanced = _config.routingBasicItem.enableRoutingAdvanced;
|
||||
domainStrategy = _config.routingBasicItem.domainStrategy;
|
||||
|
@ -134,7 +134,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
private void BindingLockedData()
|
||||
{
|
||||
_lockedItem = ConfigHandler.GetLockedRoutingItem(ref _config);
|
||||
_lockedItem = ConfigHandler.GetLockedRoutingItem(_config);
|
||||
if (_lockedItem != null)
|
||||
{
|
||||
_lockedRules = Utils.FromJson<List<RulesItem>>(_lockedItem.ruleSet);
|
||||
|
@ -164,7 +164,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
_lockedItem.ruleSet = Utils.ToJson(_lockedRules, false);
|
||||
|
||||
ConfigHandler.SaveRoutingItem(ref _config, _lockedItem);
|
||||
ConfigHandler.SaveRoutingItem(_config, _lockedItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
EndBindingLockedData();
|
||||
|
||||
if (ConfigHandler.SaveConfig(ref _config) == 0)
|
||||
if (ConfigHandler.SaveConfig(_config) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
|
@ -289,7 +289,7 @@ namespace v2rayN.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.SetDefaultRouting(ref _config, item) == 0)
|
||||
if (ConfigHandler.SetDefaultRouting(_config, item) == 0)
|
||||
{
|
||||
RefreshRoutingItems();
|
||||
IsModified = true;
|
||||
|
@ -298,7 +298,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
private void RoutingAdvancedImportRules()
|
||||
{
|
||||
if (ConfigHandler.InitBuiltinRouting(ref _config, true) == 0)
|
||||
if (ConfigHandler.InitBuiltinRouting(_config, true) == 0)
|
||||
{
|
||||
RefreshRoutingItems();
|
||||
IsModified = true;
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace v2rayN.ViewModels
|
|||
item.convertTarget = SelectedSource.convertTarget;
|
||||
}
|
||||
|
||||
if (ConfigHandler.AddSubItem(ref _config, item) == 0)
|
||||
if (ConfigHandler.AddSubItem(_config, item) == 0)
|
||||
{
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
_view.DialogResult = true;
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace v2rayN.ViewModels
|
|||
|
||||
foreach (var it in SelectedSources)
|
||||
{
|
||||
ConfigHandler.DeleteSubItem(ref _config, it?.id);
|
||||
ConfigHandler.DeleteSubItem(_config, it?.id);
|
||||
}
|
||||
RefreshSubItems();
|
||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||
|
|
|
@ -112,7 +112,7 @@ namespace v2rayN.Views
|
|||
{
|
||||
_config.globalHotkeys = _TextBoxKeyEventItem.Values.ToList();
|
||||
|
||||
if (ConfigHandler.SaveConfig(ref _config, false) == 0)
|
||||
if (ConfigHandler.SaveConfig(_config, false) == 0)
|
||||
{
|
||||
HotkeyHandler.Instance.ReLoad();
|
||||
this.DialogResult = true;
|
||||
|
|
Loading…
Reference in New Issue