The first letter of the guiconfig attribute must be capitalized.

This commit is contained in:
2dust 2024-10-23 10:42:35 +08:00
parent 1e7284f141
commit 2d143687b8
51 changed files with 694 additions and 705 deletions

View file

@ -31,7 +31,11 @@ namespace ServiceLib.Common
{ {
return default; return default;
} }
return JsonSerializer.Deserialize<T>(strJson); var options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
return JsonSerializer.Deserialize<T>(strJson, options);
} }
catch catch
{ {

View file

@ -51,7 +51,7 @@
{ {
return false; return false;
} }
Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage); Thread.CurrentThread.CurrentUICulture = new(_config.UiItem.CurrentLanguage);
//Under Win10 //Under Win10
if (Utils.IsWindows() && Environment.OSVersion.Version.Major < 10) if (Utils.IsWindows() && Environment.OSVersion.Version.Major < 10)
@ -85,7 +85,7 @@
public int GetLocalPort(EInboundProtocol protocol) public int GetLocalPort(EInboundProtocol protocol)
{ {
var localPort = _config.inbound.FirstOrDefault(t => t.protocol == nameof(EInboundProtocol.socks))?.localPort ?? 10808; var localPort = _config.Inbound.FirstOrDefault(t => t.Protocol == nameof(EInboundProtocol.socks))?.LocalPort ?? 10808;
return localPort + (int)protocol; return localPort + (int)protocol;
} }
@ -165,11 +165,11 @@
public async Task<List<ProfileItemModel>> ProfileItemsEx(string subid, string filter) public async Task<List<ProfileItemModel>> ProfileItemsEx(string subid, string filter)
{ {
var lstModel = await ProfileItems(_config.subIndexId, filter); var lstModel = await ProfileItems(_config.SubIndexId, filter);
await ConfigHandler.SetDefaultServer(_config, lstModel); await ConfigHandler.SetDefaultServer(_config, lstModel);
var lstServerStat = (_config.guiItem.enableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? []; var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? [];
var lstProfileExs = ProfileExHandler.Instance.ProfileExs; var lstProfileExs = ProfileExHandler.Instance.ProfileExs;
lstModel = (from t in lstModel lstModel = (from t in lstModel
join t2 in lstServerStat on t.indexId equals t2.indexId into t2b join t2 in lstServerStat on t.indexId equals t2.indexId into t2b
@ -188,7 +188,7 @@
streamSecurity = t.streamSecurity, streamSecurity = t.streamSecurity,
subid = t.subid, subid = t.subid,
subRemarks = t.subRemarks, subRemarks = t.subRemarks,
isActive = t.indexId == _config.indexId, isActive = t.indexId == _config.IndexId,
sort = t33 == null ? 0 : t33.sort, sort = t33 == null ? 0 : t33.sort,
delay = t33 == null ? 0 : t33.delay, delay = t33 == null ? 0 : t33.delay,
delayVal = t33?.delay != 0 ? $"{t33?.delay} {Global.DelayUnit}" : string.Empty, delayVal = t33?.delay != 0 ? $"{t33?.delay} {Global.DelayUnit}" : string.Empty,
@ -268,16 +268,16 @@
return (ECoreType)profileItem.coreType; return (ECoreType)profileItem.coreType;
} }
if (_config.coreTypeItem == null) if (_config.CoreTypeItem == null)
{ {
return ECoreType.Xray; return ECoreType.Xray;
} }
var item = _config.coreTypeItem.FirstOrDefault(it => it.configType == eConfigType); var item = _config.CoreTypeItem.FirstOrDefault(it => it.ConfigType == eConfigType);
if (item == null) if (item == null)
{ {
return ECoreType.Xray; return ECoreType.Xray;
} }
return item.coreType; return item.CoreType;
} }
#endregion Core Type #endregion Core Type

View file

@ -72,7 +72,7 @@ namespace ServiceLib.Handler
return; return;
} }
var urlBase = $"{GetApiUrl()}/proxies"; var urlBase = $"{GetApiUrl()}/proxies";
urlBase += @"/{0}/delay?timeout=10000&url=" + AppHandler.Instance.Config.speedTestItem.speedPingTestUrl; urlBase += @"/{0}/delay?timeout=10000&url=" + AppHandler.Instance.Config.SpeedTestItem.SpeedPingTestUrl;
List<Task> tasks = new List<Task>(); List<Task> tasks = new List<Task>();
foreach (var it in lstProxy) foreach (var it in lstProxy)

View file

@ -37,133 +37,133 @@ namespace ServiceLib.Handler
config ??= new Config(); config ??= new Config();
config.coreBasicItem ??= new() config.CoreBasicItem ??= new()
{ {
logEnabled = false, LogEnabled = false,
loglevel = "warning", Loglevel = "warning",
muxEnabled = false, MuxEnabled = false,
}; };
if (config.inbound == null) if (config.Inbound == null)
{ {
config.inbound = new List<InItem>(); config.Inbound = new List<InItem>();
InItem inItem = new() InItem inItem = new()
{ {
protocol = EInboundProtocol.socks.ToString(), Protocol = EInboundProtocol.socks.ToString(),
localPort = 10808, LocalPort = 10808,
udpEnabled = true, UdpEnabled = true,
sniffingEnabled = true, SniffingEnabled = true,
routeOnly = false, RouteOnly = false,
}; };
config.inbound.Add(inItem); config.Inbound.Add(inItem);
} }
else else
{ {
if (config.inbound.Count > 0) if (config.Inbound.Count > 0)
{ {
config.inbound[0].protocol = EInboundProtocol.socks.ToString(); config.Inbound[0].Protocol = EInboundProtocol.socks.ToString();
} }
} }
config.routingBasicItem ??= new() config.RoutingBasicItem ??= new()
{ {
enableRoutingAdvanced = true EnableRoutingAdvanced = true
}; };
if (Utils.IsNullOrEmpty(config.routingBasicItem.domainStrategy)) if (Utils.IsNullOrEmpty(config.RoutingBasicItem.DomainStrategy))
{ {
config.routingBasicItem.domainStrategy = Global.DomainStrategies[0];//"IPIfNonMatch"; config.RoutingBasicItem.DomainStrategy = Global.DomainStrategies[0];//"IPIfNonMatch";
} }
config.kcpItem ??= new KcpItem config.KcpItem ??= new KcpItem
{ {
mtu = 1350, Mtu = 1350,
tti = 50, Tti = 50,
uplinkCapacity = 12, UplinkCapacity = 12,
downlinkCapacity = 100, DownlinkCapacity = 100,
readBufferSize = 2, ReadBufferSize = 2,
writeBufferSize = 2, WriteBufferSize = 2,
congestion = false Congestion = false
}; };
config.grpcItem ??= new GrpcItem config.GrpcItem ??= new GrpcItem
{ {
idle_timeout = 60, IdleTimeout = 60,
health_check_timeout = 20, HealthCheckTimeout = 20,
permit_without_stream = false, PermitWithoutStream = false,
initial_windows_size = 0, InitialWindowsSize = 0,
}; };
config.tunModeItem ??= new TunModeItem config.TunModeItem ??= new TunModeItem
{ {
enableTun = false, EnableTun = false,
mtu = 9000, Mtu = 9000,
}; };
config.guiItem ??= new() config.GuiItem ??= new()
{ {
enableStatistics = false, EnableStatistics = false,
}; };
config.msgUIItem ??= new(); config.MsgUIItem ??= new();
config.uiItem ??= new UIItem() config.UiItem ??= new UIItem()
{ {
enableAutoAdjustMainLvColWidth = true EnableAutoAdjustMainLvColWidth = true
}; };
if (config.uiItem.mainColumnItem == null) if (config.UiItem.MainColumnItem == null)
{ {
config.uiItem.mainColumnItem = new(); config.UiItem.MainColumnItem = new();
} }
if (Utils.IsNullOrEmpty(config.uiItem.currentLanguage)) if (Utils.IsNullOrEmpty(config.UiItem.CurrentLanguage))
{ {
if (Thread.CurrentThread.CurrentCulture.Name.Equals("zh-cn", StringComparison.CurrentCultureIgnoreCase)) if (Thread.CurrentThread.CurrentCulture.Name.Equals("zh-cn", StringComparison.CurrentCultureIgnoreCase))
{ {
config.uiItem.currentLanguage = Global.Languages[0]; config.UiItem.CurrentLanguage = Global.Languages[0];
} }
else else
{ {
config.uiItem.currentLanguage = Global.Languages[2]; config.UiItem.CurrentLanguage = Global.Languages[2];
} }
} }
config.constItem ??= new ConstItem(); config.ConstItem ??= new ConstItem();
if (Utils.IsNullOrEmpty(config.constItem.defIEProxyExceptions)) if (Utils.IsNullOrEmpty(config.ConstItem.DefIEProxyExceptions))
{ {
config.constItem.defIEProxyExceptions = Global.IEProxyExceptions; config.ConstItem.DefIEProxyExceptions = Global.IEProxyExceptions;
} }
config.speedTestItem ??= new(); config.SpeedTestItem ??= new();
if (config.speedTestItem.speedTestTimeout < 10) if (config.SpeedTestItem.SpeedTestTimeout < 10)
{ {
config.speedTestItem.speedTestTimeout = 10; config.SpeedTestItem.SpeedTestTimeout = 10;
} }
if (Utils.IsNullOrEmpty(config.speedTestItem.speedTestUrl)) if (Utils.IsNullOrEmpty(config.SpeedTestItem.SpeedTestUrl))
{ {
config.speedTestItem.speedTestUrl = Global.SpeedTestUrls[0]; config.SpeedTestItem.SpeedTestUrl = Global.SpeedTestUrls[0];
} }
if (Utils.IsNullOrEmpty(config.speedTestItem.speedPingTestUrl)) if (Utils.IsNullOrEmpty(config.SpeedTestItem.SpeedPingTestUrl))
{ {
config.speedTestItem.speedPingTestUrl = Global.SpeedPingTestUrl; config.SpeedTestItem.SpeedPingTestUrl = Global.SpeedPingTestUrl;
} }
config.mux4RayItem ??= new() config.Mux4RayItem ??= new()
{ {
concurrency = 8, Concurrency = 8,
xudpConcurrency = 16, XudpConcurrency = 16,
xudpProxyUDP443 = "reject" XudpProxyUDP443 = "reject"
}; };
config.mux4SboxItem ??= new() config.Mux4SboxItem ??= new()
{ {
protocol = Global.SingboxMuxs[0], Protocol = Global.SingboxMuxs[0],
max_connections = 8 MaxConnections = 8
}; };
config.hysteriaItem ??= new() config.HysteriaItem ??= new()
{ {
up_mbps = 100, UpMbps = 100,
down_mbps = 100 DownMbps = 100
}; };
config.clashUIItem ??= new(); config.ClashUIItem ??= new();
config.systemProxyItem ??= new(); config.SystemProxyItem ??= new();
config.webDavItem ??= new(); config.WebDavItem ??= new();
return config; return config;
} }
@ -369,7 +369,7 @@ namespace ServiceLib.Handler
return -1; return -1;
} }
config.indexId = indexId; config.IndexId = indexId;
await ToJsonFile(config); await ToJsonFile(config);
@ -378,11 +378,11 @@ namespace ServiceLib.Handler
public static async Task<int> SetDefaultServer(Config config, List<ProfileItemModel> lstProfile) public static async Task<int> SetDefaultServer(Config config, List<ProfileItemModel> lstProfile)
{ {
if (lstProfile.Exists(t => t.indexId == config.indexId)) if (lstProfile.Exists(t => t.indexId == config.IndexId))
{ {
return 0; return 0;
} }
var count = await SQLiteHelper.Instance.TableAsync<ProfileItem>().CountAsync(t => t.indexId == config.indexId); var count = await SQLiteHelper.Instance.TableAsync<ProfileItem>().CountAsync(t => t.indexId == config.IndexId);
if (count > 0) if (count > 0)
{ {
return 0; return 0;
@ -398,7 +398,7 @@ namespace ServiceLib.Handler
public static async Task<ProfileItem?> GetDefaultServer(Config config) public static async Task<ProfileItem?> GetDefaultServer(Config config)
{ {
var item = await AppHandler.Instance.GetProfileItem(config.indexId); var item = await AppHandler.Instance.GetProfileItem(config.IndexId);
if (item is null) if (item is null)
{ {
var item2 = await SQLiteHelper.Instance.TableAsync<ProfileItem>().FirstOrDefaultAsync(); var item2 = await SQLiteHelper.Instance.TableAsync<ProfileItem>().FirstOrDefaultAsync();
@ -887,7 +887,7 @@ namespace ServiceLib.Handler
List<ProfileItem> lstKeep = new(); List<ProfileItem> lstKeep = new();
List<ProfileItem> lstRemove = new(); List<ProfileItem> lstRemove = new();
if (!config.guiItem.keepOlderDedupl) lstProfile.Reverse(); if (!config.GuiItem.KeepOlderDedupl) lstProfile.Reverse();
foreach (ProfileItem item in lstProfile) foreach (ProfileItem item in lstProfile)
{ {
@ -920,11 +920,11 @@ namespace ServiceLib.Handler
{ {
if (Utils.IsNullOrEmpty(profileItem.allowInsecure)) if (Utils.IsNullOrEmpty(profileItem.allowInsecure))
{ {
profileItem.allowInsecure = config.coreBasicItem.defAllowInsecure.ToString().ToLower(); profileItem.allowInsecure = config.CoreBasicItem.DefAllowInsecure.ToString().ToLower();
} }
if (Utils.IsNullOrEmpty(profileItem.fingerprint) && profileItem.streamSecurity == Global.StreamSecurityReality) if (Utils.IsNullOrEmpty(profileItem.fingerprint) && profileItem.streamSecurity == Global.StreamSecurityReality)
{ {
profileItem.fingerprint = config.coreBasicItem.defFingerprint; profileItem.fingerprint = config.CoreBasicItem.DefFingerprint;
} }
} }
} }
@ -1089,7 +1089,7 @@ namespace ServiceLib.Handler
if (isSub && Utils.IsNotEmpty(subid)) if (isSub && Utils.IsNotEmpty(subid))
{ {
var existItem = lstOriSub?.FirstOrDefault(t => t.isSub == isSub var existItem = lstOriSub?.FirstOrDefault(t => t.isSub == isSub
&& config.uiItem.enableUpdateSubOnlyRemarksExist ? t.remarks == profileItem.remarks : CompareProfileItem(t, profileItem, true)); && config.UiItem.EnableUpdateSubOnlyRemarksExist ? t.remarks == profileItem.remarks : CompareProfileItem(t, profileItem, true));
if (existItem != null) if (existItem != null)
{ {
//Check for duplicate indexId //Check for duplicate indexId
@ -1604,7 +1604,7 @@ namespace ServiceLib.Handler
{ {
if (await SQLiteHelper.Instance.TableAsync<RoutingItem>().Where(t => t.id == routingItem.id).CountAsync() > 0) if (await SQLiteHelper.Instance.TableAsync<RoutingItem>().Where(t => t.id == routingItem.id).CountAsync() > 0)
{ {
config.routingBasicItem.routingIndexId = routingItem.id; config.RoutingBasicItem.RoutingIndexId = routingItem.id;
} }
await ToJsonFile(config); await ToJsonFile(config);
@ -1614,7 +1614,7 @@ namespace ServiceLib.Handler
public static async Task<RoutingItem> GetDefaultRouting(Config config) public static async Task<RoutingItem> GetDefaultRouting(Config config)
{ {
var item = await AppHandler.Instance.GetRoutingItem(config.routingBasicItem.routingIndexId); var item = await AppHandler.Instance.GetRoutingItem(config.RoutingBasicItem.RoutingIndexId);
if (item is null) if (item is null)
{ {
var item2 = await SQLiteHelper.Instance.TableAsync<RoutingItem>().FirstOrDefaultAsync(t => t.locked == false); var item2 = await SQLiteHelper.Instance.TableAsync<RoutingItem>().FirstOrDefaultAsync(t => t.locked == false);
@ -1627,7 +1627,7 @@ namespace ServiceLib.Handler
public static async Task<int> InitRouting(Config config, bool blImportAdvancedRules = false) public static async Task<int> InitRouting(Config config, bool blImportAdvancedRules = false)
{ {
if (string.IsNullOrEmpty(config.constItem.routeRulesTemplateSourceUrl)) if (string.IsNullOrEmpty(config.ConstItem.RouteRulesTemplateSourceUrl))
{ {
await InitBuiltinRouting(config, blImportAdvancedRules); await InitBuiltinRouting(config, blImportAdvancedRules);
} }
@ -1642,7 +1642,7 @@ namespace ServiceLib.Handler
public static async Task<int> InitExternalRouting(Config config, bool blImportAdvancedRules = false) public static async Task<int> InitExternalRouting(Config config, bool blImportAdvancedRules = false)
{ {
var downloadHandle = new DownloadService(); var downloadHandle = new DownloadService();
var templateContent = await downloadHandle.TryDownloadString(config.constItem.routeRulesTemplateSourceUrl, true, ""); var templateContent = await downloadHandle.TryDownloadString(config.ConstItem.RouteRulesTemplateSourceUrl, true, "");
if (string.IsNullOrEmpty(templateContent)) if (string.IsNullOrEmpty(templateContent))
return await InitBuiltinRouting(config, blImportAdvancedRules); // fallback return await InitBuiltinRouting(config, blImportAdvancedRules); // fallback
@ -1826,9 +1826,9 @@ namespace ServiceLib.Handler
switch (type) switch (type)
{ {
case EPresetType.Default: case EPresetType.Default:
config.constItem.geoSourceUrl = ""; config.ConstItem.GeoSourceUrl = "";
config.constItem.srsSourceUrl = ""; config.ConstItem.SrsSourceUrl = "";
config.constItem.routeRulesTemplateSourceUrl = ""; config.ConstItem.RouteRulesTemplateSourceUrl = "";
await SQLiteHelper.Instance.DeleteAllAsync<DNSItem>(); await SQLiteHelper.Instance.DeleteAllAsync<DNSItem>();
await InitBuiltinDNS(config); await InitBuiltinDNS(config);
@ -1836,9 +1836,9 @@ namespace ServiceLib.Handler
return true; return true;
case EPresetType.Russia: case EPresetType.Russia:
config.constItem.geoSourceUrl = Global.GeoFilesSources[1]; config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[1];
config.constItem.srsSourceUrl = Global.SingboxRulesetSources[1]; config.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[1];
config.constItem.routeRulesTemplateSourceUrl = Global.RoutingRulesSources[1]; config.ConstItem.RouteRulesTemplateSourceUrl = Global.RoutingRulesSources[1];
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json")); await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.Xray, Global.DNSTemplateSources[1] + "v2ray.json"));
await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json")); await SaveDNSItems(config, await GetExternalDNSItem(ECoreType.sing_box, Global.DNSTemplateSources[1] + "sing_box.json"));

View file

@ -182,7 +182,7 @@ namespace ServiceLib.Handler
// coreType = LazyConfig.Instance.GetCoreType(node, node.configType); // coreType = LazyConfig.Instance.GetCoreType(node, node.configType);
//} //}
var coreType = AppHandler.Instance.GetCoreType(node, node.configType); var coreType = AppHandler.Instance.GetCoreType(node, node.configType);
_config.runningCoreType = coreType; _config.RunningCoreType = coreType;
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType); var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(coreType);
var displayLog = node.configType != EConfigType.Custom || node.displayLog; var displayLog = node.configType != EConfigType.Custom || node.displayLog;
@ -198,7 +198,7 @@ namespace ServiceLib.Handler
{ {
ProfileItem? itemSocks = null; ProfileItem? itemSocks = null;
var preCoreType = ECoreType.sing_box; var preCoreType = ECoreType.sing_box;
if (node.configType != EConfigType.Custom && coreType != ECoreType.sing_box && _config.tunModeItem.enableTun) if (node.configType != EConfigType.Custom && coreType != ECoreType.sing_box && _config.TunModeItem.EnableTun)
{ {
itemSocks = new ProfileItem() itemSocks = new ProfileItem()
{ {
@ -211,7 +211,7 @@ namespace ServiceLib.Handler
} }
else if ((node.configType == EConfigType.Custom && node.preSocksPort > 0)) else if ((node.configType == EConfigType.Custom && node.preSocksPort > 0))
{ {
preCoreType = _config.tunModeItem.enableTun ? ECoreType.sing_box : ECoreType.Xray; preCoreType = _config.TunModeItem.EnableTun ? ECoreType.sing_box : ECoreType.Xray;
itemSocks = new ProfileItem() itemSocks = new ProfileItem()
{ {
coreType = preCoreType, coreType = preCoreType,
@ -219,7 +219,7 @@ namespace ServiceLib.Handler
address = Global.Loopback, address = Global.Loopback,
port = node.preSocksPort.Value, port = node.preSocksPort.Value,
}; };
_config.runningCoreType = preCoreType; _config.RunningCoreType = preCoreType;
} }
if (itemSocks != null) if (itemSocks != null)
{ {

View file

@ -20,7 +20,7 @@ namespace ServiceLib.Handler
private async Task Init() private async Task Init()
{ {
await InitData(); await InitData();
Task.Run(async () => await Task.Run(async () =>
{ {
while (true) while (true)
{ {

View file

@ -18,7 +18,7 @@
{ {
_config = config; _config = config;
_updateFunc = updateFunc; _updateFunc = updateFunc;
if (!config.guiItem.enableStatistics) if (!config.GuiItem.EnableStatistics)
{ {
return; return;
} }
@ -81,7 +81,7 @@
private async Task UpdateServerStat(ServerSpeedItem server) private async Task UpdateServerStat(ServerSpeedItem server)
{ {
await GetServerStatItem(_config.indexId); await GetServerStatItem(_config.IndexId);
if (_serverStatItem is null) if (_serverStatItem is null)
{ {
@ -95,7 +95,7 @@
_serverStatItem.totalDown += server.proxyDown; _serverStatItem.totalDown += server.proxyDown;
} }
server.indexId = _config.indexId; server.indexId = _config.IndexId;
server.todayUp = _serverStatItem.todayUp; server.todayUp = _serverStatItem.todayUp;
server.todayDown = _serverStatItem.todayDown; server.todayDown = _serverStatItem.todayDown;
server.totalUp = _serverStatItem.totalUp; server.totalUp = _serverStatItem.totalUp;

View file

@ -6,7 +6,7 @@ namespace ServiceLib.Handler.SysProxy
{ {
public static async Task<bool> UpdateSysProxy(Config config, bool forceDisable) public static async Task<bool> UpdateSysProxy(Config config, bool forceDisable)
{ {
var type = config.systemProxyItem.sysProxyType; var type = config.SystemProxyItem.SysProxyType;
if (forceDisable && type != ESysProxyType.Unchanged) if (forceDisable && type != ESysProxyType.Unchanged)
{ {
@ -84,19 +84,19 @@ namespace ServiceLib.Handler.SysProxy
private static void GetWindowsProxyString(Config config, int port, int portSocks, out string strProxy, out string strExceptions) private static void GetWindowsProxyString(Config config, int port, int portSocks, out string strProxy, out string strExceptions)
{ {
strExceptions = ""; strExceptions = "";
if (config.systemProxyItem.notProxyLocalAddress) if (config.SystemProxyItem.NotProxyLocalAddress)
{ {
strExceptions = $"<local>;{config.constItem.defIEProxyExceptions};{config.systemProxyItem.systemProxyExceptions}"; strExceptions = $"<local>;{config.ConstItem.DefIEProxyExceptions};{config.SystemProxyItem.SystemProxyExceptions}";
} }
strProxy = string.Empty; strProxy = string.Empty;
if (Utils.IsNullOrEmpty(config.systemProxyItem.systemProxyAdvancedProtocol)) if (Utils.IsNullOrEmpty(config.SystemProxyItem.SystemProxyAdvancedProtocol))
{ {
strProxy = $"{Global.Loopback}:{port}"; strProxy = $"{Global.Loopback}:{port}";
} }
else else
{ {
strProxy = config.systemProxyItem.systemProxyAdvancedProtocol strProxy = config.SystemProxyItem.SystemProxyAdvancedProtocol
.Replace("{ip}", Global.Loopback) .Replace("{ip}", Global.Loopback)
.Replace("{http_port}", port.ToString()) .Replace("{http_port}", port.ToString())
.Replace("{socks_port}", portSocks.ToString()); .Replace("{socks_port}", portSocks.ToString());

View file

@ -55,9 +55,9 @@
await Task.Delay(1000 * 3600); await Task.Delay(1000 * 3600);
var dtNow = DateTime.Now; var dtNow = DateTime.Now;
if (config.guiItem.autoUpdateInterval > 0) if (config.GuiItem.AutoUpdateInterval > 0)
{ {
if ((dtNow - autoUpdateGeoTime).Hours % config.guiItem.autoUpdateInterval == 0) if ((dtNow - autoUpdateGeoTime).Hours % config.GuiItem.AutoUpdateInterval == 0)
{ {
await updateHandle.UpdateGeoFileAll(config, (bool success, string msg) => await updateHandle.UpdateGeoFileAll(config, (bool success, string msg) =>
{ {

View file

@ -24,9 +24,9 @@ namespace ServiceLib.Handler
{ {
try try
{ {
if (_config.webDavItem.url.IsNullOrEmpty() if (_config.WebDavItem.Url.IsNullOrEmpty()
|| _config.webDavItem.userName.IsNullOrEmpty() || _config.WebDavItem.UserName.IsNullOrEmpty()
|| _config.webDavItem.password.IsNullOrEmpty()) || _config.WebDavItem.Password.IsNullOrEmpty())
{ {
throw new ArgumentException("webdav parameter error or null"); throw new ArgumentException("webdav parameter error or null");
} }
@ -35,19 +35,19 @@ namespace ServiceLib.Handler
_client?.Dispose(); _client?.Dispose();
_client = null; _client = null;
} }
if (_config.webDavItem.dirName.IsNullOrEmpty()) if (_config.WebDavItem.DirName.IsNullOrEmpty())
{ {
_webDir = Global.AppName + "_backup"; _webDir = Global.AppName + "_backup";
} }
else else
{ {
_webDir = _config.webDavItem.dirName.TrimEx(); _webDir = _config.WebDavItem.DirName.TrimEx();
} }
var clientParams = new WebDavClientParams var clientParams = new WebDavClientParams
{ {
BaseAddress = new Uri(_config.webDavItem.url), BaseAddress = new Uri(_config.WebDavItem.Url),
Credentials = new NetworkCredential(_config.webDavItem.userName, _config.webDavItem.password) Credentials = new NetworkCredential(_config.WebDavItem.UserName, _config.WebDavItem.Password)
}; };
_client = new WebDavClient(clientParams); _client = new WebDavClient(clientParams);
} }

View file

@ -8,18 +8,18 @@
{ {
#region property #region property
public string indexId { get; set; } public string IndexId { get; set; }
public string subIndexId { get; set; } public string SubIndexId { get; set; }
public ECoreType runningCoreType { get; set; } public ECoreType RunningCoreType { get; set; }
public bool IsRunningCore(ECoreType type) public bool IsRunningCore(ECoreType type)
{ {
if (type == ECoreType.Xray && runningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5) if (type == ECoreType.Xray && RunningCoreType is ECoreType.Xray or ECoreType.v2fly or ECoreType.v2fly_v5)
{ {
return true; return true;
} }
if (type == ECoreType.sing_box && runningCoreType is ECoreType.sing_box or ECoreType.mihomo) if (type == ECoreType.sing_box && RunningCoreType is ECoreType.sing_box or ECoreType.mihomo)
{ {
return true; return true;
} }
@ -30,25 +30,25 @@
#region other entities #region other entities
public CoreBasicItem coreBasicItem { get; set; } public CoreBasicItem CoreBasicItem { get; set; }
public TunModeItem tunModeItem { get; set; } public TunModeItem TunModeItem { get; set; }
public KcpItem kcpItem { get; set; } public KcpItem KcpItem { get; set; }
public GrpcItem grpcItem { get; set; } public GrpcItem GrpcItem { get; set; }
public RoutingBasicItem routingBasicItem { get; set; } public RoutingBasicItem RoutingBasicItem { get; set; }
public GUIItem guiItem { get; set; } public GUIItem GuiItem { get; set; }
public MsgUIItem msgUIItem { get; set; } public MsgUIItem MsgUIItem { get; set; }
public UIItem uiItem { get; set; } public UIItem UiItem { get; set; }
public ConstItem constItem { get; set; } public ConstItem ConstItem { get; set; }
public SpeedTestItem speedTestItem { get; set; } public SpeedTestItem SpeedTestItem { get; set; }
public Mux4RayItem mux4RayItem { get; set; } public Mux4RayItem Mux4RayItem { get; set; }
public Mux4SboxItem mux4SboxItem { get; set; } public Mux4SboxItem Mux4SboxItem { get; set; }
public HysteriaItem hysteriaItem { get; set; } public HysteriaItem HysteriaItem { get; set; }
public ClashUIItem clashUIItem { get; set; } public ClashUIItem ClashUIItem { get; set; }
public SystemProxyItem systemProxyItem { get; set; } public SystemProxyItem SystemProxyItem { get; set; }
public WebDavItem webDavItem { get; set; } public WebDavItem WebDavItem { get; set; }
public List<InItem> inbound { get; set; } public List<InItem> Inbound { get; set; }
public List<KeyEventItem> globalHotkeys { get; set; } public List<KeyEventItem> GlobalHotkeys { get; set; }
public List<CoreTypeItem> coreTypeItem { get; set; } public List<CoreTypeItem> CoreTypeItem { get; set; }
#endregion other entities #endregion other entities
} }

View file

@ -3,152 +3,137 @@
[Serializable] [Serializable]
public class CoreBasicItem public class CoreBasicItem
{ {
/// <summary> public bool LogEnabled { get; set; }
/// 允许日志
/// </summary>
public bool logEnabled { get; set; }
/// <summary> public string Loglevel { get; set; }
/// 日志等级
/// </summary>
public string loglevel { get; set; }
/// <summary> public bool MuxEnabled { get; set; }
/// 允许Mux多路复用
/// </summary>
public bool muxEnabled { get; set; }
/// <summary> public bool DefAllowInsecure { get; set; }
/// 是否允许不安全连接
/// </summary>
public bool defAllowInsecure { get; set; }
public string defFingerprint { get; set; } public string DefFingerprint { get; set; }
/// <summary> public string DefUserAgent { get; set; }
/// 默认用户代理
/// </summary>
public string defUserAgent { get; set; }
public bool enableFragment { get; set; } public bool EnableFragment { get; set; }
public bool enableCacheFile4Sbox { get; set; } = true; public bool EnableCacheFile4Sbox { get; set; } = true;
} }
[Serializable] [Serializable]
public class InItem public class InItem
{ {
public int localPort { get; set; } public int LocalPort { get; set; }
public string protocol { get; set; } public string Protocol { get; set; }
public bool udpEnabled { get; set; } public bool UdpEnabled { get; set; }
public bool sniffingEnabled { get; set; } = true; public bool SniffingEnabled { get; set; } = true;
public List<string>? destOverride { get; set; } = ["http", "tls"]; public List<string>? DestOverride { get; set; } = ["http", "tls"];
public bool routeOnly { get; set; } public bool RouteOnly { get; set; }
public bool allowLANConn { get; set; } public bool AllowLANConn { get; set; }
public bool newPort4LAN { get; set; } public bool NewPort4LAN { get; set; }
public string user { get; set; } public string User { get; set; }
public string pass { get; set; } public string Pass { get; set; }
} }
[Serializable] [Serializable]
public class KcpItem public class KcpItem
{ {
public int mtu { get; set; } public int Mtu { get; set; }
public int tti { get; set; } public int Tti { get; set; }
public int uplinkCapacity { get; set; } public int UplinkCapacity { get; set; }
public int downlinkCapacity { get; set; } public int DownlinkCapacity { get; set; }
public bool congestion { get; set; } public bool Congestion { get; set; }
public int readBufferSize { get; set; } public int ReadBufferSize { get; set; }
public int writeBufferSize { get; set; } public int WriteBufferSize { get; set; }
} }
[Serializable] [Serializable]
public class GrpcItem public class GrpcItem
{ {
public int idle_timeout { get; set; } public int IdleTimeout { get; set; }
public int health_check_timeout { get; set; } public int HealthCheckTimeout { get; set; }
public bool permit_without_stream { get; set; } public bool PermitWithoutStream { get; set; }
public int initial_windows_size { get; set; } public int InitialWindowsSize { get; set; }
} }
[Serializable] [Serializable]
public class GUIItem public class GUIItem
{ {
public bool autoRun { get; set; } public bool AutoRun { get; set; }
public bool enableStatistics { get; set; } public bool EnableStatistics { get; set; }
public bool keepOlderDedupl { get; set; } public bool KeepOlderDedupl { get; set; }
public bool ignoreGeoUpdateCore { get; set; } = true; public bool IgnoreGeoUpdateCore { get; set; } = true;
public int autoUpdateInterval { get; set; } public int AutoUpdateInterval { get; set; }
public bool checkPreReleaseUpdate { get; set; } = false; public bool CheckPreReleaseUpdate { get; set; } = false;
public bool enableSecurityProtocolTls13 { get; set; } public bool EnableSecurityProtocolTls13 { get; set; }
public int trayMenuServersLimit { get; set; } = 20; public int TrayMenuServersLimit { get; set; } = 20;
public bool enableHWA { get; set; } = false; public bool EnableHWA { get; set; } = false;
} }
[Serializable] [Serializable]
public class MsgUIItem public class MsgUIItem
{ {
public string? mainMsgFilter { get; set; } public string? MainMsgFilter { get; set; }
public bool? autoRefresh { get; set; } public bool? AutoRefresh { get; set; }
} }
[Serializable] [Serializable]
public class UIItem public class UIItem
{ {
public bool enableAutoAdjustMainLvColWidth { get; set; } public bool EnableAutoAdjustMainLvColWidth { get; set; }
public bool enableUpdateSubOnlyRemarksExist { get; set; } public bool EnableUpdateSubOnlyRemarksExist { get; set; }
public double mainWidth { get; set; } public double MainWidth { get; set; }
public double mainHeight { get; set; } public double MainHeight { get; set; }
public double mainGirdHeight1 { get; set; } public double MainGirdHeight1 { get; set; }
public double mainGirdHeight2 { get; set; } public double MainGirdHeight2 { get; set; }
public EGirdOrientation mainGirdOrientation { get; set; } = EGirdOrientation.Vertical; public EGirdOrientation MainGirdOrientation { get; set; } = EGirdOrientation.Vertical;
public bool colorModeDark { get; set; } public bool ColorModeDark { get; set; }
public bool followSystemTheme { get; set; } public bool FollowSystemTheme { get; set; }
public string? colorPrimaryName { get; set; } public string? ColorPrimaryName { get; set; }
public string currentLanguage { get; set; } public string CurrentLanguage { get; set; }
public string currentFontFamily { get; set; } public string CurrentFontFamily { get; set; }
public int currentFontSize { get; set; } public int CurrentFontSize { get; set; }
public bool enableDragDropSort { get; set; } public bool EnableDragDropSort { get; set; }
public bool doubleClick2Activate { get; set; } public bool DoubleClick2Activate { get; set; }
public bool autoHideStartup { get; set; } public bool AutoHideStartup { get; set; }
public List<ColumnItem> mainColumnItem { get; set; } public List<ColumnItem> MainColumnItem { get; set; }
public bool showInTaskbar { get; set; } public bool ShowInTaskbar { get; set; }
} }
[Serializable] [Serializable]
public class ConstItem public class ConstItem
{ {
public string defIEProxyExceptions { get; set; } public string DefIEProxyExceptions { get; set; }
public string subConvertUrl { get; set; } = string.Empty; public string SubConvertUrl { get; set; } = string.Empty;
public string? geoSourceUrl { get; set; } public string? GeoSourceUrl { get; set; }
public string? srsSourceUrl { get; set; } public string? SrsSourceUrl { get; set; }
public string? routeRulesTemplateSourceUrl { get; set; } public string? RouteRulesTemplateSourceUrl { get; set; }
} }
[Serializable] [Serializable]
public class KeyEventItem public class KeyEventItem
{ {
public EGlobalHotkey eGlobalHotkey { get; set; } public EGlobalHotkey EGlobalHotkey { get; set; }
public bool Alt { get; set; } public bool Alt { get; set; }
@ -162,38 +147,38 @@
[Serializable] [Serializable]
public class CoreTypeItem public class CoreTypeItem
{ {
public EConfigType configType { get; set; } public EConfigType ConfigType { get; set; }
public ECoreType coreType { get; set; } public ECoreType CoreType { get; set; }
} }
[Serializable] [Serializable]
public class TunModeItem public class TunModeItem
{ {
public bool enableTun { get; set; } public bool EnableTun { get; set; }
public bool strictRoute { get; set; } = true; public bool StrictRoute { get; set; } = true;
public string stack { get; set; } public string Stack { get; set; }
public int mtu { get; set; } public int Mtu { get; set; }
public bool enableExInbound { get; set; } public bool EnableExInbound { get; set; }
public bool enableIPv6Address { get; set; } public bool EnableIPv6Address { get; set; }
} }
[Serializable] [Serializable]
public class SpeedTestItem public class SpeedTestItem
{ {
public int speedTestTimeout { get; set; } public int SpeedTestTimeout { get; set; }
public string speedTestUrl { get; set; } public string SpeedTestUrl { get; set; }
public string speedPingTestUrl { get; set; } public string SpeedPingTestUrl { get; set; }
} }
[Serializable] [Serializable]
public class RoutingBasicItem public class RoutingBasicItem
{ {
public string domainStrategy { get; set; } public string DomainStrategy { get; set; }
public string domainStrategy4Singbox { get; set; } public string DomainStrategy4Singbox { get; set; }
public string domainMatcher { get; set; } public string DomainMatcher { get; set; }
public string routingIndexId { get; set; } public string RoutingIndexId { get; set; }
public bool enableRoutingAdvanced { get; set; } public bool EnableRoutingAdvanced { get; set; }
} }
[Serializable] [Serializable]
@ -207,55 +192,55 @@
[Serializable] [Serializable]
public class Mux4RayItem public class Mux4RayItem
{ {
public int? concurrency { get; set; } public int? Concurrency { get; set; }
public int? xudpConcurrency { get; set; } public int? XudpConcurrency { get; set; }
public string? xudpProxyUDP443 { get; set; } public string? XudpProxyUDP443 { get; set; }
} }
[Serializable] [Serializable]
public class Mux4SboxItem public class Mux4SboxItem
{ {
public string protocol { get; set; } public string Protocol { get; set; }
public int max_connections { get; set; } public int MaxConnections { get; set; }
public bool? padding { get; set; } public bool? Padding { get; set; }
} }
[Serializable] [Serializable]
public class HysteriaItem public class HysteriaItem
{ {
public int up_mbps { get; set; } public int UpMbps { get; set; }
public int down_mbps { get; set; } public int DownMbps { get; set; }
} }
[Serializable] [Serializable]
public class ClashUIItem public class ClashUIItem
{ {
public ERuleMode ruleMode { get; set; } public ERuleMode RuleMode { get; set; }
public bool enableIPv6 { get; set; } public bool EnableIPv6 { get; set; }
public bool enableMixinContent { get; set; } public bool EnableMixinContent { get; set; }
public int proxiesSorting { get; set; } public int ProxiesSorting { get; set; }
public bool proxiesAutoRefresh { get; set; } public bool ProxiesAutoRefresh { get; set; }
public int proxiesAutoDelayTestInterval { get; set; } = 10; public int ProxiesAutoDelayTestInterval { get; set; } = 10;
public int connectionsSorting { get; set; } public int ConnectionsSorting { get; set; }
public bool connectionsAutoRefresh { get; set; } public bool ConnectionsAutoRefresh { get; set; }
public int connectionsRefreshInterval { get; set; } = 2; public int ConnectionsRefreshInterval { get; set; } = 2;
} }
[Serializable] [Serializable]
public class SystemProxyItem public class SystemProxyItem
{ {
public ESysProxyType sysProxyType { get; set; } public ESysProxyType SysProxyType { get; set; }
public string systemProxyExceptions { get; set; } public string SystemProxyExceptions { get; set; }
public bool notProxyLocalAddress { get; set; } = true; public bool NotProxyLocalAddress { get; set; } = true;
public string systemProxyAdvancedProtocol { get; set; } public string SystemProxyAdvancedProtocol { get; set; }
} }
[Serializable] [Serializable]
public class WebDavItem public class WebDavItem
{ {
public string? url { get; set; } public string? Url { get; set; }
public string? userName { get; set; } public string? UserName { get; set; }
public string? password { get; set; } public string? Password { get; set; }
public string? dirName { get; set; } public string? DirName { get; set; }
} }
} }

View file

@ -83,12 +83,12 @@
//socks-port //socks-port
fileContent["socks-port"] = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); fileContent["socks-port"] = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
//log-level //log-level
fileContent["log-level"] = GetLogLevel(_config.coreBasicItem.loglevel); fileContent["log-level"] = GetLogLevel(_config.CoreBasicItem.Loglevel);
//external-controller //external-controller
fileContent["external-controller"] = $"{Global.Loopback}:{AppHandler.Instance.StatePort2}"; fileContent["external-controller"] = $"{Global.Loopback}:{AppHandler.Instance.StatePort2}";
//allow-lan //allow-lan
if (_config.inbound[0].allowLANConn) if (_config.Inbound[0].AllowLANConn)
{ {
fileContent["allow-lan"] = "true"; fileContent["allow-lan"] = "true";
fileContent["bind-address"] = "*"; fileContent["bind-address"] = "*";
@ -99,7 +99,7 @@
} }
//ipv6 //ipv6
fileContent["ipv6"] = _config.clashUIItem.enableIPv6; fileContent["ipv6"] = _config.ClashUIItem.EnableIPv6;
//mode //mode
if (!fileContent.ContainsKey("mode")) if (!fileContent.ContainsKey("mode"))
@ -108,14 +108,14 @@
} }
else else
{ {
if (_config.clashUIItem.ruleMode != ERuleMode.Unchanged) if (_config.ClashUIItem.RuleMode != ERuleMode.Unchanged)
{ {
fileContent["mode"] = _config.clashUIItem.ruleMode.ToString().ToLower(); fileContent["mode"] = _config.ClashUIItem.RuleMode.ToString().ToLower();
} }
} }
//enable tun mode //enable tun mode
if (_config.tunModeItem.enableTun) if (_config.TunModeItem.EnableTun)
{ {
string tun = Utils.GetEmbedText(Global.ClashTunYaml); string tun = Utils.GetEmbedText(Global.ClashTunYaml);
if (Utils.IsNotEmpty(tun)) if (Utils.IsNotEmpty(tun))
@ -181,7 +181,7 @@
} }
foreach (var item in mixinContent) foreach (var item in mixinContent)
{ {
if (!_config.tunModeItem.enableTun && item.Key == "tun") if (!_config.TunModeItem.EnableTun && item.Key == "tun")
{ {
continue; continue;
} }

View file

@ -444,12 +444,12 @@ namespace ServiceLib.Services.CoreConfig
{ {
try try
{ {
switch (_config.coreBasicItem.loglevel) switch (_config.CoreBasicItem.Loglevel)
{ {
case "debug": case "debug":
case "info": case "info":
case "error": case "error":
singboxConfig.log.level = _config.coreBasicItem.loglevel; singboxConfig.log.level = _config.CoreBasicItem.Loglevel;
break; break;
case "warning": case "warning":
@ -459,11 +459,11 @@ namespace ServiceLib.Services.CoreConfig
default: default:
break; break;
} }
if (_config.coreBasicItem.loglevel == Global.None) if (_config.CoreBasicItem.Loglevel == Global.None)
{ {
singboxConfig.log.disabled = true; singboxConfig.log.disabled = true;
} }
if (_config.coreBasicItem.logEnabled) if (_config.CoreBasicItem.LogEnabled)
{ {
var dtNow = DateTime.Now; var dtNow = DateTime.Now;
singboxConfig.log.output = Utils.GetLogPath($"sbox_{dtNow:yyyy-MM-dd}.txt"); singboxConfig.log.output = Utils.GetLogPath($"sbox_{dtNow:yyyy-MM-dd}.txt");
@ -483,8 +483,8 @@ namespace ServiceLib.Services.CoreConfig
var listen = "::"; var listen = "::";
singboxConfig.inbounds = []; singboxConfig.inbounds = [];
if (!_config.tunModeItem.enableTun if (!_config.TunModeItem.EnableTun
|| _config.tunModeItem.enableTun && _config.tunModeItem.enableExInbound && _config.runningCoreType == ECoreType.sing_box) || _config.TunModeItem.EnableTun && _config.TunModeItem.EnableExInbound && _config.RunningCoreType == ECoreType.sing_box)
{ {
var inbound = new Inbound4Sbox() var inbound = new Inbound4Sbox()
{ {
@ -495,11 +495,11 @@ namespace ServiceLib.Services.CoreConfig
singboxConfig.inbounds.Add(inbound); singboxConfig.inbounds.Add(inbound);
inbound.listen_port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks); inbound.listen_port = AppHandler.Instance.GetLocalPort(EInboundProtocol.socks);
inbound.sniff = _config.inbound[0].sniffingEnabled; inbound.sniff = _config.Inbound[0].SniffingEnabled;
inbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled; inbound.sniff_override_destination = _config.Inbound[0].RouteOnly ? false : _config.Inbound[0].SniffingEnabled;
inbound.domain_strategy = Utils.IsNullOrEmpty(_config.routingBasicItem.domainStrategy4Singbox) ? null : _config.routingBasicItem.domainStrategy4Singbox; inbound.domain_strategy = Utils.IsNullOrEmpty(_config.RoutingBasicItem.DomainStrategy4Singbox) ? null : _config.RoutingBasicItem.DomainStrategy4Singbox;
if (_config.routingBasicItem.enableRoutingAdvanced) if (_config.RoutingBasicItem.EnableRoutingAdvanced)
{ {
var routing = await ConfigHandler.GetDefaultRouting(_config); var routing = await ConfigHandler.GetDefaultRouting(_config);
if (Utils.IsNotEmpty(routing.domainStrategy4Singbox)) if (Utils.IsNotEmpty(routing.domainStrategy4Singbox))
@ -512,9 +512,9 @@ namespace ServiceLib.Services.CoreConfig
var inbound2 = GetInbound(inbound, EInboundProtocol.http, false); var inbound2 = GetInbound(inbound, EInboundProtocol.http, false);
singboxConfig.inbounds.Add(inbound2); singboxConfig.inbounds.Add(inbound2);
if (_config.inbound[0].allowLANConn) if (_config.Inbound[0].AllowLANConn)
{ {
if (_config.inbound[0].newPort4LAN) if (_config.Inbound[0].NewPort4LAN)
{ {
var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true); var inbound3 = GetInbound(inbound, EInboundProtocol.socks2, true);
inbound3.listen = listen; inbound3.listen = listen;
@ -525,10 +525,10 @@ namespace ServiceLib.Services.CoreConfig
singboxConfig.inbounds.Add(inbound4); singboxConfig.inbounds.Add(inbound4);
//auth //auth
if (Utils.IsNotEmpty(_config.inbound[0].user) && Utils.IsNotEmpty(_config.inbound[0].pass)) if (Utils.IsNotEmpty(_config.Inbound[0].User) && Utils.IsNotEmpty(_config.Inbound[0].Pass))
{ {
inbound3.users = new() { new() { username = _config.inbound[0].user, password = _config.inbound[0].pass } }; inbound3.users = new() { new() { username = _config.Inbound[0].User, password = _config.Inbound[0].Pass } };
inbound4.users = new() { new() { username = _config.inbound[0].user, password = _config.inbound[0].pass } }; inbound4.users = new() { new() { username = _config.Inbound[0].User, password = _config.Inbound[0].Pass } };
} }
} }
else else
@ -539,24 +539,24 @@ namespace ServiceLib.Services.CoreConfig
} }
} }
if (_config.tunModeItem.enableTun) if (_config.TunModeItem.EnableTun)
{ {
if (_config.tunModeItem.mtu <= 0) if (_config.TunModeItem.Mtu <= 0)
{ {
_config.tunModeItem.mtu = Utils.ToInt(Global.TunMtus[0]); _config.TunModeItem.Mtu = Utils.ToInt(Global.TunMtus[0]);
} }
if (Utils.IsNullOrEmpty(_config.tunModeItem.stack)) if (Utils.IsNullOrEmpty(_config.TunModeItem.Stack))
{ {
_config.tunModeItem.stack = Global.TunStacks[0]; _config.TunModeItem.Stack = Global.TunStacks[0];
} }
var tunInbound = JsonUtils.Deserialize<Inbound4Sbox>(Utils.GetEmbedText(Global.TunSingboxInboundFileName)) ?? new Inbound4Sbox { }; var tunInbound = JsonUtils.Deserialize<Inbound4Sbox>(Utils.GetEmbedText(Global.TunSingboxInboundFileName)) ?? new Inbound4Sbox { };
tunInbound.mtu = _config.tunModeItem.mtu; tunInbound.mtu = _config.TunModeItem.Mtu;
tunInbound.strict_route = _config.tunModeItem.strictRoute; tunInbound.strict_route = _config.TunModeItem.StrictRoute;
tunInbound.stack = _config.tunModeItem.stack; tunInbound.stack = _config.TunModeItem.Stack;
tunInbound.sniff = _config.inbound[0].sniffingEnabled; tunInbound.sniff = _config.Inbound[0].SniffingEnabled;
//tunInbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled; //tunInbound.sniff_override_destination = _config.inbound[0].routeOnly ? false : _config.inbound[0].sniffingEnabled;
if (_config.tunModeItem.enableIPv6Address == false) if (_config.TunModeItem.EnableIPv6Address == false)
{ {
tunInbound.inet6_address = null; tunInbound.inet6_address = null;
} }
@ -671,8 +671,8 @@ namespace ServiceLib.Services.CoreConfig
}; };
} }
outbound.up_mbps = _config.hysteriaItem.up_mbps > 0 ? _config.hysteriaItem.up_mbps : null; outbound.up_mbps = _config.HysteriaItem.UpMbps > 0 ? _config.HysteriaItem.UpMbps : null;
outbound.down_mbps = _config.hysteriaItem.down_mbps > 0 ? _config.hysteriaItem.down_mbps : null; outbound.down_mbps = _config.HysteriaItem.DownMbps > 0 ? _config.HysteriaItem.DownMbps : null;
break; break;
} }
case EConfigType.TUIC: case EConfigType.TUIC:
@ -708,14 +708,14 @@ namespace ServiceLib.Services.CoreConfig
{ {
try try
{ {
if (_config.coreBasicItem.muxEnabled && Utils.IsNotEmpty(_config.mux4SboxItem.protocol)) if (_config.CoreBasicItem.MuxEnabled && Utils.IsNotEmpty(_config.Mux4SboxItem.Protocol))
{ {
var mux = new Multiplex4Sbox() var mux = new Multiplex4Sbox()
{ {
enabled = true, enabled = true,
protocol = _config.mux4SboxItem.protocol, protocol = _config.Mux4SboxItem.Protocol,
max_connections = _config.mux4SboxItem.max_connections, max_connections = _config.Mux4SboxItem.MaxConnections,
padding = _config.mux4SboxItem.padding, padding = _config.Mux4SboxItem.Padding,
}; };
outbound.multiplex = mux; outbound.multiplex = mux;
} }
@ -746,7 +746,7 @@ namespace ServiceLib.Services.CoreConfig
{ {
enabled = true, enabled = true,
server_name = server_name, server_name = server_name,
insecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.coreBasicItem.defAllowInsecure.ToString().ToLower() : node.allowInsecure), insecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.allowInsecure),
alpn = node.GetAlpn(), alpn = node.GetAlpn(),
}; };
if (Utils.IsNotEmpty(node.fingerprint)) if (Utils.IsNotEmpty(node.fingerprint))
@ -754,7 +754,7 @@ namespace ServiceLib.Services.CoreConfig
tls.utls = new Utls4Sbox() tls.utls = new Utls4Sbox()
{ {
enabled = true, enabled = true,
fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.coreBasicItem.defFingerprint : node.fingerprint fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint
}; };
} }
if (node.streamSecurity == Global.StreamSecurityReality) if (node.streamSecurity == Global.StreamSecurityReality)
@ -834,9 +834,9 @@ namespace ServiceLib.Services.CoreConfig
case nameof(ETransport.grpc): case nameof(ETransport.grpc):
transport.type = nameof(ETransport.grpc); transport.type = nameof(ETransport.grpc);
transport.service_name = node.path; transport.service_name = node.path;
transport.idle_timeout = _config.grpcItem.idle_timeout.ToString("##s"); transport.idle_timeout = _config.GrpcItem.IdleTimeout.ToString("##s");
transport.ping_timeout = _config.grpcItem.health_check_timeout.ToString("##s"); transport.ping_timeout = _config.GrpcItem.HealthCheckTimeout.ToString("##s");
transport.permit_without_stream = _config.grpcItem.permit_without_stream; transport.permit_without_stream = _config.GrpcItem.PermitWithoutStream;
break; break;
default: default:
@ -912,7 +912,7 @@ namespace ServiceLib.Services.CoreConfig
try try
{ {
var dnsOutbound = "dns_out"; var dnsOutbound = "dns_out";
if (!_config.inbound[0].sniffingEnabled) if (!_config.Inbound[0].SniffingEnabled)
{ {
singboxConfig.route.rules.Add(new() singboxConfig.route.rules.Add(new()
{ {
@ -933,7 +933,7 @@ namespace ServiceLib.Services.CoreConfig
clash_mode = ERuleMode.Global.ToString() clash_mode = ERuleMode.Global.ToString()
}); });
if (_config.tunModeItem.enableTun) if (_config.TunModeItem.EnableTun)
{ {
singboxConfig.route.auto_detect_interface = true; singboxConfig.route.auto_detect_interface = true;
@ -958,7 +958,7 @@ namespace ServiceLib.Services.CoreConfig
}); });
} }
if (_config.routingBasicItem.enableRoutingAdvanced) if (_config.RoutingBasicItem.EnableRoutingAdvanced)
{ {
var routing = await ConfigHandler.GetDefaultRouting(_config); var routing = await ConfigHandler.GetDefaultRouting(_config);
if (routing != null) if (routing != null)
@ -1089,7 +1089,7 @@ namespace ServiceLib.Services.CoreConfig
} }
} }
if (_config.tunModeItem.enableTun && item.process?.Count > 0) if (_config.TunModeItem.EnableTun && item.process?.Count > 0)
{ {
rule3.process_name = item.process; rule3.process_name = item.process;
rules.Add(rule3); rules.Add(rule3);
@ -1183,7 +1183,7 @@ namespace ServiceLib.Services.CoreConfig
{ {
var item = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box); var item = await AppHandler.Instance.GetDNSItem(ECoreType.sing_box);
var strDNS = string.Empty; var strDNS = string.Empty;
if (_config.tunModeItem.enableTun) if (_config.TunModeItem.EnableTun)
{ {
strDNS = Utils.IsNullOrEmpty(item?.tunDNS) ? Utils.GetEmbedText(Global.TunSingboxDNSFileName) : item?.tunDNS; strDNS = Utils.IsNullOrEmpty(item?.tunDNS) ? Utils.GetEmbedText(Global.TunSingboxDNSFileName) : item?.tunDNS;
} }
@ -1248,7 +1248,7 @@ namespace ServiceLib.Services.CoreConfig
} }
//Tun2SocksAddress //Tun2SocksAddress
if (_config.tunModeItem.enableTun && node?.configType == EConfigType.SOCKS && Utils.IsDomain(node?.sni)) if (_config.TunModeItem.EnableTun && node?.configType == EConfigType.SOCKS && Utils.IsDomain(node?.sni))
{ {
dns4Sbox.rules.Insert(0, new() dns4Sbox.rules.Insert(0, new()
{ {
@ -1272,7 +1272,7 @@ namespace ServiceLib.Services.CoreConfig
}; };
} }
if (_config.coreBasicItem.enableCacheFile4Sbox) if (_config.CoreBasicItem.EnableCacheFile4Sbox)
{ {
singboxConfig.experimental ??= new Experimental4Sbox(); singboxConfig.experimental ??= new Experimental4Sbox();
singboxConfig.experimental.cache_file = new CacheFile4Sbox() singboxConfig.experimental.cache_file = new CacheFile4Sbox()
@ -1334,7 +1334,7 @@ namespace ServiceLib.Services.CoreConfig
//load custom ruleset file //load custom ruleset file
List<Ruleset4Sbox> customRulesets = []; List<Ruleset4Sbox> customRulesets = [];
if (_config.routingBasicItem.enableRoutingAdvanced) if (_config.RoutingBasicItem.EnableRoutingAdvanced)
{ {
var routing = await ConfigHandler.GetDefaultRouting(_config); var routing = await ConfigHandler.GetDefaultRouting(_config);
if (Utils.IsNotEmpty(routing.customRulesetPath4Singbox)) if (Utils.IsNotEmpty(routing.customRulesetPath4Singbox))
@ -1375,9 +1375,9 @@ namespace ServiceLib.Services.CoreConfig
} }
else else
{ {
var srsUrl = string.IsNullOrEmpty(_config.constItem.srsSourceUrl) var srsUrl = string.IsNullOrEmpty(_config.ConstItem.SrsSourceUrl)
? Global.SingboxRulesetUrl ? Global.SingboxRulesetUrl
: _config.constItem.srsSourceUrl; : _config.ConstItem.SrsSourceUrl;
customRuleset = new() customRuleset = new()
{ {

View file

@ -356,16 +356,16 @@ namespace ServiceLib.Services.CoreConfig
{ {
try try
{ {
if (_config.coreBasicItem.logEnabled) if (_config.CoreBasicItem.LogEnabled)
{ {
var dtNow = DateTime.Now; var dtNow = DateTime.Now;
v2rayConfig.log.loglevel = _config.coreBasicItem.loglevel; v2rayConfig.log.loglevel = _config.CoreBasicItem.Loglevel;
v2rayConfig.log.access = Utils.GetLogPath($"Vaccess_{dtNow:yyyy-MM-dd}.txt"); v2rayConfig.log.access = Utils.GetLogPath($"Vaccess_{dtNow:yyyy-MM-dd}.txt");
v2rayConfig.log.error = Utils.GetLogPath($"Verror_{dtNow:yyyy-MM-dd}.txt"); v2rayConfig.log.error = Utils.GetLogPath($"Verror_{dtNow:yyyy-MM-dd}.txt");
} }
else else
{ {
v2rayConfig.log.loglevel = _config.coreBasicItem.loglevel; v2rayConfig.log.loglevel = _config.CoreBasicItem.Loglevel;
v2rayConfig.log.access = ""; v2rayConfig.log.access = "";
v2rayConfig.log.error = ""; v2rayConfig.log.error = "";
} }
@ -384,33 +384,33 @@ namespace ServiceLib.Services.CoreConfig
var listen = "0.0.0.0"; var listen = "0.0.0.0";
v2rayConfig.inbounds = []; v2rayConfig.inbounds = [];
Inbounds4Ray? inbound = GetInbound(_config.inbound[0], EInboundProtocol.socks, true); Inbounds4Ray? inbound = GetInbound(_config.Inbound[0], EInboundProtocol.socks, true);
v2rayConfig.inbounds.Add(inbound); v2rayConfig.inbounds.Add(inbound);
//http //http
Inbounds4Ray? inbound2 = GetInbound(_config.inbound[0], EInboundProtocol.http, false); Inbounds4Ray? inbound2 = GetInbound(_config.Inbound[0], EInboundProtocol.http, false);
v2rayConfig.inbounds.Add(inbound2); v2rayConfig.inbounds.Add(inbound2);
if (_config.inbound[0].allowLANConn) if (_config.Inbound[0].AllowLANConn)
{ {
if (_config.inbound[0].newPort4LAN) if (_config.Inbound[0].NewPort4LAN)
{ {
var inbound3 = GetInbound(_config.inbound[0], EInboundProtocol.socks2, true); var inbound3 = GetInbound(_config.Inbound[0], EInboundProtocol.socks2, true);
inbound3.listen = listen; inbound3.listen = listen;
v2rayConfig.inbounds.Add(inbound3); v2rayConfig.inbounds.Add(inbound3);
var inbound4 = GetInbound(_config.inbound[0], EInboundProtocol.http2, false); var inbound4 = GetInbound(_config.Inbound[0], EInboundProtocol.http2, false);
inbound4.listen = listen; inbound4.listen = listen;
v2rayConfig.inbounds.Add(inbound4); v2rayConfig.inbounds.Add(inbound4);
//auth //auth
if (Utils.IsNotEmpty(_config.inbound[0].user) && Utils.IsNotEmpty(_config.inbound[0].pass)) if (Utils.IsNotEmpty(_config.Inbound[0].User) && Utils.IsNotEmpty(_config.Inbound[0].Pass))
{ {
inbound3.settings.auth = "password"; inbound3.settings.auth = "password";
inbound3.settings.accounts = new List<AccountsItem4Ray> { new AccountsItem4Ray() { user = _config.inbound[0].user, pass = _config.inbound[0].pass } }; inbound3.settings.accounts = new List<AccountsItem4Ray> { new AccountsItem4Ray() { user = _config.Inbound[0].User, pass = _config.Inbound[0].Pass } };
inbound4.settings.auth = "password"; inbound4.settings.auth = "password";
inbound4.settings.accounts = new List<AccountsItem4Ray> { new AccountsItem4Ray() { user = _config.inbound[0].user, pass = _config.inbound[0].pass } }; inbound4.settings.accounts = new List<AccountsItem4Ray> { new AccountsItem4Ray() { user = _config.Inbound[0].User, pass = _config.Inbound[0].Pass } };
} }
} }
else else
@ -441,12 +441,12 @@ namespace ServiceLib.Services.CoreConfig
return new(); return new();
} }
inbound.tag = protocol.ToString(); inbound.tag = protocol.ToString();
inbound.port = inItem.localPort + (int)protocol; inbound.port = inItem.LocalPort + (int)protocol;
inbound.protocol = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString(); inbound.protocol = bSocks ? EInboundProtocol.socks.ToString() : EInboundProtocol.http.ToString();
inbound.settings.udp = inItem.udpEnabled; inbound.settings.udp = inItem.UdpEnabled;
inbound.sniffing.enabled = inItem.sniffingEnabled; inbound.sniffing.enabled = inItem.SniffingEnabled;
inbound.sniffing.destOverride = inItem.destOverride; inbound.sniffing.destOverride = inItem.DestOverride;
inbound.sniffing.routeOnly = inItem.routeOnly; inbound.sniffing.routeOnly = inItem.RouteOnly;
return inbound; return inbound;
} }
@ -457,10 +457,10 @@ namespace ServiceLib.Services.CoreConfig
{ {
if (v2rayConfig.routing?.rules != null) if (v2rayConfig.routing?.rules != null)
{ {
v2rayConfig.routing.domainStrategy = _config.routingBasicItem.domainStrategy; v2rayConfig.routing.domainStrategy = _config.RoutingBasicItem.DomainStrategy;
v2rayConfig.routing.domainMatcher = Utils.IsNullOrEmpty(_config.routingBasicItem.domainMatcher) ? null : _config.routingBasicItem.domainMatcher; v2rayConfig.routing.domainMatcher = Utils.IsNullOrEmpty(_config.RoutingBasicItem.DomainMatcher) ? null : _config.RoutingBasicItem.DomainMatcher;
if (_config.routingBasicItem.enableRoutingAdvanced) if (_config.RoutingBasicItem.EnableRoutingAdvanced)
{ {
var routing = await ConfigHandler.GetDefaultRouting(_config); var routing = await ConfigHandler.GetDefaultRouting(_config);
if (routing != null) if (routing != null)
@ -624,7 +624,7 @@ namespace ServiceLib.Services.CoreConfig
usersItem.security = Global.DefaultSecurity; usersItem.security = Global.DefaultSecurity;
} }
await GenOutboundMux(node, outbound, _config.coreBasicItem.muxEnabled); await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled);
outbound.settings.servers = null; outbound.settings.servers = null;
break; break;
@ -719,7 +719,7 @@ namespace ServiceLib.Services.CoreConfig
usersItem.email = Global.UserEMail; usersItem.email = Global.UserEMail;
usersItem.encryption = node.security; usersItem.encryption = node.security;
await GenOutboundMux(node, outbound, _config.coreBasicItem.muxEnabled); await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled);
if (node.streamSecurity == Global.StreamSecurityReality if (node.streamSecurity == Global.StreamSecurityReality
|| node.streamSecurity == Global.StreamSecurity) || node.streamSecurity == Global.StreamSecurity)
@ -733,7 +733,7 @@ namespace ServiceLib.Services.CoreConfig
} }
if (node.streamSecurity == Global.StreamSecurityReality && Utils.IsNullOrEmpty(node.flow)) if (node.streamSecurity == Global.StreamSecurityReality && Utils.IsNullOrEmpty(node.flow))
{ {
await GenOutboundMux(node, outbound, _config.coreBasicItem.muxEnabled); await GenOutboundMux(node, outbound, _config.CoreBasicItem.MuxEnabled);
} }
outbound.settings.servers = null; outbound.settings.servers = null;
@ -782,9 +782,9 @@ namespace ServiceLib.Services.CoreConfig
if (enabled) if (enabled)
{ {
outbound.mux.enabled = true; outbound.mux.enabled = true;
outbound.mux.concurrency = _config.mux4RayItem.concurrency; outbound.mux.concurrency = _config.Mux4RayItem.Concurrency;
outbound.mux.xudpConcurrency = _config.mux4RayItem.xudpConcurrency; outbound.mux.xudpConcurrency = _config.Mux4RayItem.XudpConcurrency;
outbound.mux.xudpProxyUDP443 = _config.mux4RayItem.xudpProxyUDP443; outbound.mux.xudpProxyUDP443 = _config.Mux4RayItem.XudpProxyUDP443;
} }
else else
{ {
@ -807,15 +807,15 @@ namespace ServiceLib.Services.CoreConfig
string host = node.requestHost.TrimEx(); string host = node.requestHost.TrimEx();
string sni = node.sni; string sni = node.sni;
string useragent = ""; string useragent = "";
if (!_config.coreBasicItem.defUserAgent.IsNullOrEmpty()) if (!_config.CoreBasicItem.DefUserAgent.IsNullOrEmpty())
{ {
try try
{ {
useragent = Global.UserAgentTexts[_config.coreBasicItem.defUserAgent]; useragent = Global.UserAgentTexts[_config.CoreBasicItem.DefUserAgent];
} }
catch (KeyNotFoundException) catch (KeyNotFoundException)
{ {
useragent = _config.coreBasicItem.defUserAgent; useragent = _config.CoreBasicItem.DefUserAgent;
} }
} }
@ -826,9 +826,9 @@ namespace ServiceLib.Services.CoreConfig
TlsSettings4Ray tlsSettings = new() TlsSettings4Ray tlsSettings = new()
{ {
allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.coreBasicItem.defAllowInsecure.ToString().ToLower() : node.allowInsecure), allowInsecure = Utils.ToBool(node.allowInsecure.IsNullOrEmpty() ? _config.CoreBasicItem.DefAllowInsecure.ToString().ToLower() : node.allowInsecure),
alpn = node.GetAlpn(), alpn = node.GetAlpn(),
fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.coreBasicItem.defFingerprint : node.fingerprint fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint
}; };
if (Utils.IsNotEmpty(sni)) if (Utils.IsNotEmpty(sni))
{ {
@ -848,7 +848,7 @@ namespace ServiceLib.Services.CoreConfig
TlsSettings4Ray realitySettings = new() TlsSettings4Ray realitySettings = new()
{ {
fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.coreBasicItem.defFingerprint : node.fingerprint, fingerprint = node.fingerprint.IsNullOrEmpty() ? _config.CoreBasicItem.DefFingerprint : node.fingerprint,
serverName = sni, serverName = sni,
publicKey = node.publicKey, publicKey = node.publicKey,
shortId = node.shortId, shortId = node.shortId,
@ -865,16 +865,16 @@ namespace ServiceLib.Services.CoreConfig
case nameof(ETransport.kcp): case nameof(ETransport.kcp):
KcpSettings4Ray kcpSettings = new() KcpSettings4Ray kcpSettings = new()
{ {
mtu = _config.kcpItem.mtu, mtu = _config.KcpItem.Mtu,
tti = _config.kcpItem.tti tti = _config.KcpItem.Tti
}; };
kcpSettings.uplinkCapacity = _config.kcpItem.uplinkCapacity; kcpSettings.uplinkCapacity = _config.KcpItem.UplinkCapacity;
kcpSettings.downlinkCapacity = _config.kcpItem.downlinkCapacity; kcpSettings.downlinkCapacity = _config.KcpItem.DownlinkCapacity;
kcpSettings.congestion = _config.kcpItem.congestion; kcpSettings.congestion = _config.KcpItem.Congestion;
kcpSettings.readBufferSize = _config.kcpItem.readBufferSize; kcpSettings.readBufferSize = _config.KcpItem.ReadBufferSize;
kcpSettings.writeBufferSize = _config.kcpItem.writeBufferSize; kcpSettings.writeBufferSize = _config.KcpItem.WriteBufferSize;
kcpSettings.header = new Header4Ray kcpSettings.header = new Header4Ray
{ {
type = node.headerType type = node.headerType
@ -983,10 +983,10 @@ namespace ServiceLib.Services.CoreConfig
authority = Utils.IsNullOrEmpty(host) ? null : host, authority = Utils.IsNullOrEmpty(host) ? null : host,
serviceName = node.path, serviceName = node.path,
multiMode = node.headerType == Global.GrpcMultiMode, multiMode = node.headerType == Global.GrpcMultiMode,
idle_timeout = _config.grpcItem.idle_timeout, idle_timeout = _config.GrpcItem.IdleTimeout,
health_check_timeout = _config.grpcItem.health_check_timeout, health_check_timeout = _config.GrpcItem.HealthCheckTimeout,
permit_without_stream = _config.grpcItem.permit_without_stream, permit_without_stream = _config.GrpcItem.PermitWithoutStream,
initial_windows_size = _config.grpcItem.initial_windows_size, initial_windows_size = _config.GrpcItem.InitialWindowsSize,
}; };
streamSettings.grpcSettings = grpcSettings; streamSettings.grpcSettings = grpcSettings;
break; break;
@ -1117,7 +1117,7 @@ namespace ServiceLib.Services.CoreConfig
public async Task<int> GenStatistic(V2rayConfig v2rayConfig) public async Task<int> GenStatistic(V2rayConfig v2rayConfig)
{ {
if (_config.guiItem.enableStatistics) if (_config.GuiItem.EnableStatistics)
{ {
string tag = EInboundProtocol.api.ToString(); string tag = EInboundProtocol.api.ToString();
API4Ray apiObj = new(); API4Ray apiObj = new();
@ -1168,7 +1168,7 @@ namespace ServiceLib.Services.CoreConfig
private async Task<int> GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig) private async Task<int> GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig)
{ {
//fragment proxy //fragment proxy
if (_config.coreBasicItem.enableFragment if (_config.CoreBasicItem.EnableFragment
&& Utils.IsNotEmpty(v2rayConfig.outbounds[0].streamSettings?.security)) && Utils.IsNotEmpty(v2rayConfig.outbounds[0].streamSettings?.security))
{ {
var fragmentOutbound = new Outbounds4Ray var fragmentOutbound = new Outbounds4Ray

View file

@ -18,7 +18,7 @@ namespace ServiceLib.Services
{ {
try try
{ {
SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
var progress = new Progress<string>(); var progress = new Progress<string>();
progress.ProgressChanged += (sender, value) => progress.ProgressChanged += (sender, value) =>
@ -50,7 +50,7 @@ namespace ServiceLib.Services
{ {
try try
{ {
SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
UpdateCompleted?.Invoke(this, new RetResult(false, $"{ResUI.Downloading} {url}")); UpdateCompleted?.Invoke(this, new RetResult(false, $"{ResUI.Downloading} {url}"));
var progress = new Progress<double>(); var progress = new Progress<double>();
@ -80,7 +80,7 @@ namespace ServiceLib.Services
public async Task<string?> UrlRedirectAsync(string url, bool blProxy) public async Task<string?> UrlRedirectAsync(string url, bool blProxy)
{ {
SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
var webRequestHandler = new SocketsHttpHandler var webRequestHandler = new SocketsHttpHandler
{ {
AllowAutoRedirect = false, AllowAutoRedirect = false,
@ -150,7 +150,7 @@ namespace ServiceLib.Services
{ {
try try
{ {
SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
var webProxy = await GetWebProxy(blProxy); var webProxy = await GetWebProxy(blProxy);
var client = new HttpClient(new SocketsHttpHandler() var client = new HttpClient(new SocketsHttpHandler()
{ {
@ -195,7 +195,7 @@ namespace ServiceLib.Services
{ {
try try
{ {
SetSecurityProtocol(AppHandler.Instance.Config.guiItem.enableSecurityProtocolTls13); SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
var webProxy = await GetWebProxy(blProxy); var webProxy = await GetWebProxy(blProxy);
@ -227,7 +227,7 @@ namespace ServiceLib.Services
try try
{ {
var config = AppHandler.Instance.Config; var config = AppHandler.Instance.Config;
var responseTime = await GetRealPingTime(config.speedTestItem.speedPingTestUrl, webProxy, 10); var responseTime = await GetRealPingTime(config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10);
return responseTime; return responseTime;
} }
catch (Exception ex) catch (Exception ex)

View file

@ -203,8 +203,8 @@ namespace ServiceLib.Services
return; return;
} }
string url = _config.speedTestItem.speedTestUrl; string url = _config.SpeedTestItem.SpeedTestUrl;
var timeout = _config.speedTestItem.speedTestTimeout; var timeout = _config.SpeedTestItem.SpeedTestTimeout;
DownloadService downloadHandle = new(); DownloadService downloadHandle = new();
@ -265,8 +265,8 @@ namespace ServiceLib.Services
return; return;
} }
string url = _config.speedTestItem.speedTestUrl; string url = _config.SpeedTestItem.SpeedTestUrl;
var timeout = _config.speedTestItem.speedTestTimeout; var timeout = _config.SpeedTestItem.SpeedTestTimeout;
DownloadService downloadHandle = new(); DownloadService downloadHandle = new();
@ -331,7 +331,7 @@ namespace ServiceLib.Services
private async Task<string> GetRealPingTime(DownloadService downloadHandle, IWebProxy webProxy) private async Task<string> GetRealPingTime(DownloadService downloadHandle, IWebProxy webProxy)
{ {
int responseTime = await downloadHandle.GetRealPingTime(_config.speedTestItem.speedPingTestUrl, webProxy, 10); int responseTime = await downloadHandle.GetRealPingTime(_config.SpeedTestItem.SpeedPingTestUrl, webProxy, 10);
//string output = Utile.IsNullOrEmpty(status) ? FormatOut(responseTime, "ms") : status; //string output = Utile.IsNullOrEmpty(status) ? FormatOut(responseTime, "ms") : status;
return FormatOut(responseTime, Global.DelayUnit); return FormatOut(responseTime, Global.DelayUnit);
} }

View file

@ -154,7 +154,7 @@ namespace ServiceLib.Services
//convert //convert
if (Utils.IsNotEmpty(item.convertTarget)) if (Utils.IsNotEmpty(item.convertTarget))
{ {
var subConvertUrl = Utils.IsNullOrEmpty(config.constItem.subConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.constItem.subConvertUrl; var subConvertUrl = Utils.IsNullOrEmpty(config.ConstItem.SubConvertUrl) ? Global.SubConvertUrls.FirstOrDefault() : config.ConstItem.SubConvertUrl;
url = string.Format(subConvertUrl!, Utils.UrlEncode(url)); url = string.Format(subConvertUrl!, Utils.UrlEncode(url));
if (!url.Contains("target=")) if (!url.Contains("target="))
{ {
@ -457,9 +457,9 @@ namespace ServiceLib.Services
_config = config; _config = config;
_updateFunc = updateFunc; _updateFunc = updateFunc;
var geoUrl = string.IsNullOrEmpty(config?.constItem.geoSourceUrl) var geoUrl = string.IsNullOrEmpty(config?.ConstItem.GeoSourceUrl)
? Global.GeoUrl ? Global.GeoUrl
: config.constItem.geoSourceUrl; : config.ConstItem.GeoSourceUrl;
var fileName = $"{geoName}.dat"; var fileName = $"{geoName}.dat";
var targetPath = Utils.GetBinPath($"{fileName}"); var targetPath = Utils.GetBinPath($"{fileName}");
@ -521,9 +521,9 @@ namespace ServiceLib.Services
private async Task UpdateSrsFile(string type, string srsName, Config config, Action<bool, string> updateFunc) private async Task UpdateSrsFile(string type, string srsName, Config config, Action<bool, string> updateFunc)
{ {
var srsUrl = string.IsNullOrEmpty(_config.constItem.srsSourceUrl) var srsUrl = string.IsNullOrEmpty(_config.ConstItem.SrsSourceUrl)
? Global.SingboxRulesetUrl ? Global.SingboxRulesetUrl
: _config.constItem.srsSourceUrl; : _config.ConstItem.SrsSourceUrl;
var fileName = $"{type}-{srsName}.srs"; var fileName = $"{type}-{srsName}.srs";
var targetPath = Path.Combine(Utils.GetBinPath("srss"), fileName); var targetPath = Path.Combine(Utils.GetBinPath("srss"), fileName);

View file

@ -38,7 +38,7 @@ namespace ServiceLib.ViewModels
await RemoteRestore(); await RemoteRestore();
}); });
SelectedSource = JsonUtils.DeepCopy(_config.webDavItem); SelectedSource = JsonUtils.DeepCopy(_config.WebDavItem);
} }
private void DisplayOperationMsg(string msg = "") private void DisplayOperationMsg(string msg = "")
@ -49,7 +49,7 @@ namespace ServiceLib.ViewModels
private async Task WebDavCheck() private async Task WebDavCheck()
{ {
DisplayOperationMsg(); DisplayOperationMsg();
_config.webDavItem = SelectedSource; _config.WebDavItem = SelectedSource;
await ConfigHandler.SaveConfig(_config); await ConfigHandler.SaveConfig(_config);
var result = await WebDavHandler.Instance.CheckConnection(); var result = await WebDavHandler.Instance.CheckConnection();

View file

@ -28,12 +28,12 @@ namespace ServiceLib.ViewModels
await CheckUpdate(); await CheckUpdate();
}); });
EnableCheckPreReleaseUpdate = _config.guiItem.checkPreReleaseUpdate; EnableCheckPreReleaseUpdate = _config.GuiItem.CheckPreReleaseUpdate;
this.WhenAnyValue( this.WhenAnyValue(
x => x.EnableCheckPreReleaseUpdate, x => x.EnableCheckPreReleaseUpdate,
y => y == true) y => y == true)
.Subscribe(c => { _config.guiItem.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate; }); .Subscribe(c => { _config.GuiItem.CheckPreReleaseUpdate = EnableCheckPreReleaseUpdate; });
RefreshSubItems(); RefreshSubItems();
} }
@ -263,7 +263,7 @@ namespace ServiceLib.ViewModels
} }
else else
{ {
FileManager.ZipExtractToFile(fileName, toPath, _config.guiItem.ignoreGeoUpdateCore ? "geo" : ""); FileManager.ZipExtractToFile(fileName, toPath, _config.GuiItem.IgnoreGeoUpdateCore ? "geo" : "");
} }
if (Utils.IsLinux()) if (Utils.IsLinux())

View file

@ -31,8 +31,8 @@ namespace ServiceLib.ViewModels
{ {
_config = AppHandler.Instance.Config; _config = AppHandler.Instance.Config;
_updateView = updateView; _updateView = updateView;
SortingSelected = _config.clashUIItem.connectionsSorting; SortingSelected = _config.ClashUIItem.ConnectionsSorting;
AutoRefresh = _config.clashUIItem.connectionsAutoRefresh; AutoRefresh = _config.ClashUIItem.ConnectionsAutoRefresh;
var canEditRemove = this.WhenAnyValue( var canEditRemove = this.WhenAnyValue(
x => x.SelectedSource, x => x.SelectedSource,
@ -46,7 +46,7 @@ namespace ServiceLib.ViewModels
this.WhenAnyValue( this.WhenAnyValue(
x => x.AutoRefresh, x => x.AutoRefresh,
y => y == true) y => y == true)
.Subscribe(c => { _config.clashUIItem.connectionsAutoRefresh = AutoRefresh; }); .Subscribe(c => { _config.ClashUIItem.ConnectionsAutoRefresh = AutoRefresh; });
ConnectionCloseCmd = ReactiveCommand.CreateFromTask(async () => ConnectionCloseCmd = ReactiveCommand.CreateFromTask(async () =>
{ {
await ClashConnectionClose(false); await ClashConnectionClose(false);
@ -67,14 +67,14 @@ namespace ServiceLib.ViewModels
Observable.Interval(TimeSpan.FromSeconds(5)) Observable.Interval(TimeSpan.FromSeconds(5))
.Subscribe(async x => .Subscribe(async x =>
{ {
if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.sing_box))) if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box)))
{ {
return; return;
} }
var dtNow = DateTime.Now; var dtNow = DateTime.Now;
if (_config.clashUIItem.connectionsRefreshInterval > 0) if (_config.ClashUIItem.ConnectionsRefreshInterval > 0)
{ {
if ((dtNow - lastTime).Minutes % _config.clashUIItem.connectionsRefreshInterval == 0) if ((dtNow - lastTime).Minutes % _config.ClashUIItem.ConnectionsRefreshInterval == 0)
{ {
await GetClashConnections(); await GetClashConnections();
lastTime = dtNow; lastTime = dtNow;
@ -90,9 +90,9 @@ namespace ServiceLib.ViewModels
{ {
return; return;
} }
if (SortingSelected != _config.clashUIItem.connectionsSorting) if (SortingSelected != _config.ClashUIItem.ConnectionsSorting)
{ {
_config.clashUIItem.connectionsSorting = SortingSelected; _config.ClashUIItem.ConnectionsSorting = SortingSelected;
} }
await GetClashConnections(); await GetClashConnections();

View file

@ -66,9 +66,9 @@ namespace ServiceLib.ViewModels
SelectedGroup = new(); SelectedGroup = new();
SelectedDetail = new(); SelectedDetail = new();
AutoRefresh = _config.clashUIItem.proxiesAutoRefresh; AutoRefresh = _config.ClashUIItem.ProxiesAutoRefresh;
SortingSelected = _config.clashUIItem.proxiesSorting; SortingSelected = _config.ClashUIItem.ProxiesSorting;
RuleModeSelected = (int)_config.clashUIItem.ruleMode; RuleModeSelected = (int)_config.ClashUIItem.RuleMode;
this.WhenAnyValue( this.WhenAnyValue(
x => x.SelectedGroup, x => x.SelectedGroup,
@ -88,7 +88,7 @@ namespace ServiceLib.ViewModels
this.WhenAnyValue( this.WhenAnyValue(
x => x.AutoRefresh, x => x.AutoRefresh,
y => y == true) y => y == true)
.Subscribe(c => { _config.clashUIItem.proxiesAutoRefresh = AutoRefresh; }); .Subscribe(c => { _config.ClashUIItem.ProxiesAutoRefresh = AutoRefresh; });
Init(); Init();
} }
@ -105,7 +105,7 @@ namespace ServiceLib.ViewModels
{ {
return; return;
} }
if (_config.clashUIItem.ruleMode == (ERuleMode)RuleModeSelected) if (_config.ClashUIItem.RuleMode == (ERuleMode)RuleModeSelected)
{ {
return; return;
} }
@ -114,7 +114,7 @@ namespace ServiceLib.ViewModels
public async Task SetRuleModeCheck(ERuleMode mode) public async Task SetRuleModeCheck(ERuleMode mode)
{ {
if (_config.clashUIItem.ruleMode == mode) if (_config.ClashUIItem.RuleMode == mode)
{ {
return; return;
} }
@ -127,9 +127,9 @@ namespace ServiceLib.ViewModels
{ {
return; return;
} }
if (SortingSelected != _config.clashUIItem.proxiesSorting) if (SortingSelected != _config.ClashUIItem.ProxiesSorting)
{ {
_config.clashUIItem.proxiesSorting = SortingSelected; _config.ClashUIItem.ProxiesSorting = SortingSelected;
} }
RefreshProxyDetails(c); RefreshProxyDetails(c);
@ -155,7 +155,7 @@ namespace ServiceLib.ViewModels
private async Task SetRuleMode(ERuleMode mode) private async Task SetRuleMode(ERuleMode mode)
{ {
_config.clashUIItem.ruleMode = mode; _config.ClashUIItem.RuleMode = mode;
if (mode != ERuleMode.Unchanged) if (mode != ERuleMode.Unchanged)
{ {
@ -438,14 +438,14 @@ namespace ServiceLib.ViewModels
Observable.Interval(TimeSpan.FromSeconds(60)) Observable.Interval(TimeSpan.FromSeconds(60))
.Subscribe(async x => .Subscribe(async x =>
{ {
if (!(AutoRefresh && _config.uiItem.showInTaskbar && _config.IsRunningCore(ECoreType.sing_box))) if (!(AutoRefresh && _config.UiItem.ShowInTaskbar && _config.IsRunningCore(ECoreType.sing_box)))
{ {
return; return;
} }
var dtNow = DateTime.Now; var dtNow = DateTime.Now;
if (_config.clashUIItem.proxiesAutoDelayTestInterval > 0) if (_config.ClashUIItem.ProxiesAutoDelayTestInterval > 0)
{ {
if ((dtNow - lastTime).Minutes % _config.clashUIItem.proxiesAutoDelayTestInterval == 0) if ((dtNow - lastTime).Minutes % _config.ClashUIItem.ProxiesAutoDelayTestInterval == 0)
{ {
await ProxiesDelayTest(); await ProxiesDelayTest();
lastTime = dtNow; lastTime = dtNow;

View file

@ -142,11 +142,11 @@ namespace ServiceLib.ViewModels
}); });
SubGroupUpdateCmd = ReactiveCommand.CreateFromTask(async () => SubGroupUpdateCmd = ReactiveCommand.CreateFromTask(async () =>
{ {
await UpdateSubscriptionProcess(_config.subIndexId, false); await UpdateSubscriptionProcess(_config.SubIndexId, false);
}); });
SubGroupUpdateViaProxyCmd = ReactiveCommand.CreateFromTask(async () => SubGroupUpdateViaProxyCmd = ReactiveCommand.CreateFromTask(async () =>
{ {
await UpdateSubscriptionProcess(_config.subIndexId, true); await UpdateSubscriptionProcess(_config.SubIndexId, true);
}); });
//Setting //Setting
@ -204,14 +204,14 @@ namespace ServiceLib.ViewModels
private async Task Init() private async Task Init()
{ {
_config.uiItem.showInTaskbar = true; _config.UiItem.ShowInTaskbar = true;
await ConfigHandler.InitBuiltinRouting(_config); await ConfigHandler.InitBuiltinRouting(_config);
await ConfigHandler.InitBuiltinDNS(_config); await ConfigHandler.InitBuiltinDNS(_config);
CoreHandler.Instance.Init(_config, UpdateHandler); CoreHandler.Instance.Init(_config, UpdateHandler);
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler); TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);
if (_config.guiItem.enableStatistics) if (_config.GuiItem.EnableStatistics)
{ {
await StatisticsHandler.Instance.Init(_config, UpdateStatisticsHandler); await StatisticsHandler.Instance.Init(_config, UpdateStatisticsHandler);
} }
@ -238,13 +238,13 @@ namespace ServiceLib.ViewModels
NoticeHandler.Instance.SendMessageEx(msg); NoticeHandler.Instance.SendMessageEx(msg);
if (success) if (success)
{ {
var indexIdOld = _config.indexId; var indexIdOld = _config.IndexId;
RefreshServers(); RefreshServers();
if (indexIdOld != _config.indexId) if (indexIdOld != _config.IndexId)
{ {
Reload(); Reload();
} }
if (_config.uiItem.enableAutoAdjustMainLvColWidth) if (_config.UiItem.EnableAutoAdjustMainLvColWidth)
{ {
_updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null); _updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null);
} }
@ -253,7 +253,7 @@ namespace ServiceLib.ViewModels
private void UpdateStatisticsHandler(ServerSpeedItem update) private void UpdateStatisticsHandler(ServerSpeedItem update)
{ {
if (!_config.uiItem.showInTaskbar) if (!_config.UiItem.ShowInTaskbar)
{ {
return; return;
} }
@ -351,7 +351,7 @@ namespace ServiceLib.ViewModels
{ {
ProfileItem item = new() ProfileItem item = new()
{ {
subid = _config.subIndexId, subid = _config.SubIndexId,
configType = eConfigType, configType = eConfigType,
isSub = false, isSub = false,
}; };
@ -368,7 +368,7 @@ namespace ServiceLib.ViewModels
if (ret == true) if (ret == true)
{ {
RefreshServers(); RefreshServers();
if (item.indexId == _config.indexId) if (item.indexId == _config.IndexId)
{ {
await Reload(); await Reload();
} }
@ -382,7 +382,7 @@ namespace ServiceLib.ViewModels
await _updateView?.Invoke(EViewAction.AddServerViaClipboard, null); await _updateView?.Invoke(EViewAction.AddServerViaClipboard, null);
return; return;
} }
int ret = await ConfigHandler.AddBatchServers(_config, clipboardData, _config.subIndexId, false); int ret = await ConfigHandler.AddBatchServers(_config, clipboardData, _config.SubIndexId, false);
if (ret > 0) if (ret > 0)
{ {
RefreshSubscriptions(); RefreshSubscriptions();
@ -426,7 +426,7 @@ namespace ServiceLib.ViewModels
} }
else else
{ {
int ret = await ConfigHandler.AddBatchServers(_config, result, _config.subIndexId, false); int ret = await ConfigHandler.AddBatchServers(_config, result, _config.SubIndexId, false);
if (ret > 0) if (ret > 0)
{ {
RefreshSubscriptions(); RefreshSubscriptions();
@ -572,7 +572,7 @@ namespace ServiceLib.ViewModels
private async Task AutoHideStartup() private async Task AutoHideStartup()
{ {
if (_config.uiItem.autoHideStartup) if (_config.UiItem.AutoHideStartup)
{ {
ShowHideWindow(false); ShowHideWindow(false);
} }

View file

@ -23,17 +23,17 @@ namespace ServiceLib.ViewModels
{ {
_config = AppHandler.Instance.Config; _config = AppHandler.Instance.Config;
_updateView = updateView; _updateView = updateView;
MsgFilter = _config.msgUIItem.mainMsgFilter ?? string.Empty; MsgFilter = _config.MsgUIItem.MainMsgFilter ?? string.Empty;
AutoRefresh = _config.msgUIItem.autoRefresh ?? true; AutoRefresh = _config.MsgUIItem.AutoRefresh ?? true;
this.WhenAnyValue( this.WhenAnyValue(
x => x.MsgFilter) x => x.MsgFilter)
.Subscribe(c => _config.msgUIItem.mainMsgFilter = MsgFilter); .Subscribe(c => _config.MsgUIItem.MainMsgFilter = MsgFilter);
this.WhenAnyValue( this.WhenAnyValue(
x => x.AutoRefresh, x => x.AutoRefresh,
y => y == true) y => y == true)
.Subscribe(c => { _config.msgUIItem.autoRefresh = AutoRefresh; }); .Subscribe(c => { _config.MsgUIItem.AutoRefresh = AutoRefresh; });
MessageBus.Current.Listen<string>(EMsgCommand.SendMsgView.ToString()).Subscribe(OnNext); MessageBus.Current.Listen<string>(EMsgCommand.SendMsgView.ToString()).Subscribe(OnNext);
} }
@ -62,7 +62,7 @@ namespace ServiceLib.ViewModels
} }
_blLockShow = true; _blLockShow = true;
if (!_config.uiItem.showInTaskbar) if (!_config.UiItem.ShowInTaskbar)
{ {
await Task.Delay(1000); await Task.Delay(1000);
} }

View file

@ -119,26 +119,26 @@ namespace ServiceLib.ViewModels
{ {
#region Core #region Core
var inbound = _config.inbound[0]; var inbound = _config.Inbound[0];
localPort = inbound.localPort; localPort = inbound.LocalPort;
udpEnabled = inbound.udpEnabled; udpEnabled = inbound.UdpEnabled;
sniffingEnabled = inbound.sniffingEnabled; sniffingEnabled = inbound.SniffingEnabled;
routeOnly = inbound.routeOnly; routeOnly = inbound.RouteOnly;
allowLANConn = inbound.allowLANConn; allowLANConn = inbound.AllowLANConn;
newPort4LAN = inbound.newPort4LAN; newPort4LAN = inbound.NewPort4LAN;
user = inbound.user; user = inbound.User;
pass = inbound.pass; pass = inbound.Pass;
muxEnabled = _config.coreBasicItem.muxEnabled; muxEnabled = _config.CoreBasicItem.MuxEnabled;
logEnabled = _config.coreBasicItem.logEnabled; logEnabled = _config.CoreBasicItem.LogEnabled;
loglevel = _config.coreBasicItem.loglevel; loglevel = _config.CoreBasicItem.Loglevel;
defAllowInsecure = _config.coreBasicItem.defAllowInsecure; defAllowInsecure = _config.CoreBasicItem.DefAllowInsecure;
defFingerprint = _config.coreBasicItem.defFingerprint; defFingerprint = _config.CoreBasicItem.DefFingerprint;
defUserAgent = _config.coreBasicItem.defUserAgent; defUserAgent = _config.CoreBasicItem.DefUserAgent;
mux4SboxProtocol = _config.mux4SboxItem.protocol; mux4SboxProtocol = _config.Mux4SboxItem.Protocol;
enableCacheFile4Sbox = _config.coreBasicItem.enableCacheFile4Sbox; enableCacheFile4Sbox = _config.CoreBasicItem.EnableCacheFile4Sbox;
hyUpMbps = _config.hysteriaItem.up_mbps; hyUpMbps = _config.HysteriaItem.UpMbps;
hyDownMbps = _config.hysteriaItem.down_mbps; hyDownMbps = _config.HysteriaItem.DownMbps;
enableFragment = _config.coreBasicItem.enableFragment; enableFragment = _config.CoreBasicItem.EnableFragment;
#endregion Core #endregion Core
@ -156,47 +156,47 @@ namespace ServiceLib.ViewModels
#region UI #region UI
AutoRun = _config.guiItem.autoRun; AutoRun = _config.GuiItem.AutoRun;
EnableStatistics = _config.guiItem.enableStatistics; EnableStatistics = _config.GuiItem.EnableStatistics;
KeepOlderDedupl = _config.guiItem.keepOlderDedupl; KeepOlderDedupl = _config.GuiItem.KeepOlderDedupl;
IgnoreGeoUpdateCore = _config.guiItem.ignoreGeoUpdateCore; IgnoreGeoUpdateCore = _config.GuiItem.IgnoreGeoUpdateCore;
EnableAutoAdjustMainLvColWidth = _config.uiItem.enableAutoAdjustMainLvColWidth; EnableAutoAdjustMainLvColWidth = _config.UiItem.EnableAutoAdjustMainLvColWidth;
EnableUpdateSubOnlyRemarksExist = _config.uiItem.enableUpdateSubOnlyRemarksExist; EnableUpdateSubOnlyRemarksExist = _config.UiItem.EnableUpdateSubOnlyRemarksExist;
EnableSecurityProtocolTls13 = _config.guiItem.enableSecurityProtocolTls13; EnableSecurityProtocolTls13 = _config.GuiItem.EnableSecurityProtocolTls13;
AutoHideStartup = _config.uiItem.autoHideStartup; AutoHideStartup = _config.UiItem.AutoHideStartup;
EnableCheckPreReleaseUpdate = _config.guiItem.checkPreReleaseUpdate; EnableCheckPreReleaseUpdate = _config.GuiItem.CheckPreReleaseUpdate;
EnableDragDropSort = _config.uiItem.enableDragDropSort; EnableDragDropSort = _config.UiItem.EnableDragDropSort;
DoubleClick2Activate = _config.uiItem.doubleClick2Activate; DoubleClick2Activate = _config.UiItem.DoubleClick2Activate;
AutoUpdateInterval = _config.guiItem.autoUpdateInterval; AutoUpdateInterval = _config.GuiItem.AutoUpdateInterval;
TrayMenuServersLimit = _config.guiItem.trayMenuServersLimit; TrayMenuServersLimit = _config.GuiItem.TrayMenuServersLimit;
CurrentFontFamily = _config.uiItem.currentFontFamily; CurrentFontFamily = _config.UiItem.CurrentFontFamily;
SpeedTestTimeout = _config.speedTestItem.speedTestTimeout; SpeedTestTimeout = _config.SpeedTestItem.SpeedTestTimeout;
SpeedTestUrl = _config.speedTestItem.speedTestUrl; SpeedTestUrl = _config.SpeedTestItem.SpeedTestUrl;
SpeedPingTestUrl = _config.speedTestItem.speedPingTestUrl; SpeedPingTestUrl = _config.SpeedTestItem.SpeedPingTestUrl;
EnableHWA = _config.guiItem.enableHWA; EnableHWA = _config.GuiItem.EnableHWA;
SubConvertUrl = _config.constItem.subConvertUrl; SubConvertUrl = _config.ConstItem.SubConvertUrl;
MainGirdOrientation = (int)_config.uiItem.mainGirdOrientation; MainGirdOrientation = (int)_config.UiItem.MainGirdOrientation;
GeoFileSourceUrl = _config.constItem.geoSourceUrl; GeoFileSourceUrl = _config.ConstItem.GeoSourceUrl;
SrsFileSourceUrl = _config.constItem.srsSourceUrl; SrsFileSourceUrl = _config.ConstItem.SrsSourceUrl;
RoutingRulesSourceUrl = _config.constItem.routeRulesTemplateSourceUrl; RoutingRulesSourceUrl = _config.ConstItem.RouteRulesTemplateSourceUrl;
#endregion UI #endregion UI
#region System proxy #region System proxy
notProxyLocalAddress = _config.systemProxyItem.notProxyLocalAddress; notProxyLocalAddress = _config.SystemProxyItem.NotProxyLocalAddress;
systemProxyAdvancedProtocol = _config.systemProxyItem.systemProxyAdvancedProtocol; systemProxyAdvancedProtocol = _config.SystemProxyItem.SystemProxyAdvancedProtocol;
systemProxyExceptions = _config.systemProxyItem.systemProxyExceptions; systemProxyExceptions = _config.SystemProxyItem.SystemProxyExceptions;
#endregion System proxy #endregion System proxy
#region Tun mode #region Tun mode
TunStrictRoute = _config.tunModeItem.strictRoute; TunStrictRoute = _config.TunModeItem.StrictRoute;
TunStack = _config.tunModeItem.stack; TunStack = _config.TunModeItem.Stack;
TunMtu = _config.tunModeItem.mtu; TunMtu = _config.TunModeItem.Mtu;
TunEnableExInbound = _config.tunModeItem.enableExInbound; TunEnableExInbound = _config.TunModeItem.EnableExInbound;
TunEnableIPv6Address = _config.tunModeItem.enableIPv6Address; TunEnableIPv6Address = _config.TunModeItem.EnableIPv6Address;
#endregion Tun mode #endregion Tun mode
@ -205,28 +205,28 @@ namespace ServiceLib.ViewModels
private async Task InitCoreType() private async Task InitCoreType()
{ {
if (_config.coreTypeItem == null) if (_config.CoreTypeItem == null)
{ {
_config.coreTypeItem = new List<CoreTypeItem>(); _config.CoreTypeItem = new List<CoreTypeItem>();
} }
foreach (EConfigType it in Enum.GetValues(typeof(EConfigType))) foreach (EConfigType it in Enum.GetValues(typeof(EConfigType)))
{ {
if (_config.coreTypeItem.FindIndex(t => t.configType == it) >= 0) if (_config.CoreTypeItem.FindIndex(t => t.ConfigType == it) >= 0)
{ {
continue; continue;
} }
_config.coreTypeItem.Add(new CoreTypeItem() _config.CoreTypeItem.Add(new CoreTypeItem()
{ {
configType = it, ConfigType = it,
coreType = ECoreType.Xray CoreType = ECoreType.Xray
}); });
} }
_config.coreTypeItem.ForEach(it => _config.CoreTypeItem.ForEach(it =>
{ {
var type = it.coreType.ToString(); var type = it.CoreType.ToString();
switch ((int)it.configType) switch ((int)it.ConfigType)
{ {
case 1: case 1:
CoreType1 = type; CoreType1 = type;
@ -263,11 +263,11 @@ namespace ServiceLib.ViewModels
NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort); NoticeHandler.Instance.Enqueue(ResUI.FillLocalListeningPort);
return; return;
} }
var needReboot = (EnableStatistics != _config.guiItem.enableStatistics var needReboot = (EnableStatistics != _config.GuiItem.EnableStatistics
|| EnableDragDropSort != _config.uiItem.enableDragDropSort || EnableDragDropSort != _config.UiItem.EnableDragDropSort
|| EnableHWA != _config.guiItem.enableHWA || EnableHWA != _config.GuiItem.EnableHWA
|| CurrentFontFamily != _config.uiItem.currentFontFamily || CurrentFontFamily != _config.UiItem.CurrentFontFamily
|| MainGirdOrientation != (int)_config.uiItem.mainGirdOrientation); || MainGirdOrientation != (int)_config.UiItem.MainGirdOrientation);
//if (Utile.IsNullOrEmpty(Kcpmtu.ToString()) || !Utile.IsNumeric(Kcpmtu.ToString()) //if (Utile.IsNullOrEmpty(Kcpmtu.ToString()) || !Utile.IsNumeric(Kcpmtu.ToString())
// || Utile.IsNullOrEmpty(Kcptti.ToString()) || !Utile.IsNumeric(Kcptti.ToString()) // || Utile.IsNullOrEmpty(Kcptti.ToString()) || !Utile.IsNumeric(Kcptti.ToString())
@ -281,66 +281,66 @@ namespace ServiceLib.ViewModels
//} //}
//Core //Core
_config.inbound[0].localPort = localPort; _config.Inbound[0].LocalPort = localPort;
_config.inbound[0].udpEnabled = udpEnabled; _config.Inbound[0].UdpEnabled = udpEnabled;
_config.inbound[0].sniffingEnabled = sniffingEnabled; _config.Inbound[0].SniffingEnabled = sniffingEnabled;
_config.inbound[0].destOverride = destOverride?.ToList(); _config.Inbound[0].DestOverride = destOverride?.ToList();
_config.inbound[0].routeOnly = routeOnly; _config.Inbound[0].RouteOnly = routeOnly;
_config.inbound[0].allowLANConn = allowLANConn; _config.Inbound[0].AllowLANConn = allowLANConn;
_config.inbound[0].newPort4LAN = newPort4LAN; _config.Inbound[0].NewPort4LAN = newPort4LAN;
_config.inbound[0].user = user; _config.Inbound[0].User = user;
_config.inbound[0].pass = pass; _config.Inbound[0].Pass = pass;
if (_config.inbound.Count > 1) if (_config.Inbound.Count > 1)
{ {
_config.inbound.RemoveAt(1); _config.Inbound.RemoveAt(1);
} }
_config.coreBasicItem.logEnabled = logEnabled; _config.CoreBasicItem.LogEnabled = logEnabled;
_config.coreBasicItem.loglevel = loglevel; _config.CoreBasicItem.Loglevel = loglevel;
_config.coreBasicItem.muxEnabled = muxEnabled; _config.CoreBasicItem.MuxEnabled = muxEnabled;
_config.coreBasicItem.defAllowInsecure = defAllowInsecure; _config.CoreBasicItem.DefAllowInsecure = defAllowInsecure;
_config.coreBasicItem.defFingerprint = defFingerprint; _config.CoreBasicItem.DefFingerprint = defFingerprint;
_config.coreBasicItem.defUserAgent = defUserAgent; _config.CoreBasicItem.DefUserAgent = defUserAgent;
_config.mux4SboxItem.protocol = mux4SboxProtocol; _config.Mux4SboxItem.Protocol = mux4SboxProtocol;
_config.coreBasicItem.enableCacheFile4Sbox = enableCacheFile4Sbox; _config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox;
_config.hysteriaItem.up_mbps = hyUpMbps; _config.HysteriaItem.UpMbps = hyUpMbps;
_config.hysteriaItem.down_mbps = hyDownMbps; _config.HysteriaItem.DownMbps = hyDownMbps;
_config.coreBasicItem.enableFragment = enableFragment; _config.CoreBasicItem.EnableFragment = enableFragment;
_config.guiItem.autoRun = AutoRun; _config.GuiItem.AutoRun = AutoRun;
_config.guiItem.enableStatistics = EnableStatistics; _config.GuiItem.EnableStatistics = EnableStatistics;
_config.guiItem.keepOlderDedupl = KeepOlderDedupl; _config.GuiItem.KeepOlderDedupl = KeepOlderDedupl;
_config.guiItem.ignoreGeoUpdateCore = IgnoreGeoUpdateCore; _config.GuiItem.IgnoreGeoUpdateCore = IgnoreGeoUpdateCore;
_config.uiItem.enableAutoAdjustMainLvColWidth = EnableAutoAdjustMainLvColWidth; _config.UiItem.EnableAutoAdjustMainLvColWidth = EnableAutoAdjustMainLvColWidth;
_config.uiItem.enableUpdateSubOnlyRemarksExist = EnableUpdateSubOnlyRemarksExist; _config.UiItem.EnableUpdateSubOnlyRemarksExist = EnableUpdateSubOnlyRemarksExist;
_config.guiItem.enableSecurityProtocolTls13 = EnableSecurityProtocolTls13; _config.GuiItem.EnableSecurityProtocolTls13 = EnableSecurityProtocolTls13;
_config.uiItem.autoHideStartup = AutoHideStartup; _config.UiItem.AutoHideStartup = AutoHideStartup;
_config.guiItem.autoUpdateInterval = AutoUpdateInterval; _config.GuiItem.AutoUpdateInterval = AutoUpdateInterval;
_config.guiItem.checkPreReleaseUpdate = EnableCheckPreReleaseUpdate; _config.GuiItem.CheckPreReleaseUpdate = EnableCheckPreReleaseUpdate;
_config.uiItem.enableDragDropSort = EnableDragDropSort; _config.UiItem.EnableDragDropSort = EnableDragDropSort;
_config.uiItem.doubleClick2Activate = DoubleClick2Activate; _config.UiItem.DoubleClick2Activate = DoubleClick2Activate;
_config.guiItem.trayMenuServersLimit = TrayMenuServersLimit; _config.GuiItem.TrayMenuServersLimit = TrayMenuServersLimit;
_config.uiItem.currentFontFamily = CurrentFontFamily; _config.UiItem.CurrentFontFamily = CurrentFontFamily;
_config.speedTestItem.speedTestTimeout = SpeedTestTimeout; _config.SpeedTestItem.SpeedTestTimeout = SpeedTestTimeout;
_config.speedTestItem.speedTestUrl = SpeedTestUrl; _config.SpeedTestItem.SpeedTestUrl = SpeedTestUrl;
_config.speedTestItem.speedPingTestUrl = SpeedPingTestUrl; _config.SpeedTestItem.SpeedPingTestUrl = SpeedPingTestUrl;
_config.guiItem.enableHWA = EnableHWA; _config.GuiItem.EnableHWA = EnableHWA;
_config.constItem.subConvertUrl = SubConvertUrl; _config.ConstItem.SubConvertUrl = SubConvertUrl;
_config.uiItem.mainGirdOrientation = (EGirdOrientation)MainGirdOrientation; _config.UiItem.MainGirdOrientation = (EGirdOrientation)MainGirdOrientation;
_config.constItem.geoSourceUrl = GeoFileSourceUrl; _config.ConstItem.GeoSourceUrl = GeoFileSourceUrl;
_config.constItem.srsSourceUrl = SrsFileSourceUrl; _config.ConstItem.SrsSourceUrl = SrsFileSourceUrl;
_config.constItem.routeRulesTemplateSourceUrl = RoutingRulesSourceUrl; _config.ConstItem.RouteRulesTemplateSourceUrl = RoutingRulesSourceUrl;
//systemProxy //systemProxy
_config.systemProxyItem.systemProxyExceptions = systemProxyExceptions; _config.SystemProxyItem.SystemProxyExceptions = systemProxyExceptions;
_config.systemProxyItem.notProxyLocalAddress = notProxyLocalAddress; _config.SystemProxyItem.NotProxyLocalAddress = notProxyLocalAddress;
_config.systemProxyItem.systemProxyAdvancedProtocol = systemProxyAdvancedProtocol; _config.SystemProxyItem.SystemProxyAdvancedProtocol = systemProxyAdvancedProtocol;
//tun mode //tun mode
_config.tunModeItem.strictRoute = TunStrictRoute; _config.TunModeItem.StrictRoute = TunStrictRoute;
_config.tunModeItem.stack = TunStack; _config.TunModeItem.Stack = TunStack;
_config.tunModeItem.mtu = TunMtu; _config.TunModeItem.Mtu = TunMtu;
_config.tunModeItem.enableExInbound = TunEnableExInbound; _config.TunModeItem.EnableExInbound = TunEnableExInbound;
_config.tunModeItem.enableIPv6Address = TunEnableIPv6Address; _config.TunModeItem.EnableIPv6Address = TunEnableIPv6Address;
//coreType //coreType
await SaveCoreType(); await SaveCoreType();
@ -365,11 +365,11 @@ namespace ServiceLib.ViewModels
private async Task SaveCoreType() private async Task SaveCoreType()
{ {
for (int k = 1; k <= _config.coreTypeItem.Count; k++) for (int k = 1; k <= _config.CoreTypeItem.Count; k++)
{ {
var item = _config.coreTypeItem[k - 1]; var item = _config.CoreTypeItem[k - 1];
var type = string.Empty; var type = string.Empty;
switch ((int)item.configType) switch ((int)item.ConfigType)
{ {
case 1: case 1:
type = CoreType1; type = CoreType1;
@ -398,7 +398,7 @@ namespace ServiceLib.ViewModels
default: default:
continue; continue;
} }
item.coreType = (ECoreType)Enum.Parse(typeof(ECoreType), type); item.CoreType = (ECoreType)Enum.Parse(typeof(ECoreType), type);
} }
} }
} }

View file

@ -107,7 +107,7 @@ namespace ServiceLib.ViewModels
this.WhenAnyValue( this.WhenAnyValue(
x => x.SelectedSub, x => x.SelectedSub,
y => y != null && !y.remarks.IsNullOrEmpty() && _config.subIndexId != y.id) y => y != null && !y.remarks.IsNullOrEmpty() && _config.SubIndexId != y.id)
.Subscribe(async c => await SubSelectedChangedAsync(c)); .Subscribe(async c => await SubSelectedChangedAsync(c));
this.WhenAnyValue( this.WhenAnyValue(
x => x.SelectedMoveToGroup, x => x.SelectedMoveToGroup,
@ -334,7 +334,7 @@ namespace ServiceLib.ViewModels
{ {
return; return;
} }
_config.subIndexId = SelectedSub?.id; _config.SubIndexId = SelectedSub?.id;
RefreshServers(); RefreshServers();
@ -361,14 +361,14 @@ namespace ServiceLib.ViewModels
public async Task RefreshServersBiz() public async Task RefreshServersBiz()
{ {
var lstModel = await AppHandler.Instance.ProfileItemsEx(_config.subIndexId, _serverFilter); var lstModel = await AppHandler.Instance.ProfileItemsEx(_config.SubIndexId, _serverFilter);
_lstProfile = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(lstModel)) ?? []; _lstProfile = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(lstModel)) ?? [];
_profileItems.Clear(); _profileItems.Clear();
_profileItems.AddRange(lstModel); _profileItems.AddRange(lstModel);
if (lstModel.Count > 0) if (lstModel.Count > 0)
{ {
var selected = lstModel.FirstOrDefault(t => t.indexId == _config.indexId); var selected = lstModel.FirstOrDefault(t => t.indexId == _config.IndexId);
if (selected != null) if (selected != null)
{ {
SelectedProfile = selected; SelectedProfile = selected;
@ -390,9 +390,9 @@ namespace ServiceLib.ViewModels
{ {
_subItems.Add(item); _subItems.Add(item);
} }
if (_config.subIndexId != null && _subItems.FirstOrDefault(t => t.id == _config.subIndexId) != null) if (_config.SubIndexId != null && _subItems.FirstOrDefault(t => t.id == _config.SubIndexId) != null)
{ {
SelectedSub = _subItems.FirstOrDefault(t => t.id == _config.subIndexId); SelectedSub = _subItems.FirstOrDefault(t => t.id == _config.SubIndexId);
} }
else else
{ {
@ -458,7 +458,7 @@ namespace ServiceLib.ViewModels
if (ret == true) if (ret == true)
{ {
RefreshServers(); RefreshServers();
if (item.indexId == _config.indexId) if (item.indexId == _config.IndexId)
{ {
Reload(); Reload();
} }
@ -476,7 +476,7 @@ namespace ServiceLib.ViewModels
{ {
return; return;
} }
var exists = lstSelecteds.Exists(t => t.indexId == _config.indexId); var exists = lstSelecteds.Exists(t => t.indexId == _config.IndexId);
await ConfigHandler.RemoveServer(_config, lstSelecteds); await ConfigHandler.RemoveServer(_config, lstSelecteds);
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
@ -490,7 +490,7 @@ namespace ServiceLib.ViewModels
private async Task RemoveDuplicateServer() private async Task RemoveDuplicateServer()
{ {
var tuple = await ConfigHandler.DedupServerList(_config, _config.subIndexId); var tuple = await ConfigHandler.DedupServerList(_config, _config.SubIndexId);
RefreshServers(); RefreshServers();
Reload(); Reload();
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2)); NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
@ -525,7 +525,7 @@ namespace ServiceLib.ViewModels
{ {
return; return;
} }
if (indexId == _config.indexId) if (indexId == _config.IndexId)
{ {
return; return;
} }
@ -591,7 +591,7 @@ namespace ServiceLib.ViewModels
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed); NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
return; return;
} }
if (ret?.Data?.ToString() == _config.indexId) if (ret?.Data?.ToString() == _config.IndexId)
{ {
RefreshServers(); RefreshServers();
Reload(); Reload();
@ -611,7 +611,7 @@ namespace ServiceLib.ViewModels
_dicHeaderSort.TryAdd(colName, true); _dicHeaderSort.TryAdd(colName, true);
_dicHeaderSort.TryGetValue(colName, out bool asc); _dicHeaderSort.TryGetValue(colName, out bool asc);
if (await ConfigHandler.SortServers(_config, _config.subIndexId, colName, asc) != 0) if (await ConfigHandler.SortServers(_config, _config.SubIndexId, colName, asc) != 0)
{ {
return; return;
} }
@ -784,7 +784,7 @@ namespace ServiceLib.ViewModels
} }
else else
{ {
item = await AppHandler.Instance.GetSubItem(_config.subIndexId); item = await AppHandler.Instance.GetSubItem(_config.SubIndexId);
if (item is null) if (item is null)
{ {
return; return;

View file

@ -111,10 +111,10 @@ namespace ServiceLib.ViewModels
{ {
SelectedSource = new(); SelectedSource = new();
enableRoutingAdvanced = _config.routingBasicItem.enableRoutingAdvanced; enableRoutingAdvanced = _config.RoutingBasicItem.EnableRoutingAdvanced;
domainStrategy = _config.routingBasicItem.domainStrategy; domainStrategy = _config.RoutingBasicItem.DomainStrategy;
domainMatcher = _config.routingBasicItem.domainMatcher; domainMatcher = _config.RoutingBasicItem.DomainMatcher;
domainStrategy4Singbox = _config.routingBasicItem.domainStrategy4Singbox; domainStrategy4Singbox = _config.RoutingBasicItem.DomainStrategy4Singbox;
await ConfigHandler.InitBuiltinRouting(_config); await ConfigHandler.InitBuiltinRouting(_config);
await RefreshRoutingItems(); await RefreshRoutingItems();
@ -182,7 +182,7 @@ namespace ServiceLib.ViewModels
foreach (var item in routings) foreach (var item in routings)
{ {
bool def = false; bool def = false;
if (item.id == _config.routingBasicItem.routingIndexId) if (item.id == _config.RoutingBasicItem.RoutingIndexId)
{ {
def = true; def = true;
} }
@ -204,10 +204,10 @@ namespace ServiceLib.ViewModels
private async Task SaveRoutingAsync() private async Task SaveRoutingAsync()
{ {
_config.routingBasicItem.domainStrategy = domainStrategy; _config.RoutingBasicItem.DomainStrategy = domainStrategy;
_config.routingBasicItem.enableRoutingAdvanced = enableRoutingAdvanced; _config.RoutingBasicItem.EnableRoutingAdvanced = enableRoutingAdvanced;
_config.routingBasicItem.domainMatcher = domainMatcher; _config.RoutingBasicItem.DomainMatcher = domainMatcher;
_config.routingBasicItem.domainStrategy4Singbox = domainStrategy4Singbox; _config.RoutingBasicItem.DomainStrategy4Singbox = domainStrategy4Singbox;
await EndBindingLockedData(); await EndBindingLockedData();

View file

@ -117,7 +117,7 @@ namespace ServiceLib.ViewModels
y => y != null && !y.Text.IsNullOrEmpty()) y => y != null && !y.Text.IsNullOrEmpty())
.Subscribe(c => ServerSelectedChanged(c)); .Subscribe(c => ServerSelectedChanged(c));
SystemProxySelected = (int)_config.systemProxyItem.sysProxyType; SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType;
this.WhenAnyValue( this.WhenAnyValue(
x => x.SystemProxySelected, x => x.SystemProxySelected,
y => y >= 0) y => y >= 0)
@ -182,18 +182,18 @@ namespace ServiceLib.ViewModels
SelectedRouting = new(); SelectedRouting = new();
SelectedServer = new(); SelectedServer = new();
if (_config.tunModeItem.enableTun && AppHandler.Instance.IsAdministrator) if (_config.TunModeItem.EnableTun && AppHandler.Instance.IsAdministrator)
{ {
EnableTun = true; EnableTun = true;
} }
else else
{ {
_config.tunModeItem.enableTun = EnableTun = false; _config.TunModeItem.EnableTun = EnableTun = false;
} }
await RefreshRoutingsMenu(); await RefreshRoutingsMenu();
await InboundDisplayStatus(); await InboundDisplayStatus();
await ChangeSystemProxyAsync(_config.systemProxyItem.sysProxyType, true); await ChangeSystemProxyAsync(_config.SystemProxyItem.SysProxyType, true);
} }
public void InitUpdateView(Func<EViewAction, object?, Task<bool>>? updateView) public void InitUpdateView(Func<EViewAction, object?, Task<bool>>? updateView)
@ -248,10 +248,10 @@ namespace ServiceLib.ViewModels
private async Task RefreshServersMenu() private async Task RefreshServersMenu()
{ {
var lstModel = await AppHandler.Instance.ProfileItems(_config.subIndexId, ""); var lstModel = await AppHandler.Instance.ProfileItems(_config.SubIndexId, "");
_servers.Clear(); _servers.Clear();
if (lstModel.Count > _config.guiItem.trayMenuServersLimit) if (lstModel.Count > _config.GuiItem.TrayMenuServersLimit)
{ {
BlServers = false; BlServers = false;
return; return;
@ -265,7 +265,7 @@ namespace ServiceLib.ViewModels
var item = new ComboItem() { ID = it.indexId, Text = name }; var item = new ComboItem() { ID = it.indexId, Text = name };
_servers.Add(item); _servers.Add(item);
if (_config.indexId == it.indexId) if (_config.IndexId == it.indexId)
{ {
SelectedServer = item; SelectedServer = item;
} }
@ -312,15 +312,15 @@ namespace ServiceLib.ViewModels
public async Task SetListenerType(ESysProxyType type) public async Task SetListenerType(ESysProxyType type)
{ {
if (_config.systemProxyItem.sysProxyType == type) if (_config.SystemProxyItem.SysProxyType == type)
{ {
return; return;
} }
_config.systemProxyItem.sysProxyType = type; _config.SystemProxyItem.SysProxyType = type;
await ChangeSystemProxyAsync(type, true); await ChangeSystemProxyAsync(type, true);
NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}"); NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.SystemProxyItem.SysProxyType.ToString()}");
SystemProxySelected = (int)_config.systemProxyItem.sysProxyType; SystemProxySelected = (int)_config.SystemProxyItem.SysProxyType;
await ConfigHandler.SaveConfig(_config, false); await ConfigHandler.SaveConfig(_config, false);
} }
@ -347,7 +347,7 @@ namespace ServiceLib.ViewModels
public async Task RefreshRoutingsMenu() public async Task RefreshRoutingsMenu()
{ {
_routingItems.Clear(); _routingItems.Clear();
if (!_config.routingBasicItem.enableRoutingAdvanced) if (!_config.RoutingBasicItem.EnableRoutingAdvanced)
{ {
BlRouting = false; BlRouting = false;
return; return;
@ -358,7 +358,7 @@ namespace ServiceLib.ViewModels
foreach (var item in routings) foreach (var item in routings)
{ {
_routingItems.Add(item); _routingItems.Add(item);
if (item.id == _config.routingBasicItem.routingIndexId) if (item.id == _config.RoutingBasicItem.RoutingIndexId)
{ {
SelectedRouting = item; SelectedRouting = item;
} }
@ -382,7 +382,7 @@ namespace ServiceLib.ViewModels
{ {
return; return;
} }
if (_config.routingBasicItem.routingIndexId == item.id) if (_config.RoutingBasicItem.RoutingIndexId == item.id)
{ {
return; return;
} }
@ -401,7 +401,7 @@ namespace ServiceLib.ViewModels
{ {
return; return;
} }
if (_config.systemProxyItem.sysProxyType == (ESysProxyType)SystemProxySelected) if (_config.SystemProxyItem.SysProxyType == (ESysProxyType)SystemProxySelected)
{ {
return; return;
} }
@ -410,13 +410,13 @@ namespace ServiceLib.ViewModels
private async Task DoEnableTun(bool c) private async Task DoEnableTun(bool c)
{ {
if (_config.tunModeItem.enableTun != EnableTun) if (_config.TunModeItem.EnableTun != EnableTun)
{ {
_config.tunModeItem.enableTun = EnableTun; _config.TunModeItem.EnableTun = EnableTun;
// When running as a non-administrator, reboot to administrator mode // When running as a non-administrator, reboot to administrator mode
if (EnableTun && !AppHandler.Instance.IsAdministrator) if (EnableTun && !AppHandler.Instance.IsAdministrator)
{ {
_config.tunModeItem.enableTun = false; _config.TunModeItem.EnableTun = false;
Locator.Current.GetService<MainWindowViewModel>()?.RebootAsAdmin(); Locator.Current.GetService<MainWindowViewModel>()?.RebootAsAdmin();
return; return;
} }
@ -437,9 +437,9 @@ namespace ServiceLib.ViewModels
sb.Append($"[{EInboundProtocol.http}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.http)}]"); sb.Append($"[{EInboundProtocol.http}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.http)}]");
InboundDisplay = $"{ResUI.LabLocal}:{sb}"; InboundDisplay = $"{ResUI.LabLocal}:{sb}";
if (_config.inbound[0].allowLANConn) if (_config.Inbound[0].AllowLANConn)
{ {
if (_config.inbound[0].newPort4LAN) if (_config.Inbound[0].NewPort4LAN)
{ {
StringBuilder sb2 = new(); StringBuilder sb2 = new();
sb2.Append($"[{EInboundProtocol.socks}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks2)}]"); sb2.Append($"[{EInboundProtocol.socks}:{AppHandler.Instance.GetLocalPort(EInboundProtocol.socks2)}]");

View file

@ -28,21 +28,21 @@ namespace v2rayN.Desktop.ViewModels
private void RestoreUI() private void RestoreUI()
{ {
ModifyTheme(_config.uiItem.colorModeDark); ModifyTheme(_config.UiItem.ColorModeDark);
} }
private void BindingUI() private void BindingUI()
{ {
ColorModeDark = _config.uiItem.colorModeDark; ColorModeDark = _config.UiItem.ColorModeDark;
CurrentFontSize = _config.uiItem.currentFontSize; CurrentFontSize = _config.UiItem.CurrentFontSize;
CurrentLanguage = _config.uiItem.currentLanguage; CurrentLanguage = _config.UiItem.CurrentLanguage;
this.WhenAnyValue(x => x.ColorModeDark) this.WhenAnyValue(x => x.ColorModeDark)
.Subscribe(c => .Subscribe(c =>
{ {
if (_config.uiItem.colorModeDark != ColorModeDark) if (_config.UiItem.ColorModeDark != ColorModeDark)
{ {
_config.uiItem.colorModeDark = ColorModeDark; _config.UiItem.ColorModeDark = ColorModeDark;
ModifyTheme(ColorModeDark); ModifyTheme(ColorModeDark);
ConfigHandler.SaveConfig(_config); ConfigHandler.SaveConfig(_config);
} }
@ -55,7 +55,7 @@ namespace v2rayN.Desktop.ViewModels
{ {
if (CurrentFontSize >= Global.MinFontSize) if (CurrentFontSize >= Global.MinFontSize)
{ {
_config.uiItem.currentFontSize = CurrentFontSize; _config.UiItem.CurrentFontSize = CurrentFontSize;
double size = CurrentFontSize; double size = CurrentFontSize;
ModifyFontSize(size); ModifyFontSize(size);
@ -68,9 +68,9 @@ namespace v2rayN.Desktop.ViewModels
y => y != null && !y.IsNullOrEmpty()) y => y != null && !y.IsNullOrEmpty())
.Subscribe(c => .Subscribe(c =>
{ {
if (Utils.IsNotEmpty(CurrentLanguage) && _config.uiItem.currentLanguage != CurrentLanguage) if (Utils.IsNotEmpty(CurrentLanguage) && _config.UiItem.CurrentLanguage != CurrentLanguage)
{ {
_config.uiItem.currentLanguage = CurrentLanguage; _config.UiItem.CurrentLanguage = CurrentLanguage;
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
ConfigHandler.SaveConfig(_config); ConfigHandler.SaveConfig(_config);
NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips); NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips);

View file

@ -25,10 +25,10 @@ namespace v2rayN.Desktop.Views
{ {
this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.url, v => v.txtWebDavUrl.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Url, v => v.txtWebDavUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.userName, v => v.txtWebDavUserName.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.UserName, v => v.txtWebDavUserName.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.password, v => v.txtWebDavPassword.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtWebDavPassword.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.dirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.DirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.WebDavCheckCmd, v => v.menuWebDavCheck).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.WebDavCheckCmd, v => v.menuWebDavCheck).DisposeWith(disposables);

View file

@ -83,7 +83,7 @@ namespace v2rayN.Desktop.Views
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
switch (_config.uiItem.mainGirdOrientation) switch (_config.UiItem.MainGirdOrientation)
{ {
case EGirdOrientation.Horizontal: case EGirdOrientation.Horizontal:
gridMain.IsVisible = true; gridMain.IsVisible = true;
@ -124,7 +124,7 @@ namespace v2rayN.Desktop.Views
} }
menuAddServerViaScan.IsVisible = false; menuAddServerViaScan.IsVisible = false;
switch (_config.uiItem.mainGirdOrientation) switch (_config.UiItem.MainGirdOrientation)
{ {
case EGirdOrientation.Horizontal: case EGirdOrientation.Horizontal:
tabProfiles.Content ??= new ProfilesView(this); tabProfiles.Content ??= new ProfilesView(this);
@ -360,7 +360,7 @@ namespace v2rayN.Desktop.Views
public void ShowHideWindow(bool? blShow) public void ShowHideWindow(bool? blShow)
{ {
var bl = blShow ?? !_config.uiItem.showInTaskbar; var bl = blShow ?? !_config.UiItem.ShowInTaskbar;
if (bl) if (bl)
{ {
this.Show(); this.Show();
@ -375,46 +375,46 @@ namespace v2rayN.Desktop.Views
{ {
this.Hide(); this.Hide();
} }
_config.uiItem.showInTaskbar = bl; _config.UiItem.ShowInTaskbar = bl;
} }
private void RestoreUI() private void RestoreUI()
{ {
if (_config.uiItem.mainWidth > 0 && _config.uiItem.mainHeight > 0) if (_config.UiItem.MainWidth > 0 && _config.UiItem.MainHeight > 0)
{ {
Width = _config.uiItem.mainWidth; Width = _config.UiItem.MainWidth;
Height = _config.uiItem.mainHeight; Height = _config.UiItem.MainHeight;
} }
if (_config.uiItem.mainGirdHeight1 > 0 && _config.uiItem.mainGirdHeight2 > 0) if (_config.UiItem.MainGirdHeight1 > 0 && _config.UiItem.MainGirdHeight2 > 0)
{ {
if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal)
{ {
gridMain.ColumnDefinitions[0].Width = new GridLength(_config.uiItem.mainGirdHeight1, GridUnitType.Star); gridMain.ColumnDefinitions[0].Width = new GridLength(_config.UiItem.MainGirdHeight1, GridUnitType.Star);
gridMain.ColumnDefinitions[2].Width = new GridLength(_config.uiItem.mainGirdHeight2, GridUnitType.Star); gridMain.ColumnDefinitions[2].Width = new GridLength(_config.UiItem.MainGirdHeight2, GridUnitType.Star);
} }
else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical)
{ {
gridMain1.RowDefinitions[0].Height = new GridLength(_config.uiItem.mainGirdHeight1, GridUnitType.Star); gridMain1.RowDefinitions[0].Height = new GridLength(_config.UiItem.MainGirdHeight1, GridUnitType.Star);
gridMain1.RowDefinitions[2].Height = new GridLength(_config.uiItem.mainGirdHeight2, GridUnitType.Star); gridMain1.RowDefinitions[2].Height = new GridLength(_config.UiItem.MainGirdHeight2, GridUnitType.Star);
} }
} }
} }
private void StorageUI() private void StorageUI()
{ {
_config.uiItem.mainWidth = Utils.ToInt(this.Width); _config.UiItem.MainWidth = Utils.ToInt(this.Width);
_config.uiItem.mainHeight = Utils.ToInt(this.Height); _config.UiItem.MainHeight = Utils.ToInt(this.Height);
if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal)
{ {
_config.uiItem.mainGirdHeight1 = Math.Ceiling(gridMain.ColumnDefinitions[0].ActualWidth + 0.1); _config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain.ColumnDefinitions[0].ActualWidth + 0.1);
_config.uiItem.mainGirdHeight2 = Math.Ceiling(gridMain.ColumnDefinitions[2].ActualWidth + 0.1); _config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain.ColumnDefinitions[2].ActualWidth + 0.1);
} }
else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical)
{ {
_config.uiItem.mainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1); _config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1);
_config.uiItem.mainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1); _config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1);
} }
ConfigHandler.SaveConfig(_config); ConfigHandler.SaveConfig(_config);
} }

View file

@ -24,7 +24,7 @@ namespace v2rayN.Desktop.Views
{ {
clbdestOverride.Items.Add(it); clbdestOverride.Items.Add(it);
}); });
_config.inbound[0].destOverride?.ForEach(it => _config.Inbound[0].DestOverride?.ForEach(it =>
{ {
clbdestOverride.SelectedItems.Add(it); clbdestOverride.SelectedItems.Add(it);
}); });

View file

@ -189,7 +189,7 @@ namespace v2rayN.Desktop.Views
private void LstProfiles_DoubleTapped(object? sender, Avalonia.Input.TappedEventArgs e) private void LstProfiles_DoubleTapped(object? sender, Avalonia.Input.TappedEventArgs e)
{ {
if (_config.uiItem.doubleClick2Activate) if (_config.UiItem.DoubleClick2Activate)
{ {
ViewModel?.SetDefaultServer(); ViewModel?.SetDefaultServer();
} }
@ -325,7 +325,7 @@ namespace v2rayN.Desktop.Views
private void RestoreUI() private void RestoreUI()
{ {
var lvColumnItem = _config.uiItem.mainColumnItem.OrderBy(t => t.Index).ToList(); var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList();
var displayIndex = 0; var displayIndex = 0;
foreach (var item in lvColumnItem) foreach (var item in lvColumnItem)
{ {
@ -348,7 +348,7 @@ namespace v2rayN.Desktop.Views
} }
if (item.Name.StartsWith("to")) if (item.Name.StartsWith("to"))
{ {
if (!_config.guiItem.enableStatistics) if (!_config.GuiItem.EnableStatistics)
{ {
item2.IsVisible = false; item2.IsVisible = false;
} }
@ -375,7 +375,7 @@ namespace v2rayN.Desktop.Views
Index = item2.DisplayIndex Index = item2.DisplayIndex
}); });
} }
_config.uiItem.mainColumnItem = lvColumnItem; _config.UiItem.MainColumnItem = lvColumnItem;
ConfigHandler.SaveConfig(_config); ConfigHandler.SaveConfig(_config);
} }

View file

@ -76,7 +76,7 @@ namespace v2rayN.Desktop.Views
{ {
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{ {
desktop.MainWindow.Icon = AvaUtils.GetAppIcon(_config.systemProxyItem.sysProxyType); desktop.MainWindow.Icon = AvaUtils.GetAppIcon(_config.SystemProxyItem.SysProxyType);
} }
} }

View file

@ -10,7 +10,7 @@ namespace v2rayN.Converters
{ {
try try
{ {
var fontFamily = AppHandler.Instance.Config.uiItem.currentFontFamily; var fontFamily = AppHandler.Instance.Config.UiItem.CurrentFontFamily;
if (Utils.IsNotEmpty(fontFamily)) if (Utils.IsNotEmpty(fontFamily))
{ {
var fontPath = Utils.GetFontsPath(); var fontPath = Utils.GetFontsPath();

View file

@ -37,8 +37,8 @@ namespace v2rayN.Handler
private void Init() private void Init()
{ {
_hotkeyTriggerDic.Clear(); _hotkeyTriggerDic.Clear();
if (_config.globalHotkeys == null) return; if (_config.GlobalHotkeys == null) return;
foreach (var item in _config.globalHotkeys) foreach (var item in _config.GlobalHotkeys)
{ {
if (item.KeyCode != null && (Key)item.KeyCode != Key.None) if (item.KeyCode != null && (Key)item.KeyCode != Key.None)
{ {
@ -50,12 +50,12 @@ namespace v2rayN.Handler
key = (key << 16) | (int)modifiers; key = (key << 16) | (int)modifiers;
if (!_hotkeyTriggerDic.ContainsKey(key)) if (!_hotkeyTriggerDic.ContainsKey(key))
{ {
_hotkeyTriggerDic.Add(key, new() { item.eGlobalHotkey }); _hotkeyTriggerDic.Add(key, new() { item.EGlobalHotkey });
} }
else else
{ {
if (!_hotkeyTriggerDic[key].Contains(item.eGlobalHotkey)) if (!_hotkeyTriggerDic[key].Contains(item.EGlobalHotkey))
_hotkeyTriggerDic[key].Add(item.eGlobalHotkey); _hotkeyTriggerDic[key].Add(item.EGlobalHotkey);
} }
} }
} }

View file

@ -13,7 +13,7 @@ namespace v2rayN.Handler
{ {
try try
{ {
var index = (int)config.systemProxyItem.sysProxyType; var index = (int)config.SystemProxyItem.SysProxyType;
//Load from routing setting //Load from routing setting
var createdIcon = await GetNotifyIcon4Routing(config); var createdIcon = await GetNotifyIcon4Routing(config);
@ -46,7 +46,7 @@ namespace v2rayN.Handler
public System.Windows.Media.ImageSource GetAppIcon(Config config) public System.Windows.Media.ImageSource GetAppIcon(Config config)
{ {
var index = (int)config.systemProxyItem.sysProxyType + 1; var index = (int)config.SystemProxyItem.SysProxyType + 1;
return BitmapFrame.Create(new Uri($"pack://application:,,,/Resources/NotifyIcon{index}.ico", UriKind.RelativeOrAbsolute)); return BitmapFrame.Create(new Uri($"pack://application:,,,/Resources/NotifyIcon{index}.ico", UriKind.RelativeOrAbsolute));
} }
@ -54,7 +54,7 @@ namespace v2rayN.Handler
{ {
try try
{ {
if (!config.routingBasicItem.enableRoutingAdvanced) if (!config.RoutingBasicItem.EnableRoutingAdvanced)
{ {
return null; return null;
} }
@ -66,7 +66,7 @@ namespace v2rayN.Handler
} }
Color color = ColorTranslator.FromHtml("#3399CC"); Color color = ColorTranslator.FromHtml("#3399CC");
int index = (int)config.systemProxyItem.sysProxyType; int index = (int)config.SystemProxyItem.SysProxyType;
if (index > 0) if (index > 0)
{ {
color = (new[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1]; color = (new[] { Color.Red, Color.Purple, Color.DarkGreen, Color.Orange, Color.DarkSlateBlue, Color.RoyalBlue })[index - 1];

View file

@ -52,12 +52,12 @@ namespace v2rayN.ViewModels
} }
else else
{ {
ModifyTheme(_config.uiItem.colorModeDark); ModifyTheme(_config.UiItem.ColorModeDark);
} }
if (!_config.uiItem.colorPrimaryName.IsNullOrEmpty()) if (!_config.UiItem.ColorPrimaryName.IsNullOrEmpty())
{ {
var swatch = new SwatchesProvider().Swatches.FirstOrDefault(t => t.Name == _config.uiItem.colorPrimaryName); var swatch = new SwatchesProvider().Swatches.FirstOrDefault(t => t.Name == _config.UiItem.ColorPrimaryName);
if (swatch != null if (swatch != null
&& swatch.ExemplarHue != null && swatch.ExemplarHue != null
&& swatch.ExemplarHue?.Color != null) && swatch.ExemplarHue?.Color != null)
@ -69,24 +69,24 @@ namespace v2rayN.ViewModels
private void BindingUI() private void BindingUI()
{ {
ColorModeDark = _config.uiItem.colorModeDark; ColorModeDark = _config.UiItem.ColorModeDark;
FollowSystemTheme = _config.uiItem.followSystemTheme; FollowSystemTheme = _config.UiItem.FollowSystemTheme;
_swatches.AddRange(new SwatchesProvider().Swatches); _swatches.AddRange(new SwatchesProvider().Swatches);
if (!_config.uiItem.colorPrimaryName.IsNullOrEmpty()) if (!_config.UiItem.ColorPrimaryName.IsNullOrEmpty())
{ {
SelectedSwatch = _swatches.FirstOrDefault(t => t.Name == _config.uiItem.colorPrimaryName); SelectedSwatch = _swatches.FirstOrDefault(t => t.Name == _config.UiItem.ColorPrimaryName);
} }
CurrentFontSize = _config.uiItem.currentFontSize; CurrentFontSize = _config.UiItem.CurrentFontSize;
CurrentLanguage = _config.uiItem.currentLanguage; CurrentLanguage = _config.UiItem.CurrentLanguage;
this.WhenAnyValue( this.WhenAnyValue(
x => x.ColorModeDark, x => x.ColorModeDark,
y => y == true) y => y == true)
.Subscribe(c => .Subscribe(c =>
{ {
if (_config.uiItem.colorModeDark != ColorModeDark) if (_config.UiItem.ColorModeDark != ColorModeDark)
{ {
_config.uiItem.colorModeDark = ColorModeDark; _config.UiItem.ColorModeDark = ColorModeDark;
ModifyTheme(ColorModeDark); ModifyTheme(ColorModeDark);
ConfigHandler.SaveConfig(_config); ConfigHandler.SaveConfig(_config);
} }
@ -96,9 +96,9 @@ namespace v2rayN.ViewModels
y => y == true) y => y == true)
.Subscribe(c => .Subscribe(c =>
{ {
if (_config.uiItem.followSystemTheme != FollowSystemTheme) if (_config.UiItem.FollowSystemTheme != FollowSystemTheme)
{ {
_config.uiItem.followSystemTheme = FollowSystemTheme; _config.UiItem.FollowSystemTheme = FollowSystemTheme;
ConfigHandler.SaveConfig(_config); ConfigHandler.SaveConfig(_config);
if (FollowSystemTheme) if (FollowSystemTheme)
{ {
@ -123,9 +123,9 @@ namespace v2rayN.ViewModels
{ {
return; return;
} }
if (_config.uiItem.colorPrimaryName != SelectedSwatch?.Name) if (_config.UiItem.ColorPrimaryName != SelectedSwatch?.Name)
{ {
_config.uiItem.colorPrimaryName = SelectedSwatch?.Name; _config.UiItem.ColorPrimaryName = SelectedSwatch?.Name;
ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color); ChangePrimaryColor(SelectedSwatch.ExemplarHue.Color);
ConfigHandler.SaveConfig(_config); ConfigHandler.SaveConfig(_config);
} }
@ -138,7 +138,7 @@ namespace v2rayN.ViewModels
{ {
if (CurrentFontSize >= Global.MinFontSize) if (CurrentFontSize >= Global.MinFontSize)
{ {
_config.uiItem.currentFontSize = CurrentFontSize; _config.UiItem.CurrentFontSize = CurrentFontSize;
double size = (long)CurrentFontSize; double size = (long)CurrentFontSize;
Application.Current.Resources["StdFontSize"] = size; Application.Current.Resources["StdFontSize"] = size;
Application.Current.Resources["StdFontSize1"] = size + 1; Application.Current.Resources["StdFontSize1"] = size + 1;
@ -153,9 +153,9 @@ namespace v2rayN.ViewModels
y => y != null && !y.IsNullOrEmpty()) y => y != null && !y.IsNullOrEmpty())
.Subscribe(c => .Subscribe(c =>
{ {
if (Utils.IsNotEmpty(CurrentLanguage) && _config.uiItem.currentLanguage != CurrentLanguage) if (Utils.IsNotEmpty(CurrentLanguage) && _config.UiItem.CurrentLanguage != CurrentLanguage)
{ {
_config.uiItem.currentLanguage = CurrentLanguage; _config.UiItem.CurrentLanguage = CurrentLanguage;
Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage); Thread.CurrentThread.CurrentUICulture = new(CurrentLanguage);
ConfigHandler.SaveConfig(_config); ConfigHandler.SaveConfig(_config);
NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips); NoticeHandler.Instance.Enqueue(ResUI.NeedRebootTips);
@ -189,7 +189,7 @@ namespace v2rayN.ViewModels
var hwndSource = HwndSource.FromHwnd(helper.EnsureHandle()); var hwndSource = HwndSource.FromHwnd(helper.EnsureHandle());
hwndSource.AddHook((IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) => hwndSource.AddHook((IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) =>
{ {
if (config.uiItem.followSystemTheme) if (config.UiItem.FollowSystemTheme)
{ {
const int WM_SETTINGCHANGE = 0x001A; const int WM_SETTINGCHANGE = 0x001A;
if (msg == WM_SETTINGCHANGE) if (msg == WM_SETTINGCHANGE)

View file

@ -34,7 +34,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.EditServerCmd, v => v.btnEdit).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.EditServerCmd, v => v.btnEdit).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveServerCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveServerCmd, v => v.btnSave).DisposeWith(disposables);
}); });
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark);
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -219,7 +219,7 @@ namespace v2rayN.Views
}); });
this.Title = $"{profileItem.configType}"; this.Title = $"{profileItem.configType}";
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark);
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -18,10 +18,10 @@ namespace v2rayN.Views
{ {
this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.OperationMsg, v => v.txtMsg.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.url, v => v.txtWebDavUrl.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Url, v => v.txtWebDavUrl.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.userName, v => v.txtWebDavUserName.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.UserName, v => v.txtWebDavUserName.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.password, v => v.txtWebDavPassword.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.Password, v => v.txtWebDavPassword.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.dirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables); this.Bind(ViewModel, vm => vm.SelectedSource.DirName, v => v.txtWebDavDirName.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.WebDavCheckCmd, v => v.menuWebDavCheck).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.WebDavCheckCmd, v => v.menuWebDavCheck).DisposeWith(disposables);

View file

@ -50,7 +50,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ImportDefConfig4V2rayCmd, v => v.btnImportDefConfig4V2ray).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.ImportDefConfig4SingboxCmd, v => v.btnImportDefConfig4Singbox).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ImportDefConfig4SingboxCmd, v => v.btnImportDefConfig4Singbox).DisposeWith(disposables);
}); });
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark);
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -17,7 +17,7 @@ namespace v2rayN.Views
this.Owner = Application.Current.MainWindow; this.Owner = Application.Current.MainWindow;
_config = AppHandler.Instance.Config; _config = AppHandler.Instance.Config;
_config.globalHotkeys ??= new List<KeyEventItem>(); _config.GlobalHotkeys ??= new List<KeyEventItem>();
btnReset.Click += btnReset_Click; btnReset.Click += btnReset_Click;
btnSave.Click += btnSave_Click; btnSave.Click += btnSave_Click;
@ -30,7 +30,7 @@ namespace v2rayN.Views
HotkeyHandler.Instance.IsPause = true; HotkeyHandler.Instance.IsPause = true;
this.Closing += (s, e) => HotkeyHandler.Instance.IsPause = false; this.Closing += (s, e) => HotkeyHandler.Instance.IsPause = false;
WindowsUtils.SetDarkBorder(this, _config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : _config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, _config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : _config.UiItem.ColorModeDark);
InitData(); InitData();
} }
@ -38,11 +38,11 @@ namespace v2rayN.Views
{ {
_TextBoxKeyEventItem = new() _TextBoxKeyEventItem = new()
{ {
{ txtGlobalHotkey0,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.ShowForm) }, { txtGlobalHotkey0,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.ShowForm) },
{ txtGlobalHotkey1,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.SystemProxyClear) }, { txtGlobalHotkey1,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.SystemProxyClear) },
{ txtGlobalHotkey2,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.SystemProxySet) }, { txtGlobalHotkey2,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.SystemProxySet) },
{ txtGlobalHotkey3,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.SystemProxyUnchanged)}, { txtGlobalHotkey3,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.SystemProxyUnchanged)},
{ txtGlobalHotkey4,GetKeyEventItemByEGlobalHotkey(_config.globalHotkeys,EGlobalHotkey.SystemProxyPac)} { txtGlobalHotkey4,GetKeyEventItemByEGlobalHotkey(_config.GlobalHotkeys,EGlobalHotkey.SystemProxyPac)}
}; };
BindingData(); BindingData();
} }
@ -61,9 +61,9 @@ namespace v2rayN.Views
private KeyEventItem GetKeyEventItemByEGlobalHotkey(List<KeyEventItem> KEList, EGlobalHotkey eg) private KeyEventItem GetKeyEventItemByEGlobalHotkey(List<KeyEventItem> KEList, EGlobalHotkey eg)
{ {
return JsonUtils.DeepCopy(KEList.Find((it) => it.eGlobalHotkey == eg) ?? new() return JsonUtils.DeepCopy(KEList.Find((it) => it.EGlobalHotkey == eg) ?? new()
{ {
eGlobalHotkey = eg, EGlobalHotkey = eg,
Control = false, Control = false,
Alt = false, Alt = false,
Shift = false, Shift = false,
@ -101,7 +101,7 @@ namespace v2rayN.Views
private void btnSave_Click(object sender, RoutedEventArgs e) private void btnSave_Click(object sender, RoutedEventArgs e)
{ {
_config.globalHotkeys = _TextBoxKeyEventItem.Values.ToList(); _config.GlobalHotkeys = _TextBoxKeyEventItem.Values.ToList();
if ( ConfigHandler.SaveConfig(_config, false).Result == 0) if ( ConfigHandler.SaveConfig(_config, false).Result == 0)
{ {

View file

@ -41,7 +41,7 @@ namespace v2rayN.Views
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel)); Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null); WindowsHandler.Instance.RegisterGlobalHotkey(_config, OnHotkeyHandler, null);
switch (_config.uiItem.mainGirdOrientation) switch (_config.UiItem.MainGirdOrientation)
{ {
case EGirdOrientation.Horizontal: case EGirdOrientation.Horizontal:
tabProfiles.Content ??= new ProfilesView(); tabProfiles.Content ??= new ProfilesView();
@ -105,7 +105,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.ReloadCmd, v => v.menuReload).DisposeWith(disposables);
this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables); this.OneWayBind(ViewModel, vm => vm.BlReloadEnabled, v => v.menuReload.IsEnabled).DisposeWith(disposables);
switch (_config.uiItem.mainGirdOrientation) switch (_config.UiItem.MainGirdOrientation)
{ {
case EGirdOrientation.Horizontal: case EGirdOrientation.Horizontal:
gridMain.Visibility = Visibility.Visible; gridMain.Visibility = Visibility.Visible;
@ -135,7 +135,7 @@ namespace v2rayN.Views
this.Title = $"{Utils.GetVersion()} - {(AppHandler.Instance.IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; this.Title = $"{Utils.GetVersion()} - {(AppHandler.Instance.IsAdministrator ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
if (!_config.guiItem.enableHWA) if (!_config.GuiItem.EnableHWA)
{ {
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
} }
@ -362,7 +362,7 @@ namespace v2rayN.Views
public void ShowHideWindow(bool? blShow) public void ShowHideWindow(bool? blShow)
{ {
var bl = blShow ?? !_config.uiItem.showInTaskbar; var bl = blShow ?? !_config.UiItem.ShowInTaskbar;
if (bl) if (bl)
{ {
Application.Current.MainWindow.Show(); Application.Current.MainWindow.Show();
@ -377,50 +377,50 @@ namespace v2rayN.Views
{ {
Application.Current.MainWindow.Hide(); Application.Current.MainWindow.Hide();
} }
_config.uiItem.showInTaskbar = bl; _config.UiItem.ShowInTaskbar = bl;
} }
private void RestoreUI() private void RestoreUI()
{ {
if (_config.uiItem.mainWidth > 0 && _config.uiItem.mainHeight > 0) if (_config.UiItem.MainWidth > 0 && _config.UiItem.MainHeight > 0)
{ {
Width = _config.uiItem.mainWidth; Width = _config.UiItem.MainWidth;
Height = _config.uiItem.mainHeight; Height = _config.UiItem.MainHeight;
} }
var maxWidth = SystemParameters.WorkArea.Width; var maxWidth = SystemParameters.WorkArea.Width;
var maxHeight = SystemParameters.WorkArea.Height; var maxHeight = SystemParameters.WorkArea.Height;
if (Width > maxWidth) Width = maxWidth; if (Width > maxWidth) Width = maxWidth;
if (Height > maxHeight) Height = maxHeight; if (Height > maxHeight) Height = maxHeight;
if (_config.uiItem.mainGirdHeight1 > 0 && _config.uiItem.mainGirdHeight2 > 0) if (_config.UiItem.MainGirdHeight1 > 0 && _config.UiItem.MainGirdHeight2 > 0)
{ {
if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal)
{ {
gridMain.ColumnDefinitions[0].Width = new GridLength(_config.uiItem.mainGirdHeight1, GridUnitType.Star); gridMain.ColumnDefinitions[0].Width = new GridLength(_config.UiItem.MainGirdHeight1, GridUnitType.Star);
gridMain.ColumnDefinitions[2].Width = new GridLength(_config.uiItem.mainGirdHeight2, GridUnitType.Star); gridMain.ColumnDefinitions[2].Width = new GridLength(_config.UiItem.MainGirdHeight2, GridUnitType.Star);
} }
else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical)
{ {
gridMain1.RowDefinitions[0].Height = new GridLength(_config.uiItem.mainGirdHeight1, GridUnitType.Star); gridMain1.RowDefinitions[0].Height = new GridLength(_config.UiItem.MainGirdHeight1, GridUnitType.Star);
gridMain1.RowDefinitions[2].Height = new GridLength(_config.uiItem.mainGirdHeight2, GridUnitType.Star); gridMain1.RowDefinitions[2].Height = new GridLength(_config.UiItem.MainGirdHeight2, GridUnitType.Star);
} }
} }
} }
private void StorageUI() private void StorageUI()
{ {
_config.uiItem.mainWidth = Utils.ToInt(this.Width); _config.UiItem.MainWidth = Utils.ToInt(this.Width);
_config.uiItem.mainHeight = Utils.ToInt(this.Height); _config.UiItem.MainHeight = Utils.ToInt(this.Height);
if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Horizontal) if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Horizontal)
{ {
_config.uiItem.mainGirdHeight1 = Math.Ceiling(gridMain.ColumnDefinitions[0].ActualWidth + 0.1); _config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain.ColumnDefinitions[0].ActualWidth + 0.1);
_config.uiItem.mainGirdHeight2 = Math.Ceiling(gridMain.ColumnDefinitions[2].ActualWidth + 0.1); _config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain.ColumnDefinitions[2].ActualWidth + 0.1);
} }
else if (_config.uiItem.mainGirdOrientation == EGirdOrientation.Vertical) else if (_config.UiItem.MainGirdOrientation == EGirdOrientation.Vertical)
{ {
_config.uiItem.mainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1); _config.UiItem.MainGirdHeight1 = Math.Ceiling(gridMain1.RowDefinitions[0].ActualHeight + 0.1);
_config.uiItem.mainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1); _config.UiItem.MainGirdHeight2 = Math.Ceiling(gridMain1.RowDefinitions[2].ActualHeight + 0.1);
} }
} }

View file

@ -26,7 +26,7 @@ namespace v2rayN.Views
{ {
clbdestOverride.Items.Add(it); clbdestOverride.Items.Add(it);
}); });
_config.inbound[0].destOverride?.ForEach(it => _config.Inbound[0].DestOverride?.ForEach(it =>
{ {
clbdestOverride.SelectedItems.Add(it); clbdestOverride.SelectedItems.Add(it);
}); });
@ -180,7 +180,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
}); });
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark);
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
@ -206,7 +206,7 @@ namespace v2rayN.Views
{ {
files.AddRange(Directory.GetFiles(path, pattern)); files.AddRange(Directory.GetFiles(path, pattern));
} }
var culture = _config.uiItem.currentLanguage == Global.Languages[0] ? "zh-cn" : "en-us"; var culture = _config.UiItem.CurrentLanguage == Global.Languages[0] ? "zh-cn" : "en-us";
var culture2 = "en-us"; var culture2 = "en-us";
foreach (var ttf in files) foreach (var ttf in files)
{ {

View file

@ -32,7 +32,7 @@ namespace v2rayN.Views
lstProfiles.LoadingRow += LstProfiles_LoadingRow; lstProfiles.LoadingRow += LstProfiles_LoadingRow;
menuSelectAll.Click += menuSelectAll_Click; menuSelectAll.Click += menuSelectAll_Click;
if (_config.uiItem.enableDragDropSort) if (_config.UiItem.EnableDragDropSort)
{ {
lstProfiles.AllowDrop = true; lstProfiles.AllowDrop = true;
lstProfiles.PreviewMouseLeftButtonDown += LstProfiles_PreviewMouseLeftButtonDown; lstProfiles.PreviewMouseLeftButtonDown += LstProfiles_PreviewMouseLeftButtonDown;
@ -195,7 +195,7 @@ namespace v2rayN.Views
private void LstProfiles_MouseDoubleClick(object sender, MouseButtonEventArgs e) private void LstProfiles_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{ {
if (_config.uiItem.doubleClick2Activate) if (_config.UiItem.DoubleClick2Activate)
{ {
ViewModel?.SetDefaultServer(); ViewModel?.SetDefaultServer();
} }
@ -321,7 +321,7 @@ namespace v2rayN.Views
private void RestoreUI() private void RestoreUI()
{ {
var lvColumnItem = _config.uiItem.mainColumnItem.OrderBy(t => t.Index).ToList(); var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList();
var displayIndex = 0; var displayIndex = 0;
foreach (var item in lvColumnItem) foreach (var item in lvColumnItem)
{ {
@ -340,7 +340,7 @@ namespace v2rayN.Views
} }
if (item.Name.StartsWith("to")) if (item.Name.StartsWith("to"))
{ {
if (!_config.guiItem.enableStatistics) if (!_config.GuiItem.EnableStatistics)
{ {
item2.Visibility = Visibility.Hidden; item2.Visibility = Visibility.Hidden;
} }
@ -363,7 +363,7 @@ namespace v2rayN.Views
Index = item2.DisplayIndex Index = item2.DisplayIndex
}); });
} }
_config.uiItem.mainColumnItem = lvColumnItem; _config.UiItem.MainColumnItem = lvColumnItem;
ConfigHandler.SaveConfig(_config); ConfigHandler.SaveConfig(_config);
} }

View file

@ -58,7 +58,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
}); });
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark);
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -60,7 +60,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
}); });
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark);
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -66,7 +66,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
}); });
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark);
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -37,7 +37,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
}); });
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark);
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)

View file

@ -31,7 +31,7 @@ namespace v2rayN.Views
this.BindCommand(ViewModel, vm => vm.SubEditCmd, v => v.menuSubEdit).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SubEditCmd, v => v.menuSubEdit).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SubShareCmd, v => v.menuSubShare).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SubShareCmd, v => v.menuSubShare).DisposeWith(disposables);
}); });
WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.uiItem.colorModeDark); WindowsUtils.SetDarkBorder(this, AppHandler.Instance.Config.UiItem.FollowSystemTheme ? !WindowsUtils.IsLightTheme() : AppHandler.Instance.Config.UiItem.ColorModeDark);
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)