mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 20:09:12 +00:00
Compare commits
2 commits
3488814e8e
...
66efb0f355
Author | SHA1 | Date | |
---|---|---|---|
![]() |
66efb0f355 | ||
![]() |
22f0d04f01 |
6 changed files with 29 additions and 24 deletions
|
@ -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(' '))
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
|
@ -138,21 +137,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
|
||||||
|
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue