Skip to content

Commit b99b301

Browse files
committed
Bug fix
1 parent 83b4f1e commit b99b301

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

v2rayN/v2rayN/Common/JsonUtils.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ public static string Serialize(object? obj, bool indented = true)
105105
/// <param name="filePath"></param>
106106
/// <param name="nullValue"></param>
107107
/// <returns></returns>
108-
public static int ToFile(object? obj, string filePath, bool nullValue = true)
108+
public static int ToFile(object? obj, string? filePath, bool nullValue = true)
109109
{
110-
int result;
110+
if (filePath is null)
111+
{
112+
return -1;
113+
}
111114
try
112115
{
113116
using FileStream file = File.Create(filePath);
@@ -119,14 +122,13 @@ public static int ToFile(object? obj, string filePath, bool nullValue = true)
119122
};
120123

121124
JsonSerializer.Serialize(file, obj, options);
122-
result = 0;
125+
return 0;
123126
}
124127
catch (Exception ex)
125128
{
126129
Logging.SaveLog(ex.Message, ex);
127-
result = -1;
130+
return -1;
128131
}
129-
return result;
130132
}
131133
}
132134
}

v2rayN/v2rayN/Handler/CoreConfigSingbox.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public int GenerateClientConfigContent(ProfileItem node, out SingboxConfig? sing
2525
msg = ResUI.CheckServerSettings;
2626
return -1;
2727
}
28+
if (node.GetNetwork() == nameof(ETransport.kcp))
29+
{
30+
msg = ResUI.Incorrectconfiguration + $" - {node.GetNetwork()}";
31+
return -1;
32+
}
2833

2934
msg = ResUI.InitialConfiguration;
3035

v2rayN/v2rayN/Handler/CoreHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ public void LoadCore()
3838
string fileName = Utils.GetConfigPath(Global.CoreConfigFileName);
3939
if (CoreConfigHandler.GenerateClientConfig(node, fileName, out string msg, out string content) != 0)
4040
{
41-
ShowMsg(false, msg);
41+
ShowMsg(false, msg);
42+
return;
4243
}
4344
else
4445
{

0 commit comments

Comments
 (0)