1.1.3 -> 1.1.4 第17次更新

This commit is contained in:
Space Time 2024-11-27 21:15:21 +08:00
parent 9b1533b51c
commit 6b7542a3b9
4 changed files with 86 additions and 28 deletions

View File

@ -70,7 +70,7 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 The config cannot be recognized. Check if the config contain syntax errors 的本地化字符串。
/// 查找类似 The config contains syntax errors and cannot be recognized 的本地化字符串。
/// </summary>
public static string _ConfErrorMsg {
get {
@ -79,7 +79,7 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 I know you would do it, but nothing will actually happen. Whee. 的本地化字符串。
/// 查找类似 I know you would do it, but nothing will actually happen. Whee 的本地化字符串。
/// </summary>
public static string _GameClickOnceMsg {
get {
@ -88,7 +88,7 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 Ugh, what are you doing. Please stop, I don&apos;t want to hurt anyone. Stop please, this is your last chance. Ugh, I can&apos;t control it anymore. 的本地化字符串。
/// 查找类似 Ugh, what are you doing. Please stop, I don&apos;t want to hurt anyone. Stop please, this is your last chance. Ugh, I can&apos;t control it anymore 的本地化字符串。
/// </summary>
public static string _GameClickThreeMsg {
get {
@ -142,11 +142,11 @@ namespace Sheas_Cealer.Consts {
}
/// <summary>
/// 查找类似 The args cannot be recognized. Check if the hosts contain syntax errors 的本地化字符串。
/// 查找类似 Some hosts contain syntax errors and cannot be recognized. Do you want to continue anyway? 的本地化字符串。
/// </summary>
public static string _HostErrorMsg {
public static string _HostErrorPrompt {
get {
return ResourceManager.GetString("_HostErrorMsg", resourceCulture);
return ResourceManager.GetString("_HostErrorPrompt", resourceCulture);
}
}
@ -177,6 +177,24 @@ namespace Sheas_Cealer.Consts {
}
}
/// <summary>
/// 查找类似 The local port 80 is occupied, which may cause the http connection to fail to automatically jump to https. Do you want to continue? 的本地化字符串。
/// </summary>
public static string _NginxHttpPortOccupiedPrompt {
get {
return ResourceManager.GetString("_NginxHttpPortOccupiedPrompt", resourceCulture);
}
}
/// <summary>
/// 查找类似 The local port 443 is occupied, which may cause the global forgery to fail to take effect. Do you want to continue? 的本地化字符串。
/// </summary>
public static string _NginxHttpsPortOccupiedPrompt {
get {
return ResourceManager.GetString("_NginxHttpsPortOccupiedPrompt", resourceCulture);
}
}
/// <summary>
/// 查找类似 There is an update available. Do you want to update upstream host? If No it will only open the upstream host page for you 的本地化字符串。
/// </summary>

View File

@ -256,13 +256,13 @@
<value>Browser</value>
</data>
<data name="_ConfErrorMsg" xml:space="preserve">
<value>The config cannot be recognized. Check if the config contain syntax errors</value>
<value>The config contains syntax errors and cannot be recognized</value>
</data>
<data name="_GameClickOnceMsg" xml:space="preserve">
<value>I know you would do it, but nothing will actually happen. Whee.</value>
<value>I know you would do it, but nothing will actually happen. Whee</value>
</data>
<data name="_GameClickThreeMsg" xml:space="preserve">
<value>Ugh, what are you doing. Please stop, I don't want to hurt anyone. Stop please, this is your last chance. Ugh, I can't control it anymore.</value>
<value>Ugh, what are you doing. Please stop, I don't want to hurt anyone. Stop please, this is your last chance. Ugh, I can't control it anymore</value>
</data>
<data name="_GameClickTwiceMsg" xml:space="preserve">
<value>No no no, don't click me. Sorry, I shouldn't have lied to you, I am a cursed button, and continuing to click me will bring disaster to the entire Sheas Cealer. Please believe me, this is not a game, and there are no new features here. Listen to me and use the normal functions, okay?</value>
@ -279,8 +279,8 @@
<data name="_GameStartMsg" xml:space="preserve">
<value>No, please kill me, I...can't control myself...</value>
</data>
<data name="_HostErrorMsg" xml:space="preserve">
<value>The args cannot be recognized. Check if the hosts contain syntax errors</value>
<data name="_HostErrorPrompt" xml:space="preserve">
<value>Some hosts contain syntax errors and cannot be recognized. Do you want to continue anyway?</value>
</data>
<data name="_KillBrowserProcessPrompt" xml:space="preserve">
<value>All processes of the selected browser will be closed before launching. Do you want to continue?</value>
@ -291,6 +291,12 @@
<data name="_LaunchProxyPrompt" xml:space="preserve">
<value>Please remember to come back and stop the proxy manually after use. Do you want to continue?</value>
</data>
<data name="_NginxHttpPortOccupiedPrompt" xml:space="preserve">
<value>The local port 80 is occupied, which may cause the http connection to fail to automatically jump to https. Do you want to continue?</value>
</data>
<data name="_NginxHttpsPortOccupiedPrompt" xml:space="preserve">
<value>The local port 443 is occupied, which may cause the global forgery to fail to take effect. Do you want to continue?</value>
</data>
<data name="_OverrideUpstreamHostPrompt" xml:space="preserve">
<value>There is an update available. Do you want to update upstream host? If No it will only open the upstream host page for you</value>
</data>

View File

@ -256,7 +256,7 @@
<value>浏览器</value>
</data>
<data name="_ConfErrorMsg" xml:space="preserve">
<value>配置无法识别,请检查配置文件中是否含有语法错误</value>
<value>配置文件中含有语法错误,配置无法识别</value>
</data>
<data name="_GameClickOnceMsg" xml:space="preserve">
<value>就知道你会点,但其实什么事情都不会发生的。嘻嘻</value>
@ -279,8 +279,8 @@
<data name="_GameStartMsg" xml:space="preserve">
<value>不,求你杀了我,我...控制不住了...</value>
</data>
<data name="_HostErrorMsg" xml:space="preserve">
<value>规则无法识别,请检查伪造规则中是否含有语法错误</value>
<data name="_HostErrorPrompt" xml:space="preserve">
<value>伪造规则中含有语法错误,部分规则无法识别,是否仍然继续?</value>
</data>
<data name="_KillBrowserProcessPrompt" xml:space="preserve">
<value>启动前将关闭所选浏览器的所有进程,是否继续?</value>
@ -291,6 +291,12 @@
<data name="_LaunchProxyPrompt" xml:space="preserve">
<value>使用完请务必记得回来手动关闭代理,是否继续?</value>
</data>
<data name="_NginxHttpPortOccupiedPrompt" xml:space="preserve">
<value>本地 80 端口被占用,这可能导致 http 连接无法自动跳转到 https是否继续?</value>
</data>
<data name="_NginxHttpsPortOccupiedPrompt" xml:space="preserve">
<value>本地 443 端口被占用,这可能导致全局伪造无法正常生效,是否继续?</value>
</data>
<data name="_OverrideUpstreamHostPrompt" xml:space="preserve">
<value>上游规则有更新可用,需要更新吗?否则只为你打开上游规则网页</value>
</data>

View File

@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
@ -45,6 +47,12 @@ public partial class MainWin : Window
private static string? MihomoConfs;
private static string? ExtraMihomoConfs;
private static bool IsCealHostError = false;
private static int NginxHttpPort = 80;
private static int NginxHttpsPort = 443;
private static int MihomoMixedPort = 7880;
private static int GameClickTime = 0;
private static int GameFlashInterval = 1000;
@ -150,9 +158,8 @@ public partial class MainWin : Window
{
HoldButtonTimer?.Stop();
if (string.IsNullOrWhiteSpace(CealArgs))
throw new Exception(MainConst._HostErrorMsg);
if (MessageBox.Show(MainConst._KillBrowserProcessPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
if ((IsCealHostError && MessageBox.Show(MainConst._HostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
(MessageBox.Show(MainConst._KillBrowserProcessPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
return;
foreach (Process browserProcess in Process.GetProcessesByName(Path.GetFileNameWithoutExtension(MainPres!.BrowserPath)))
@ -183,11 +190,11 @@ public partial class MainWin : Window
if (!MainPres!.IsNginxRunning)
{
if (string.IsNullOrWhiteSpace(CealArgs))
throw new Exception(MainConst._HostErrorMsg);
if (MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
return;
if (MainPres.IsFlashing && MessageBox.Show(MainConst._LaunchNginxFlashingPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
if ((IsCealHostError && MessageBox.Show(MainConst._HostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
(NginxHttpPort != 80 && MessageBox.Show(MainConst._NginxHttpPortOccupiedPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
(NginxHttpsPort != 443 && MessageBox.Show(MainConst._NginxHttpsPortOccupiedPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
(MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
(MainPres.IsFlashing && MessageBox.Show(MainConst._LaunchNginxFlashingPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
return;
if (!File.Exists(MainConst.NginxConfPath))
@ -256,7 +263,7 @@ public partial class MainWin : Window
{
try
{
await Http.GetAsync<HttpResponseMessage>("https://localhost", MainClient);
await Http.GetAsync<HttpResponseMessage>($"https://localhost:{NginxHttpPort}", MainClient);
break;
}
catch (HttpRequestException ex) when (ex.InnerException is SocketException innerEx)
@ -318,7 +325,7 @@ public partial class MainWin : Window
{
try
{
await Http.GetAsync<HttpResponseMessage>("http://localhost:7880", MainClient);
await Http.GetAsync<HttpResponseMessage>($"http://localhost:{MihomoMixedPort}", MainClient);
break;
}
catch (HttpRequestException ex) when (ex.InnerException is SocketException innerEx)
@ -509,8 +516,15 @@ public partial class MainWin : Window
if (cealHostDomainPairs.Count != 0)
CealHostRulesDict[cealHostName].Add((cealHostDomainPairs, cealHostSni, cealHostIp));
}
IsCealHostError = false;
}
catch
{
CealHostRulesDict.Remove(cealHostName);
IsCealHostError = true;
}
catch { CealHostRulesDict.Remove(cealHostName); }
finally
{
string hostRules = string.Empty;
@ -552,6 +566,14 @@ public partial class MainWin : Window
if (!Directory.Exists(MainConst.NginxTempPath))
Directory.CreateDirectory(MainConst.NginxTempPath);
foreach (IPEndPoint activeTcpListener in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners())
if (activeTcpListener.Port == NginxHttpPort)
NginxHttpPort++;
else if (activeTcpListener.Port == NginxHttpsPort)
NginxHttpsPort++;
else if (activeTcpListener.Port > NginxHttpsPort)
break;
using FileStream nginxConfStream = new(MainConst.NginxConfPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
ExtraNginxConfs = new StreamReader(nginxConfStream).ReadToEnd();
@ -573,7 +595,7 @@ public partial class MainWin : Window
.AddOrUpdate("events:worker_connections", "65536")
.AddOrUpdate("http:proxy_set_header", "Host $http_host")
.AddOrUpdate("http:proxy_ssl_server_name", !MainPres.IsFlashing ? "on" : "off")
.AddOrUpdate($"http:server[{serverIndex}]:listen", "80 default_server")
.AddOrUpdate($"http:server[{serverIndex}]:listen", $"{NginxHttpPort} default_server")
.AddOrUpdate($"http:server[{serverIndex}]:return", "https://$host$request_uri");
foreach (List<(List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp)> cealHostRules in CealHostRulesDict.Values)
@ -597,7 +619,7 @@ public partial class MainWin : Window
NginxConfs = NginxConfs
.AddOrUpdate($"http:server[{serverIndex}]:server_name", serverName.TrimEnd('|'))
.AddOrUpdate($"http:server[{serverIndex}]:listen", "443 ssl")
.AddOrUpdate($"http:server[{serverIndex}]:listen", $"{NginxHttpsPort} ssl")
.AddOrUpdate($"http:server[{serverIndex}]:ssl_certificate", Path.GetFileName(MainConst.NginxCertPath))
.AddOrUpdate($"http:server[{serverIndex}]:ssl_certificate_key", Path.GetFileName(MainConst.NginxKeyPath))
.AddOrUpdate($"http:server[{serverIndex}]:location", "/", true)
@ -618,6 +640,12 @@ public partial class MainWin : Window
if (!File.Exists(MainConst.MihomoConfPath))
File.Create(MainConst.MihomoConfPath).Dispose();
foreach (IPEndPoint activeTcpListener in IPGlobalProperties.GetIPGlobalProperties().GetActiveTcpListeners())
if (activeTcpListener.Port == MihomoMixedPort)
MihomoMixedPort++;
else if (activeTcpListener.Port > MihomoMixedPort)
break;
using FileStream mihomoConfStream = new(MainConst.MihomoConfPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
ExtraMihomoConfs = new StreamReader(mihomoConfStream).ReadToEnd();
@ -627,7 +655,7 @@ public partial class MainWin : Window
.Build()
.Deserialize<Dictionary<string, object>>(ExtraMihomoConfs) ?? [];
mihomoConfDict["mixed-port"] = 7880;
mihomoConfDict["mixed-port"] = MihomoMixedPort;
mihomoConfDict["dns"] = new
{
enable = true,