Browse Source

Fix ?!

pull/5720/head
2dust 2 months ago
parent
commit
243dbab06a
  1. 13
      v2rayN/ServiceLib/Common/SemanticVersion.cs
  2. 7
      v2rayN/ServiceLib/Common/Utils.cs
  3. 8
      v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigSingbox.cs
  4. 4
      v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigV2ray.cs
  5. 2
      v2rayN/ServiceLib/Handler/LazyConfig.cs
  6. 6
      v2rayN/ServiceLib/Handler/UpdateHandler.cs

13
v2rayN/ServiceLib/Common/SemanticVersion.cs

@ -15,11 +15,19 @@
this.version = $"{major}.{minor}.{patch}";
}
public SemanticVersion(string version)
public SemanticVersion(string? version)
{
this.version = version.RemovePrefix('v');
try
{
if (version.IsNullOrEmpty())
{
this.major = 0;
this.minor = 0;
this.patch = 0;
return;
}
this.version = version.RemovePrefix('v');
string[] parts = this.version.Split('.');
if (parts.Length == 2)
{
@ -43,7 +51,6 @@
this.major = 0;
this.minor = 0;
this.patch = 0;
//this.version = "0.0.0";
}
}

7
v2rayN/ServiceLib/Common/Utils.cs

@ -158,10 +158,11 @@ namespace ServiceLib.Common
/// </summary>
/// <param name="plainText"></param>
/// <returns></returns>
public static string Base64Decode(string plainText)
public static string Base64Decode(string? plainText)
{
try
{
if (plainText.IsNullOrEmpty()) return "";
plainText = plainText.Trim()
.Replace(Environment.NewLine, "")
.Replace("\n", "")
@ -365,7 +366,7 @@ namespace ServiceLib.Common
}
}
public static bool IsBase64String(string plainText)
public static bool IsBase64String(string? plainText)
{
if (plainText.IsNullOrEmpty()) return false;
var buffer = new Span<byte>(new byte[plainText.Length]);
@ -812,7 +813,7 @@ namespace ServiceLib.Common
}
if (coreType != null)
{
_tempPath = Path.Combine(_tempPath, coreType.ToString()!);
_tempPath = Path.Combine(_tempPath, coreType.ToString());
if (!Directory.Exists(_tempPath))
{
Directory.CreateDirectory(_tempPath);

8
v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigSingbox.cs

@ -865,7 +865,7 @@ namespace ServiceLib.Handler.CoreConfig
var txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
//Previous proxy
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile);
if (prevNode is not null
&& prevNode.configType != EConfigType.Custom)
{
@ -878,7 +878,7 @@ namespace ServiceLib.Handler.CoreConfig
}
//Next proxy
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile);
if (nextNode is not null
&& nextNode.configType != EConfigType.Custom)
{
@ -956,7 +956,7 @@ namespace ServiceLib.Handler.CoreConfig
if (routing != null)
{
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.ruleSet);
foreach (var item in rules!)
foreach (var item in rules ?? [])
{
if (item.enabled)
{
@ -971,7 +971,7 @@ namespace ServiceLib.Handler.CoreConfig
if (lockedItem != null)
{
var rules = JsonUtils.Deserialize<List<RulesItem>>(lockedItem.ruleSet);
foreach (var item in rules!)
foreach (var item in rules ?? [])
{
GenRoutingUserRule(item, singboxConfig.route.rules);
}

4
v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigV2ray.cs

@ -1204,7 +1204,7 @@ namespace ServiceLib.Handler.CoreConfig
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
//Previous proxy
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile);
if (prevNode is not null
&& prevNode.configType != EConfigType.Custom
&& prevNode.configType != EConfigType.Hysteria2
@ -1223,7 +1223,7 @@ namespace ServiceLib.Handler.CoreConfig
}
//Next proxy
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile);
if (nextNode is not null
&& nextNode.configType != EConfigType.Custom
&& nextNode.configType != EConfigType.Hysteria2

2
v2rayN/ServiceLib/Handler/LazyConfig.cs

@ -168,7 +168,7 @@
return SQLiteHelper.Instance.Table<ProfileItem>().FirstOrDefault(it => it.indexId == indexId);
}
public ProfileItem? GetProfileItemViaRemarks(string remarks)
public ProfileItem? GetProfileItemViaRemarks(string? remarks)
{
if (Utils.IsNullOrEmpty(remarks))
{

6
v2rayN/ServiceLib/Handler/UpdateHandler.cs

@ -191,7 +191,7 @@ namespace ServiceLib.Handler
//more url
if (Utils.IsNullOrEmpty(item.convertTarget) && Utils.IsNotEmpty(item.moreUrl.TrimEx()))
{
if (Utils.IsNotEmpty(result) && Utils.IsBase64String(result!))
if (Utils.IsNotEmpty(result) && Utils.IsBase64String(result))
{
result = Utils.Base64Decode(result);
}
@ -212,7 +212,7 @@ namespace ServiceLib.Handler
}
if (Utils.IsNotEmpty(result2))
{
if (Utils.IsBase64String(result2!))
if (Utils.IsBase64String(result2))
{
result += Utils.Base64Decode(result2);
}
@ -368,7 +368,7 @@ namespace ServiceLib.Handler
{
var gitHubReleases = JsonUtils.Deserialize<List<GitHubRelease>>(gitHubReleaseApi);
var gitHubRelease = preRelease ? gitHubReleases?.First() : gitHubReleases?.First(r => r.Prerelease == false);
var version = new SemanticVersion(gitHubRelease?.TagName!);
var version = new SemanticVersion(gitHubRelease?.TagName);
var body = gitHubRelease?.Body;
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type);

Loading…
Cancel
Save