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();
|
||||
}
|
||||
}
|
||||
else if(Utils.IsOSX())
|
||||
else if (Utils.IsOSX())
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
|
|
|
@ -98,15 +98,11 @@ namespace ServiceLib.Handler
|
|||
if (_process != null)
|
||||
{
|
||||
await KillProcess(_process);
|
||||
_process.Dispose();
|
||||
_process = null;
|
||||
}
|
||||
|
||||
if (_processPre != null)
|
||||
{
|
||||
await KillProcess(_processPre);
|
||||
_processPre.Dispose();
|
||||
_processPre = null;
|
||||
}
|
||||
|
||||
if (_linuxSudoPid > 0)
|
||||
|
@ -125,8 +121,7 @@ namespace ServiceLib.Handler
|
|||
{
|
||||
try
|
||||
{
|
||||
var _p = Process.GetProcessById(pid);
|
||||
await KillProcess(_p);
|
||||
await KillProcess(Process.GetProcessById(pid));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -332,26 +327,11 @@ namespace ServiceLib.Handler
|
|||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
proc?.Kill(true);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
try { proc?.Kill(true); } catch { }
|
||||
try { proc?.Close(); } catch { }
|
||||
try { proc?.Dispose(); } catch { }
|
||||
proc = null;
|
||||
await Task.Delay(100);
|
||||
if (proc?.HasExited == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
proc?.Kill();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Process
|
||||
|
@ -408,7 +388,7 @@ namespace ServiceLib.Handler
|
|||
|
||||
var timeout = new CancellationTokenSource(TimeSpan.FromSeconds(10));
|
||||
await proc.WaitForExitAsync(timeout.Token);
|
||||
await Task.Delay(1000);
|
||||
await Task.Delay(3000);
|
||||
}
|
||||
|
||||
private async Task<string> CreateLinuxShellFile(string cmdLine, string fileName)
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>7.2.3</Version>
|
||||
<Version>7.2.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace ServiceLib.Services.CoreConfig
|
|||
ret.Msg = ResUI.CheckServerSettings;
|
||||
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()}";
|
||||
return ret;
|
||||
|
@ -548,7 +548,7 @@ namespace ServiceLib.Services.CoreConfig
|
|||
}
|
||||
|
||||
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.strict_route = _config.TunModeItem.StrictRoute;
|
||||
tunInbound.stack = _config.TunModeItem.Stack;
|
||||
|
|
|
@ -185,7 +185,7 @@ namespace ServiceLib.Services
|
|||
{
|
||||
if (pid > 0)
|
||||
{
|
||||
CoreHandler.Instance.CoreStopPid(pid);
|
||||
await CoreHandler.Instance.CoreStopPid(pid);
|
||||
}
|
||||
await ProfileExHandler.Instance.SaveTo();
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ namespace ServiceLib.Services
|
|||
|
||||
if (pid > 0)
|
||||
{
|
||||
CoreHandler.Instance.CoreStopPid(pid);
|
||||
await CoreHandler.Instance.CoreStopPid(pid);
|
||||
}
|
||||
UpdateFunc("", ResUI.SpeedtestingCompleted);
|
||||
await ProfileExHandler.Instance.SaveTo();
|
||||
|
@ -317,7 +317,7 @@ namespace ServiceLib.Services
|
|||
|
||||
if (pid > 0)
|
||||
{
|
||||
CoreHandler.Instance.CoreStopPid(pid);
|
||||
await CoreHandler.Instance.CoreStopPid(pid);
|
||||
}
|
||||
UpdateFunc("", ResUI.SpeedtestingCompleted);
|
||||
await ProfileExHandler.Instance.SaveTo();
|
||||
|
|
|
@ -405,4 +405,4 @@ namespace ServiceLib.ViewModels
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue