From b99b30163bb4fb54eeca0062e9b7c2a23d394437 Mon Sep 17 00:00:00 2001
From: 2dust <31833384+2dust@users.noreply.github.com>
Date: Mon, 3 Jun 2024 07:37:26 +0800
Subject: [PATCH] Bug fix
---
v2rayN/v2rayN/Common/JsonUtils.cs | 12 +++++++-----
v2rayN/v2rayN/Handler/CoreConfigSingbox.cs | 5 +++++
v2rayN/v2rayN/Handler/CoreHandler.cs | 3 ++-
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/v2rayN/v2rayN/Common/JsonUtils.cs b/v2rayN/v2rayN/Common/JsonUtils.cs
index 2198ba35..ab81d41e 100644
--- a/v2rayN/v2rayN/Common/JsonUtils.cs
+++ b/v2rayN/v2rayN/Common/JsonUtils.cs
@@ -105,9 +105,12 @@ namespace v2rayN
///
///
///
- public static int ToFile(object? obj, string filePath, bool nullValue = true)
+ public static int ToFile(object? obj, string? filePath, bool nullValue = true)
{
- int result;
+ if (filePath is null)
+ {
+ return -1;
+ }
try
{
using FileStream file = File.Create(filePath);
@@ -119,14 +122,13 @@ namespace v2rayN
};
JsonSerializer.Serialize(file, obj, options);
- result = 0;
+ return 0;
}
catch (Exception ex)
{
Logging.SaveLog(ex.Message, ex);
- result = -1;
+ return -1;
}
- return result;
}
}
}
\ No newline at end of file
diff --git a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs
index c2cd926c..1fc6858c 100644
--- a/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs
+++ b/v2rayN/v2rayN/Handler/CoreConfigSingbox.cs
@@ -25,6 +25,11 @@ namespace v2rayN.Handler
msg = ResUI.CheckServerSettings;
return -1;
}
+ if (node.GetNetwork() == nameof(ETransport.kcp))
+ {
+ msg = ResUI.Incorrectconfiguration + $" - {node.GetNetwork()}";
+ return -1;
+ }
msg = ResUI.InitialConfiguration;
diff --git a/v2rayN/v2rayN/Handler/CoreHandler.cs b/v2rayN/v2rayN/Handler/CoreHandler.cs
index b6b37c2f..05a8e08b 100644
--- a/v2rayN/v2rayN/Handler/CoreHandler.cs
+++ b/v2rayN/v2rayN/Handler/CoreHandler.cs
@@ -38,7 +38,8 @@ namespace v2rayN.Handler
string fileName = Utils.GetConfigPath(Global.CoreConfigFileName);
if (CoreConfigHandler.GenerateClientConfig(node, fileName, out string msg, out string content) != 0)
{
- ShowMsg(false, msg);
+ ShowMsg(false, msg);
+ return;
}
else
{