mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-14 05:12:09 +08:00
Correct and optimize the code
This commit is contained in:
parent
8a81ba59dc
commit
c43bc49feb
@ -204,6 +204,8 @@ public partial class MainWin : Window
|
|||||||
{
|
{
|
||||||
HoldButtonTimer?.Stop();
|
HoldButtonTimer?.Stop();
|
||||||
|
|
||||||
|
NginxConfWatcher_Changed(null!, null!);
|
||||||
|
|
||||||
if (!MainPres.IsConginxRunning && !MainPres.IsNginxRunning)
|
if (!MainPres.IsConginxRunning && !MainPres.IsNginxRunning)
|
||||||
{
|
{
|
||||||
if (NginxCleaner.IsNginxCleaningSemaphore.CurrentCount == 0 || !await IsNginxLaunchingSemaphore.WaitAsync(0))
|
if (NginxCleaner.IsNginxCleaningSemaphore.CurrentCount == 0 || !await IsNginxLaunchingSemaphore.WaitAsync(0))
|
||||||
@ -772,13 +774,9 @@ public partial class MainWin : Window
|
|||||||
NginxHttpPort = 80;
|
NginxHttpPort = 80;
|
||||||
NginxHttpsPort = 443;
|
NginxHttpsPort = 443;
|
||||||
|
|
||||||
foreach (IPEndPoint activeTcpListener in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners())
|
HashSet<int> activePorts = new(IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners().Select(listener => listener.Port));
|
||||||
if (activeTcpListener.Port == NginxHttpPort)
|
while (activePorts.Contains(NginxHttpPort)) NginxHttpPort++;
|
||||||
NginxHttpPort++;
|
while (activePorts.Contains(NginxHttpsPort)) NginxHttpsPort++;
|
||||||
else if (activeTcpListener.Port == NginxHttpsPort)
|
|
||||||
NginxHttpsPort++;
|
|
||||||
else if (activeTcpListener.Port > NginxHttpsPort)
|
|
||||||
break;
|
|
||||||
|
|
||||||
await using FileStream nginxConfStream = new(MainConst.NginxConfPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
await using FileStream nginxConfStream = new(MainConst.NginxConfPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||||
NginxConfig extraNginxConfig = NginxConfig.Load(ExtraNginxConfs = new StreamReader(nginxConfStream).ReadToEnd());
|
NginxConfig extraNginxConfig = NginxConfig.Load(ExtraNginxConfs = new StreamReader(nginxConfStream).ReadToEnd());
|
||||||
|
Loading…
Reference in New Issue
Block a user