Code clean
Some checks are pending
release macos / build (Release) (push) Waiting to run
release / build (Release) (push) Waiting to run

This commit is contained in:
2dust 2024-11-29 19:21:09 +08:00
parent 1c6323315b
commit f685682214
6 changed files with 14 additions and 34 deletions

View file

@ -25,7 +25,7 @@ namespace ServiceLib.Handler
await SetTaskLinux();
}
}
else if(Utils.IsOSX())
else if (Utils.IsOSX())
{
//TODO
}

View file

@ -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)

View file

@ -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>

View file

@ -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;

View file

@ -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();

View file

@ -405,4 +405,4 @@ namespace ServiceLib.ViewModels
}
}
}
}
}