From d951decd1f7c8e7a94d80dd0809d50fee2411f19 Mon Sep 17 00:00:00 2001 From: Space Time Date: Sun, 6 Oct 2024 14:01:43 +0800 Subject: [PATCH] =?UTF-8?q?1.1.1=20->=201.1.2=20=E7=AC=AC37=E6=AC=A1?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Wins/MainWin.xaml.cs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Wins/MainWin.xaml.cs b/Wins/MainWin.xaml.cs index 2efce43..b9b0acf 100644 --- a/Wins/MainWin.xaml.cs +++ b/Wins/MainWin.xaml.cs @@ -296,7 +296,7 @@ public partial class MainWin : Window HoldButtonTimer.Tick += MihomoButtonHoldTimer_Tick; HoldButtonTimer.Start(); } - private void MihomoButtonHoldTimer_Tick(object? sender, EventArgs e) + private async void MihomoButtonHoldTimer_Tick(object? sender, EventArgs e) { HoldButtonTimer?.Stop(); @@ -312,9 +312,11 @@ public partial class MainWin : Window if (!File.Exists(confPath)) File.Create(confPath).Dispose(); + string extraConfs = File.ReadAllText(confPath); + Dictionary mihomoConfs = new DeserializerBuilder() .WithNamingConvention(HyphenatedNamingConvention.Instance) - .Build().Deserialize>(File.ReadAllText(confPath)) ?? []; ; + .Build().Deserialize>(extraConfs) ?? []; ; mihomoConfs["mixed-port"] = 7880; mihomoConfs["ipv6"] = true; @@ -344,6 +346,20 @@ public partial class MainWin : Window new MihomoProc().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "-d ."); + while (true) + try + { + await Http.GetAsync("http://localhost:7880", MainClient); + break; + } + catch (HttpRequestException ex) when (ex.InnerException is SocketException innerEx) + { + if (innerEx.SocketErrorCode != SocketError.ConnectionRefused) + break; + } + + File.WriteAllText(confPath, extraConfs); + if (sender == null) Application.Current.Dispatcher.InvokeShutdown(); }