diff --git a/v2rayN/ServiceLib/Common/Utils.cs b/v2rayN/ServiceLib/Common/Utils.cs
index 358d4e9a..85182a60 100644
--- a/v2rayN/ServiceLib/Common/Utils.cs
+++ b/v2rayN/ServiceLib/Common/Utils.cs
@@ -85,13 +85,19 @@ public class Utils
/// Base64 Encode
///
///
+ ///
///
- public static string Base64Encode(string plainText)
+ public static string Base64Encode(string plainText, bool removePadding = false)
{
try
{
var plainTextBytes = Encoding.UTF8.GetBytes(plainText);
- return Convert.ToBase64String(plainTextBytes);
+ var base64 = Convert.ToBase64String(plainTextBytes);
+ if (removePadding)
+ {
+ base64 = base64.TrimEnd('=');
+ }
+ return base64;
}
catch (Exception ex)
{
@@ -112,7 +118,7 @@ public class Utils
{
if (plainText.IsNullOrEmpty())
{
- return "";
+ return string.Empty;
}
plainText = plainText.Trim()
@@ -947,7 +953,7 @@ public class Utils
if (SetUnixFileMode(fileName))
{
Logging.SaveLog($"Successfully set the file execution permission, {fileName}");
- return "";
+ return string.Empty;
}
if (fileName.Contains(' '))
diff --git a/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs b/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs
index 814d753d..decda17f 100644
--- a/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs
+++ b/v2rayN/ServiceLib/Handler/Fmt/FmtHandler.cs
@@ -27,7 +27,7 @@ public class FmtHandler
catch (Exception ex)
{
Logging.SaveLog(_tag, ex);
- return "";
+ return string.Empty;
}
}
diff --git a/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs
index 2c9898e9..2ec9769f 100644
--- a/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs
+++ b/v2rayN/ServiceLib/Handler/Fmt/ShadowsocksFmt.cs
@@ -42,7 +42,7 @@ public class ShadowsocksFmt : BaseFmt
// item.port);
//url = Utile.Base64Encode(url);
//new Sip002
- var pw = Utils.Base64Encode($"{item.Security}:{item.Id}");
+ var pw = Utils.Base64Encode($"{item.Security}:{item.Id}", true);
return ToUri(EConfigType.Shadowsocks, item.Address, item.Port, pw, null, remark);
}
diff --git a/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs b/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs
index 6110d784..dbecdade 100644
--- a/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs
+++ b/v2rayN/ServiceLib/Handler/Fmt/SocksFmt.cs
@@ -33,7 +33,7 @@ public class SocksFmt : BaseFmt
remark = "#" + Utils.UrlEncode(item.Remarks);
}
//new
- var pw = Utils.Base64Encode($"{item.Security}:{item.Id}");
+ var pw = Utils.Base64Encode($"{item.Security}:{item.Id}", true);
return ToUri(EConfigType.SOCKS, item.Address, item.Port, pw, null, remark);
}
diff --git a/v2rayN/ServiceLib/Manager/AppManager.cs b/v2rayN/ServiceLib/Manager/AppManager.cs
index 16aa4253..fb2a3f39 100644
--- a/v2rayN/ServiceLib/Manager/AppManager.cs
+++ b/v2rayN/ServiceLib/Manager/AppManager.cs
@@ -8,7 +8,6 @@ public sealed class AppManager
private Config _config;
private int? _statePort;
private int? _statePort2;
- private WindowsJob? _processJob;
public static AppManager Instance => _instance.Value;
public Config Config => _config;
@@ -136,21 +135,6 @@ public sealed class AppManager
return localPort + (int)protocol;
}
- public void AddProcess(nint processHandle)
- {
- if (Utils.IsWindows())
- {
- _processJob ??= new();
- try
- {
- _processJob?.AddProcess(processHandle);
- }
- catch
- {
- }
- }
- }
-
#endregion Config
#region SqliteHelper
diff --git a/v2rayN/ServiceLib/Manager/CoreManager.cs b/v2rayN/ServiceLib/Manager/CoreManager.cs
index 04f34d75..07876db8 100644
--- a/v2rayN/ServiceLib/Manager/CoreManager.cs
+++ b/v2rayN/ServiceLib/Manager/CoreManager.cs
@@ -8,6 +8,7 @@ public class CoreManager
private static readonly Lazy _instance = new(() => new());
public static CoreManager Instance => _instance.Value;
private Config _config;
+ private WindowsJob? _processJob;
private ProcessService? _processService;
private ProcessService? _processPreService;
private bool _linuxSudo = false;
@@ -264,14 +265,28 @@ public class CoreManager
await procService.StartAsync();
await Task.Delay(100);
- AppManager.Instance.AddProcess(procService.Handle);
+
if (procService is null or { HasExited: true })
{
throw new Exception(ResUI.FailedToRunCore);
}
+ AddProcessJob(procService.Handle);
return procService;
}
+ private void AddProcessJob(nint processHandle)
+ {
+ if (Utils.IsWindows())
+ {
+ _processJob ??= new();
+ try
+ {
+ _processJob?.AddProcess(processHandle);
+ }
+ catch { }
+ }
+ }
+
#endregion Process
}