mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 13:42:24 +00:00
Code clean
This commit is contained in:
parent
1c6323315b
commit
f685682214
6 changed files with 14 additions and 34 deletions
|
@ -25,7 +25,7 @@ namespace ServiceLib.Handler
|
||||||
await SetTaskLinux();
|
await SetTaskLinux();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(Utils.IsOSX())
|
else if (Utils.IsOSX())
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,15 +98,11 @@ namespace ServiceLib.Handler
|
||||||
if (_process != null)
|
if (_process != null)
|
||||||
{
|
{
|
||||||
await KillProcess(_process);
|
await KillProcess(_process);
|
||||||
_process.Dispose();
|
|
||||||
_process = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_processPre != null)
|
if (_processPre != null)
|
||||||
{
|
{
|
||||||
await KillProcess(_processPre);
|
await KillProcess(_processPre);
|
||||||
_processPre.Dispose();
|
|
||||||
_processPre = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_linuxSudoPid > 0)
|
if (_linuxSudoPid > 0)
|
||||||
|
@ -125,8 +121,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var _p = Process.GetProcessById(pid);
|
await KillProcess(Process.GetProcessById(pid));
|
||||||
await KillProcess(_p);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -332,26 +327,11 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try
|
try { proc?.Kill(true); } catch { }
|
||||||
{
|
try { proc?.Close(); } catch { }
|
||||||
proc?.Kill(true);
|
try { proc?.Dispose(); } catch { }
|
||||||
}
|
proc = null;
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
if (proc?.HasExited == false)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
proc?.Kill();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// ignored
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Process
|
#endregion Process
|
||||||
|
@ -408,7 +388,7 @@ namespace ServiceLib.Handler
|
||||||
|
|
||||||
var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
||||||
await proc.WaitForExitAsync(timeout.Token);
|
await proc.WaitForExitAsync(timeout.Token);
|
||||||
await Task.Delay(1000);
|
await Task.Delay(3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string> CreateLinuxShellFile(string cmdLine, string fileName)
|
private async Task<string> CreateLinuxShellFile(string cmdLine, string fileName)
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>7.2.3</Version>
|
<Version>7.2.2</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
ret.Msg = ResUI.CheckServerSettings;
|
ret.Msg = ResUI.CheckServerSettings;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (node.GetNetwork() is nameof(ETransport.kcp) or nameof(ETransport.xhttp))
|
if (node.GetNetwork() is nameof(ETransport.kcp) or nameof(ETransport.xhttp))
|
||||||
{
|
{
|
||||||
ret.Msg = ResUI.Incorrectconfiguration + $" - {node.GetNetwork()}";
|
ret.Msg = ResUI.Incorrectconfiguration + $" - {node.GetNetwork()}";
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -548,7 +548,7 @@ namespace ServiceLib.Services.CoreConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
var tunInbound = JsonUtils.Deserialize<Inbound4Sbox>(Utils.GetEmbedText(Global.TunSingboxInboundFileName)) ?? new Inbound4Sbox { };
|
var tunInbound = JsonUtils.Deserialize<Inbound4Sbox>(Utils.GetEmbedText(Global.TunSingboxInboundFileName)) ?? new Inbound4Sbox { };
|
||||||
tunInbound.interface_name = Utils.IsOSX()? $"utun{new Random().Next(99)}": "singbox_tun";
|
tunInbound.interface_name = Utils.IsOSX() ? $"utun{new Random().Next(99)}" : "singbox_tun";
|
||||||
tunInbound.mtu = _config.TunModeItem.Mtu;
|
tunInbound.mtu = _config.TunModeItem.Mtu;
|
||||||
tunInbound.strict_route = _config.TunModeItem.StrictRoute;
|
tunInbound.strict_route = _config.TunModeItem.StrictRoute;
|
||||||
tunInbound.stack = _config.TunModeItem.Stack;
|
tunInbound.stack = _config.TunModeItem.Stack;
|
||||||
|
|
|
@ -185,7 +185,7 @@ namespace ServiceLib.Services
|
||||||
{
|
{
|
||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
{
|
{
|
||||||
CoreHandler.Instance.CoreStopPid(pid);
|
await CoreHandler.Instance.CoreStopPid(pid);
|
||||||
}
|
}
|
||||||
await ProfileExHandler.Instance.SaveTo();
|
await ProfileExHandler.Instance.SaveTo();
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ namespace ServiceLib.Services
|
||||||
|
|
||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
{
|
{
|
||||||
CoreHandler.Instance.CoreStopPid(pid);
|
await CoreHandler.Instance.CoreStopPid(pid);
|
||||||
}
|
}
|
||||||
UpdateFunc("", ResUI.SpeedtestingCompleted);
|
UpdateFunc("", ResUI.SpeedtestingCompleted);
|
||||||
await ProfileExHandler.Instance.SaveTo();
|
await ProfileExHandler.Instance.SaveTo();
|
||||||
|
@ -317,7 +317,7 @@ namespace ServiceLib.Services
|
||||||
|
|
||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
{
|
{
|
||||||
CoreHandler.Instance.CoreStopPid(pid);
|
await CoreHandler.Instance.CoreStopPid(pid);
|
||||||
}
|
}
|
||||||
UpdateFunc("", ResUI.SpeedtestingCompleted);
|
UpdateFunc("", ResUI.SpeedtestingCompleted);
|
||||||
await ProfileExHandler.Instance.SaveTo();
|
await ProfileExHandler.Instance.SaveTo();
|
||||||
|
|
|
@ -405,4 +405,4 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue