mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-13 12:52:08 +08:00
1.1.3 -> 1.1.4 第81次更新
This commit is contained in:
parent
aa5765d168
commit
e962850d05
@ -91,7 +91,15 @@ public partial class MainWin : Window
|
|||||||
UpdateUpstreamHostButton_Click(null!, null!);
|
UpdateUpstreamHostButton_Click(null!, null!);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void MainWin_Closing(object sender, CancelEventArgs e) => Application.Current.Shutdown();
|
private void MainWin_Closing(object sender, CancelEventArgs e)
|
||||||
|
{
|
||||||
|
if (MainPres.IsNginxIniting)
|
||||||
|
File.WriteAllText(MainConst.NginxConfPath, ExtraNginxConfs);
|
||||||
|
if (MainPres.IsMihomoIniting)
|
||||||
|
File.WriteAllText(MainConst.MihomoConfPath, ExtraMihomoConfs);
|
||||||
|
|
||||||
|
Application.Current.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
private void MainWin_DragEnter(object sender, DragEventArgs e)
|
private void MainWin_DragEnter(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
@ -263,41 +271,46 @@ public partial class MainWin : Window
|
|||||||
File.AppendAllText(MainConst.HostsConfPath, hostsConfAppendContent);
|
File.AppendAllText(MainConst.HostsConfPath, hostsConfAppendContent);
|
||||||
#endregion Child Cert & Hosts
|
#endregion Child Cert & Hosts
|
||||||
|
|
||||||
MainPres.IsNginxIniting = true;
|
try
|
||||||
NginxConfWatcher.EnableRaisingEvents = false;
|
|
||||||
NginxConfs!.Save(MainConst.NginxConfPath);
|
|
||||||
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
new NginxProc().Run(Path.GetDirectoryName(MainConst.NginxPath), @$"-c ""{Path.GetRelativePath(Path.GetDirectoryName(MainConst.NginxPath)!, MainConst.NginxConfPath)}""");
|
MainPres.IsNginxIniting = true;
|
||||||
});
|
NginxConfWatcher.EnableRaisingEvents = false;
|
||||||
|
NginxConfs!.Save(MainConst.NginxConfPath);
|
||||||
|
|
||||||
while (true)
|
await Task.Run(() =>
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await Http.GetAsync<HttpResponseMessage>($"https://localhost:{NginxHttpsPort}", MainClient);
|
new NginxProc().Run(Path.GetDirectoryName(MainConst.NginxPath), @$"-c ""{Path.GetRelativePath(Path.GetDirectoryName(MainConst.NginxPath)!, MainConst.NginxConfPath)}""");
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
while (true)
|
||||||
}
|
|
||||||
catch (HttpRequestException ex)
|
|
||||||
{
|
{
|
||||||
if (ex.InnerException is SocketException innerEx && innerEx.SocketErrorCode != SocketError.ConnectionRefused)
|
try
|
||||||
|
{
|
||||||
|
await Http.GetAsync<HttpResponseMessage>($"https://localhost:{NginxHttpsPort}", MainClient);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
if (ex.InnerException is SocketException innerEx && innerEx.SocketErrorCode != SocketError.ConnectionRefused)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!MainPres.IsNginxRunning)
|
if (!MainPres.IsNginxRunning)
|
||||||
{
|
{
|
||||||
if (MessageBox.Show(MainConst._LaunchNginxErrorPrompt, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
if (MessageBox.Show(MainConst._LaunchNginxErrorPrompt, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
|
||||||
Process.Start(new ProcessStartInfo(MainConst.NginxErrorLogsPath) { UseShellExecute = true });
|
Process.Start(new ProcessStartInfo(MainConst.NginxErrorLogsPath) { UseShellExecute = true });
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
File.WriteAllText(MainConst.NginxConfPath, ExtraNginxConfs);
|
{
|
||||||
NginxConfWatcher.EnableRaisingEvents = true;
|
File.WriteAllText(MainConst.NginxConfPath, ExtraNginxConfs);
|
||||||
MainPres.IsNginxIniting = false;
|
NginxConfWatcher.EnableRaisingEvents = true;
|
||||||
|
MainPres.IsNginxIniting = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -339,40 +352,45 @@ public partial class MainWin : Window
|
|||||||
if (!File.Exists(MainConst.MihomoConfPath))
|
if (!File.Exists(MainConst.MihomoConfPath))
|
||||||
File.Create(MainConst.MihomoConfPath).Dispose();
|
File.Create(MainConst.MihomoConfPath).Dispose();
|
||||||
|
|
||||||
MainPres.IsMihomoIniting = true;
|
try
|
||||||
MihomoConfWatcher.EnableRaisingEvents = false;
|
|
||||||
File.WriteAllText(MainConst.MihomoConfPath, MihomoConfs);
|
|
||||||
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
new MihomoProc().Run(Path.GetDirectoryName(MainConst.MihomoPath), @$"-d ""{Path.GetDirectoryName(MainConst.MihomoConfPath)}""");
|
MainPres.IsMihomoIniting = true;
|
||||||
});
|
MihomoConfWatcher.EnableRaisingEvents = false;
|
||||||
|
File.WriteAllText(MainConst.MihomoConfPath, MihomoConfs);
|
||||||
|
|
||||||
while (true)
|
await Task.Run(() =>
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
await Http.GetAsync<HttpResponseMessage>($"http://localhost:{MihomoMixedPort}", MainClient);
|
new MihomoProc().Run(Path.GetDirectoryName(MainConst.MihomoPath), @$"-d ""{Path.GetDirectoryName(MainConst.MihomoConfPath)}""");
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
while (true)
|
||||||
}
|
|
||||||
catch (HttpRequestException ex)
|
|
||||||
{
|
{
|
||||||
if (ex.InnerException is SocketException innerEx && innerEx.SocketErrorCode != SocketError.ConnectionRefused)
|
try
|
||||||
|
{
|
||||||
|
await Http.GetAsync<HttpResponseMessage>($"http://localhost:{MihomoMixedPort}", MainClient);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
if (ex.InnerException is SocketException innerEx && innerEx.SocketErrorCode != SocketError.ConnectionRefused)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!MainPres.IsMihomoRunning)
|
if (!MainPres.IsMihomoRunning)
|
||||||
{
|
{
|
||||||
MessageBox.Show(MainConst._LaunchMihomoErrorMsg);
|
MessageBox.Show(MainConst._LaunchMihomoErrorMsg);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
File.WriteAllText(MainConst.MihomoConfPath, ExtraMihomoConfs);
|
{
|
||||||
MihomoConfWatcher.EnableRaisingEvents = true;
|
File.WriteAllText(MainConst.MihomoConfPath, ExtraMihomoConfs);
|
||||||
MainPres.IsMihomoIniting = false;
|
MihomoConfWatcher.EnableRaisingEvents = true;
|
||||||
|
MainPres.IsMihomoIniting = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user