Skip to content

Commit 243dbab

Browse files
committed
Fix ?!
1 parent 073eaa9 commit 243dbab

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

v2rayN/ServiceLib/Common/SemanticVersion.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ public SemanticVersion(int major, int minor, int patch)
1515
this.version = $"{major}.{minor}.{patch}";
1616
}
1717

18-
public SemanticVersion(string version)
18+
public SemanticVersion(string? version)
1919
{
20-
this.version = version.RemovePrefix('v');
2120
try
2221
{
22+
if (version.IsNullOrEmpty())
23+
{
24+
this.major = 0;
25+
this.minor = 0;
26+
this.patch = 0;
27+
return;
28+
}
29+
this.version = version.RemovePrefix('v');
30+
2331
string[] parts = this.version.Split('.');
2432
if (parts.Length == 2)
2533
{
@@ -43,7 +51,6 @@ public SemanticVersion(string version)
4351
this.major = 0;
4452
this.minor = 0;
4553
this.patch = 0;
46-
//this.version = "0.0.0";
4754
}
4855
}
4956

v2rayN/ServiceLib/Common/Utils.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,11 @@ public static string Base64Encode(string plainText)
158158
/// </summary>
159159
/// <param name="plainText"></param>
160160
/// <returns></returns>
161-
public static string Base64Decode(string plainText)
161+
public static string Base64Decode(string? plainText)
162162
{
163163
try
164164
{
165+
if (plainText.IsNullOrEmpty()) return "";
165166
plainText = plainText.Trim()
166167
.Replace(Environment.NewLine, "")
167168
.Replace("\n", "")
@@ -365,7 +366,7 @@ public static string GetPunycode(string url)
365366
}
366367
}
367368

368-
public static bool IsBase64String(string plainText)
369+
public static bool IsBase64String(string? plainText)
369370
{
370371
if (plainText.IsNullOrEmpty()) return false;
371372
var buffer = new Span<byte>(new byte[plainText.Length]);
@@ -812,7 +813,7 @@ public static string GetBinPath(string filename, string? coreType = null)
812813
}
813814
if (coreType != null)
814815
{
815-
_tempPath = Path.Combine(_tempPath, coreType.ToString()!);
816+
_tempPath = Path.Combine(_tempPath, coreType.ToString());
816817
if (!Directory.Exists(_tempPath))
817818
{
818819
Directory.CreateDirectory(_tempPath);

v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigSingbox.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ private int GenMoreOutbounds(ProfileItem node, SingboxConfig singboxConfig)
865865
var txtOutbound = Utils.GetEmbedText(Global.SingboxSampleOutbound);
866866

867867
//Previous proxy
868-
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
868+
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile);
869869
if (prevNode is not null
870870
&& prevNode.configType != EConfigType.Custom)
871871
{
@@ -878,7 +878,7 @@ private int GenMoreOutbounds(ProfileItem node, SingboxConfig singboxConfig)
878878
}
879879

880880
//Next proxy
881-
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
881+
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile);
882882
if (nextNode is not null
883883
&& nextNode.configType != EConfigType.Custom)
884884
{
@@ -956,7 +956,7 @@ private int GenRouting(SingboxConfig singboxConfig)
956956
if (routing != null)
957957
{
958958
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.ruleSet);
959-
foreach (var item in rules!)
959+
foreach (var item in rules ?? [])
960960
{
961961
if (item.enabled)
962962
{
@@ -971,7 +971,7 @@ private int GenRouting(SingboxConfig singboxConfig)
971971
if (lockedItem != null)
972972
{
973973
var rules = JsonUtils.Deserialize<List<RulesItem>>(lockedItem.ruleSet);
974-
foreach (var item in rules!)
974+
foreach (var item in rules ?? [])
975975
{
976976
GenRoutingUserRule(item, singboxConfig.route.rules);
977977
}

v2rayN/ServiceLib/Handler/CoreConfig/CoreConfigV2ray.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ private int GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig)
12041204
var txtOutbound = Utils.GetEmbedText(Global.V2raySampleOutbound);
12051205

12061206
//Previous proxy
1207-
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile!);
1207+
var prevNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.prevProfile);
12081208
if (prevNode is not null
12091209
&& prevNode.configType != EConfigType.Custom
12101210
&& prevNode.configType != EConfigType.Hysteria2
@@ -1223,7 +1223,7 @@ private int GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig)
12231223
}
12241224

12251225
//Next proxy
1226-
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile!);
1226+
var nextNode = LazyConfig.Instance.GetProfileItemViaRemarks(subItem.nextProfile);
12271227
if (nextNode is not null
12281228
&& nextNode.configType != EConfigType.Custom
12291229
&& nextNode.configType != EConfigType.Hysteria2

v2rayN/ServiceLib/Handler/LazyConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ from t33 in t3b.DefaultIfEmpty()
168168
return SQLiteHelper.Instance.Table<ProfileItem>().FirstOrDefault(it => it.indexId == indexId);
169169
}
170170

171-
public ProfileItem? GetProfileItemViaRemarks(string remarks)
171+
public ProfileItem? GetProfileItemViaRemarks(string? remarks)
172172
{
173173
if (Utils.IsNullOrEmpty(remarks))
174174
{

v2rayN/ServiceLib/Handler/UpdateHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public void UpdateSubscriptionProcess(Config config, string subId, bool blProxy,
191191
//more url
192192
if (Utils.IsNullOrEmpty(item.convertTarget) && Utils.IsNotEmpty(item.moreUrl.TrimEx()))
193193
{
194-
if (Utils.IsNotEmpty(result) && Utils.IsBase64String(result!))
194+
if (Utils.IsNotEmpty(result) && Utils.IsBase64String(result))
195195
{
196196
result = Utils.Base64Decode(result);
197197
}
@@ -212,7 +212,7 @@ public void UpdateSubscriptionProcess(Config config, string subId, bool blProxy,
212212
}
213213
if (Utils.IsNotEmpty(result2))
214214
{
215-
if (Utils.IsBase64String(result2!))
215+
if (Utils.IsBase64String(result2))
216216
{
217217
result += Utils.Base64Decode(result2);
218218
}
@@ -368,7 +368,7 @@ private async Task<ResultEventArgs> ParseDownloadUrl(ECoreType type, string gitH
368368
{
369369
var gitHubReleases = JsonUtils.Deserialize<List<GitHubRelease>>(gitHubReleaseApi);
370370
var gitHubRelease = preRelease ? gitHubReleases?.First() : gitHubReleases?.First(r => r.Prerelease == false);
371-
var version = new SemanticVersion(gitHubRelease?.TagName!);
371+
var version = new SemanticVersion(gitHubRelease?.TagName);
372372
var body = gitHubRelease?.Body;
373373

374374
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type);

0 commit comments

Comments
 (0)