Compare commits

..

2 commits

Author SHA1 Message Date
DHR60
0cb205eea9
Merge 733987742e into 22f0d04f01 2025-10-03 14:13:50 +08:00
2dust
22f0d04f01 Fix
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run
https://github.com/2dust/v2rayN/issues/8060
2025-10-03 14:13:03 +08:00
6 changed files with 29 additions and 24 deletions

View file

@ -85,13 +85,19 @@ public class Utils
/// Base64 Encode /// Base64 Encode
/// </summary> /// </summary>
/// <param name="plainText"></param> /// <param name="plainText"></param>
/// <param name="removePadding"></param>
/// <returns></returns> /// <returns></returns>
public static string Base64Encode(string plainText) public static string Base64Encode(string plainText, bool removePadding = false)
{ {
try try
{ {
var plainTextBytes = Encoding.UTF8.GetBytes(plainText); 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) catch (Exception ex)
{ {
@ -112,7 +118,7 @@ public class Utils
{ {
if (plainText.IsNullOrEmpty()) if (plainText.IsNullOrEmpty())
{ {
return ""; return string.Empty;
} }
plainText = plainText.Trim() plainText = plainText.Trim()
@ -947,7 +953,7 @@ public class Utils
if (SetUnixFileMode(fileName)) if (SetUnixFileMode(fileName))
{ {
Logging.SaveLog($"Successfully set the file execution permission, {fileName}"); Logging.SaveLog($"Successfully set the file execution permission, {fileName}");
return ""; return string.Empty;
} }
if (fileName.Contains(' ')) if (fileName.Contains(' '))

View file

@ -27,7 +27,7 @@ public class FmtHandler
catch (Exception ex) catch (Exception ex)
{ {
Logging.SaveLog(_tag, ex); Logging.SaveLog(_tag, ex);
return ""; return string.Empty;
} }
} }

View file

@ -42,7 +42,7 @@ public class ShadowsocksFmt : BaseFmt
// item.port); // item.port);
//url = Utile.Base64Encode(url); //url = Utile.Base64Encode(url);
//new Sip002 //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); return ToUri(EConfigType.Shadowsocks, item.Address, item.Port, pw, null, remark);
} }

View file

@ -33,7 +33,7 @@ public class SocksFmt : BaseFmt
remark = "#" + Utils.UrlEncode(item.Remarks); remark = "#" + Utils.UrlEncode(item.Remarks);
} }
//new //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); return ToUri(EConfigType.SOCKS, item.Address, item.Port, pw, null, remark);
} }

View file

@ -8,7 +8,6 @@ public sealed class AppManager
private Config _config; private Config _config;
private int? _statePort; private int? _statePort;
private int? _statePort2; private int? _statePort2;
private WindowsJob? _processJob;
public static AppManager Instance => _instance.Value; public static AppManager Instance => _instance.Value;
public Config Config => _config; public Config Config => _config;
@ -136,21 +135,6 @@ public sealed class AppManager
return localPort + (int)protocol; return localPort + (int)protocol;
} }
public void AddProcess(nint processHandle)
{
if (Utils.IsWindows())
{
_processJob ??= new();
try
{
_processJob?.AddProcess(processHandle);
}
catch
{
}
}
}
#endregion Config #endregion Config
#region SqliteHelper #region SqliteHelper

View file

@ -8,6 +8,7 @@ public class CoreManager
private static readonly Lazy<CoreManager> _instance = new(() => new()); private static readonly Lazy<CoreManager> _instance = new(() => new());
public static CoreManager Instance => _instance.Value; public static CoreManager Instance => _instance.Value;
private Config _config; private Config _config;
private WindowsJob? _processJob;
private ProcessService? _processService; private ProcessService? _processService;
private ProcessService? _processPreService; private ProcessService? _processPreService;
private bool _linuxSudo = false; private bool _linuxSudo = false;
@ -264,14 +265,28 @@ public class CoreManager
await procService.StartAsync(); await procService.StartAsync();
await Task.Delay(100); await Task.Delay(100);
AppManager.Instance.AddProcess(procService.Handle);
if (procService is null or { HasExited: true }) if (procService is null or { HasExited: true })
{ {
throw new Exception(ResUI.FailedToRunCore); throw new Exception(ResUI.FailedToRunCore);
} }
AddProcessJob(procService.Handle);
return procService; return procService;
} }
private void AddProcessJob(nint processHandle)
{
if (Utils.IsWindows())
{
_processJob ??= new();
try
{
_processJob?.AddProcess(processHandle);
}
catch { }
}
}
#endregion Process #endregion Process
} }