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
+8 -8
View File
@@ -51,7 +51,7 @@
{
return false;
}
Thread.CurrentThread.CurrentUICulture = new(_config.uiItem.currentLanguage);
Thread.CurrentThread.CurrentUICulture = new(_config.UiItem.CurrentLanguage);
//Under Win10
if (Utils.IsWindows() && Environment.OSVersion.Version.Major < 10)
@@ -85,7 +85,7 @@
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;
}
@@ -165,11 +165,11 @@
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);
var lstServerStat = (_config.guiItem.enableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? [];
var lstServerStat = (_config.GuiItem.EnableStatistics ? StatisticsHandler.Instance.ServerStat : null) ?? [];
var lstProfileExs = ProfileExHandler.Instance.ProfileExs;
lstModel = (from t in lstModel
join t2 in lstServerStat on t.indexId equals t2.indexId into t2b
@@ -188,7 +188,7 @@
streamSecurity = t.streamSecurity,
subid = t.subid,
subRemarks = t.subRemarks,
isActive = t.indexId == _config.indexId,
isActive = t.indexId == _config.IndexId,
sort = t33 == null ? 0 : t33.sort,
delay = t33 == null ? 0 : t33.delay,
delayVal = t33?.delay != 0 ? $"{t33?.delay} {Global.DelayUnit}" : string.Empty,
@@ -268,16 +268,16 @@
return (ECoreType)profileItem.coreType;
}
if (_config.coreTypeItem == null)
if (_config.CoreTypeItem == null)
{
return ECoreType.Xray;
}
var item = _config.coreTypeItem.FirstOrDefault(it => it.configType == eConfigType);
var item = _config.CoreTypeItem.FirstOrDefault(it => it.ConfigType == eConfigType);
if (item == null)
{
return ECoreType.Xray;
}
return item.coreType;
return item.CoreType;
}
#endregion Core Type
+1 -1
View File
@@ -72,7 +72,7 @@ namespace ServiceLib.Handler
return;
}
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>();
foreach (var it in lstProxy)
+85 -85
View File
@@ -37,133 +37,133 @@ namespace ServiceLib.Handler
config ??= new Config();
config.coreBasicItem ??= new()
config.CoreBasicItem ??= new()
{
logEnabled = false,
loglevel = "warning",
muxEnabled = false,
LogEnabled = false,
Loglevel = "warning",
MuxEnabled = false,
};
if (config.inbound == null)
if (config.Inbound == null)
{
config.inbound = new List<InItem>();
config.Inbound = new List<InItem>();
InItem inItem = new()
{
protocol = EInboundProtocol.socks.ToString(),
localPort = 10808,
udpEnabled = true,
sniffingEnabled = true,
routeOnly = false,
Protocol = EInboundProtocol.socks.ToString(),
LocalPort = 10808,
UdpEnabled = true,
SniffingEnabled = true,
RouteOnly = false,
};
config.inbound.Add(inItem);
config.Inbound.Add(inItem);
}
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,
tti = 50,
uplinkCapacity = 12,
downlinkCapacity = 100,
readBufferSize = 2,
writeBufferSize = 2,
congestion = false
Mtu = 1350,
Tti = 50,
UplinkCapacity = 12,
DownlinkCapacity = 100,
ReadBufferSize = 2,
WriteBufferSize = 2,
Congestion = false
};
config.grpcItem ??= new GrpcItem
config.GrpcItem ??= new GrpcItem
{
idle_timeout = 60,
health_check_timeout = 20,
permit_without_stream = false,
initial_windows_size = 0,
IdleTimeout = 60,
HealthCheckTimeout = 20,
PermitWithoutStream = false,
InitialWindowsSize = 0,
};
config.tunModeItem ??= new TunModeItem
config.TunModeItem ??= new TunModeItem
{
enableTun = false,
mtu = 9000,
EnableTun = false,
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))
{
config.uiItem.currentLanguage = Global.Languages[0];
config.UiItem.CurrentLanguage = Global.Languages[0];
}
else
{
config.uiItem.currentLanguage = Global.Languages[2];
config.UiItem.CurrentLanguage = Global.Languages[2];
}
}
config.constItem ??= new ConstItem();
if (Utils.IsNullOrEmpty(config.constItem.defIEProxyExceptions))
config.ConstItem ??= new ConstItem();
if (Utils.IsNullOrEmpty(config.ConstItem.DefIEProxyExceptions))
{
config.constItem.defIEProxyExceptions = Global.IEProxyExceptions;
config.ConstItem.DefIEProxyExceptions = Global.IEProxyExceptions;
}
config.speedTestItem ??= new();
if (config.speedTestItem.speedTestTimeout < 10)
config.SpeedTestItem ??= new();
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,
xudpConcurrency = 16,
xudpProxyUDP443 = "reject"
Concurrency = 8,
XudpConcurrency = 16,
XudpProxyUDP443 = "reject"
};
config.mux4SboxItem ??= new()
config.Mux4SboxItem ??= new()
{
protocol = Global.SingboxMuxs[0],
max_connections = 8
Protocol = Global.SingboxMuxs[0],
MaxConnections = 8
};
config.hysteriaItem ??= new()
config.HysteriaItem ??= new()
{
up_mbps = 100,
down_mbps = 100
UpMbps = 100,
DownMbps = 100
};
config.clashUIItem ??= new();
config.systemProxyItem ??= new();
config.webDavItem ??= new();
config.ClashUIItem ??= new();
config.SystemProxyItem ??= new();
config.WebDavItem ??= new();
return config;
}
@@ -369,7 +369,7 @@ namespace ServiceLib.Handler
return -1;
}
config.indexId = indexId;
config.IndexId = indexId;
await ToJsonFile(config);
@@ -378,11 +378,11 @@ namespace ServiceLib.Handler
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;
}
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)
{
return 0;
@@ -398,7 +398,7 @@ namespace ServiceLib.Handler
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)
{
var item2 = await SQLiteHelper.Instance.TableAsync<ProfileItem>().FirstOrDefaultAsync();
@@ -887,7 +887,7 @@ namespace ServiceLib.Handler
List<ProfileItem> lstKeep = new();
List<ProfileItem> lstRemove = new();
if (!config.guiItem.keepOlderDedupl) lstProfile.Reverse();
if (!config.GuiItem.KeepOlderDedupl) lstProfile.Reverse();
foreach (ProfileItem item in lstProfile)
{
@@ -920,11 +920,11 @@ namespace ServiceLib.Handler
{
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)
{
profileItem.fingerprint = config.coreBasicItem.defFingerprint;
profileItem.fingerprint = config.CoreBasicItem.DefFingerprint;
}
}
}
@@ -1089,7 +1089,7 @@ namespace ServiceLib.Handler
if (isSub && Utils.IsNotEmpty(subid))
{
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)
{
//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)
{
config.routingBasicItem.routingIndexId = routingItem.id;
config.RoutingBasicItem.RoutingIndexId = routingItem.id;
}
await ToJsonFile(config);
@@ -1614,7 +1614,7 @@ namespace ServiceLib.Handler
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)
{
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)
{
if (string.IsNullOrEmpty(config.constItem.routeRulesTemplateSourceUrl))
if (string.IsNullOrEmpty(config.ConstItem.RouteRulesTemplateSourceUrl))
{
await InitBuiltinRouting(config, blImportAdvancedRules);
}
@@ -1642,7 +1642,7 @@ namespace ServiceLib.Handler
public static async Task<int> InitExternalRouting(Config config, bool blImportAdvancedRules = false)
{
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))
return await InitBuiltinRouting(config, blImportAdvancedRules); // fallback
@@ -1826,9 +1826,9 @@ namespace ServiceLib.Handler
switch (type)
{
case EPresetType.Default:
config.constItem.geoSourceUrl = "";
config.constItem.srsSourceUrl = "";
config.constItem.routeRulesTemplateSourceUrl = "";
config.ConstItem.GeoSourceUrl = "";
config.ConstItem.SrsSourceUrl = "";
config.ConstItem.RouteRulesTemplateSourceUrl = "";
await SQLiteHelper.Instance.DeleteAllAsync<DNSItem>();
await InitBuiltinDNS(config);
@@ -1836,9 +1836,9 @@ namespace ServiceLib.Handler
return true;
case EPresetType.Russia:
config.constItem.geoSourceUrl = Global.GeoFilesSources[1];
config.constItem.srsSourceUrl = Global.SingboxRulesetSources[1];
config.constItem.routeRulesTemplateSourceUrl = Global.RoutingRulesSources[1];
config.ConstItem.GeoSourceUrl = Global.GeoFilesSources[1];
config.ConstItem.SrsSourceUrl = Global.SingboxRulesetSources[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.sing_box, Global.DNSTemplateSources[1] + "sing_box.json"));
+4 -4
View File
@@ -182,7 +182,7 @@ namespace ServiceLib.Handler
// coreType = LazyConfig.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 displayLog = node.configType != EConfigType.Custom || node.displayLog;
@@ -198,7 +198,7 @@ namespace ServiceLib.Handler
{
ProfileItem? itemSocks = null;
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()
{
@@ -211,7 +211,7 @@ namespace ServiceLib.Handler
}
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()
{
coreType = preCoreType,
@@ -219,7 +219,7 @@ namespace ServiceLib.Handler
address = Global.Loopback,
port = node.preSocksPort.Value,
};
_config.runningCoreType = preCoreType;
_config.RunningCoreType = preCoreType;
}
if (itemSocks != null)
{
@@ -20,7 +20,7 @@ namespace ServiceLib.Handler
private async Task Init()
{
await InitData();
Task.Run(async () =>
await Task.Run(async () =>
{
while (true)
{
@@ -18,7 +18,7 @@
{
_config = config;
_updateFunc = updateFunc;
if (!config.guiItem.enableStatistics)
if (!config.GuiItem.EnableStatistics)
{
return;
}
@@ -81,7 +81,7 @@
private async Task UpdateServerStat(ServerSpeedItem server)
{
await GetServerStatItem(_config.indexId);
await GetServerStatItem(_config.IndexId);
if (_serverStatItem is null)
{
@@ -95,7 +95,7 @@
_serverStatItem.totalDown += server.proxyDown;
}
server.indexId = _config.indexId;
server.indexId = _config.IndexId;
server.todayUp = _serverStatItem.todayUp;
server.todayDown = _serverStatItem.todayDown;
server.totalUp = _serverStatItem.totalUp;
@@ -6,7 +6,7 @@ namespace ServiceLib.Handler.SysProxy
{
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)
{
@@ -84,19 +84,19 @@ namespace ServiceLib.Handler.SysProxy
private static void GetWindowsProxyString(Config config, int port, int portSocks, out string strProxy, out string 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;
if (Utils.IsNullOrEmpty(config.systemProxyItem.systemProxyAdvancedProtocol))
if (Utils.IsNullOrEmpty(config.SystemProxyItem.SystemProxyAdvancedProtocol))
{
strProxy = $"{Global.Loopback}:{port}";
}
else
{
strProxy = config.systemProxyItem.systemProxyAdvancedProtocol
strProxy = config.SystemProxyItem.SystemProxyAdvancedProtocol
.Replace("{ip}", Global.Loopback)
.Replace("{http_port}", port.ToString())
.Replace("{socks_port}", portSocks.ToString());
+2 -2
View File
@@ -55,9 +55,9 @@
await Task.Delay(1000 * 3600);
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) =>
{
+7 -7
View File
@@ -24,9 +24,9 @@ namespace ServiceLib.Handler
{
try
{
if (_config.webDavItem.url.IsNullOrEmpty()
|| _config.webDavItem.userName.IsNullOrEmpty()
|| _config.webDavItem.password.IsNullOrEmpty())
if (_config.WebDavItem.Url.IsNullOrEmpty()
|| _config.WebDavItem.UserName.IsNullOrEmpty()
|| _config.WebDavItem.Password.IsNullOrEmpty())
{
throw new ArgumentException("webdav parameter error or null");
}
@@ -35,19 +35,19 @@ namespace ServiceLib.Handler
_client?.Dispose();
_client = null;
}
if (_config.webDavItem.dirName.IsNullOrEmpty())
if (_config.WebDavItem.DirName.IsNullOrEmpty())
{
_webDir = Global.AppName + "_backup";
}
else
{
_webDir = _config.webDavItem.dirName.TrimEx();
_webDir = _config.WebDavItem.DirName.TrimEx();
}
var clientParams = new WebDavClientParams
{
BaseAddress = new Uri(_config.webDavItem.url),
Credentials = new NetworkCredential(_config.webDavItem.userName, _config.webDavItem.password)
BaseAddress = new Uri(_config.WebDavItem.Url),
Credentials = new NetworkCredential(_config.WebDavItem.UserName, _config.WebDavItem.Password)
};
_client = new WebDavClient(clientParams);
}