mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-14 05:12:09 +08:00
1.1.3 -> 1.1.4 第19次更新
This commit is contained in:
parent
426596f780
commit
460826b1ee
@ -256,7 +256,7 @@
|
|||||||
<value>浏览器</value>
|
<value>浏览器</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="_ConfErrorMsg" xml:space="preserve">
|
<data name="_ConfErrorMsg" xml:space="preserve">
|
||||||
<value>配置文件中含有语法错误,配置无法识别</value>
|
<value>配置文件含有语法错误,部分配置无法识别</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="_GameClickOnceMsg" xml:space="preserve">
|
<data name="_GameClickOnceMsg" xml:space="preserve">
|
||||||
<value>就知道你会点,但其实什么事情都不会发生的。嘻嘻</value>
|
<value>就知道你会点,但其实什么事情都不会发生的。嘻嘻</value>
|
||||||
@ -280,7 +280,7 @@
|
|||||||
<value>不,求你杀了我,我...控制不住了...</value>
|
<value>不,求你杀了我,我...控制不住了...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="_HostErrorPrompt" xml:space="preserve">
|
<data name="_HostErrorPrompt" xml:space="preserve">
|
||||||
<value>伪造规则中含有语法错误,部分规则无法识别,是否仍然继续?</value>
|
<value>伪造规则含有语法错误,部分规则无法识别,是否仍然继续?</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="_KillBrowserProcessPrompt" xml:space="preserve">
|
<data name="_KillBrowserProcessPrompt" xml:space="preserve">
|
||||||
<value>启动前将关闭所选浏览器的所有进程,是否继续?</value>
|
<value>启动前将关闭所选浏览器的所有进程,是否继续?</value>
|
||||||
@ -295,7 +295,7 @@
|
|||||||
<value>本地 80 端口被占用,这可能导致 http 连接无法自动跳转到 https,是否继续?</value>
|
<value>本地 80 端口被占用,这可能导致 http 连接无法自动跳转到 https,是否继续?</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="_NginxHttpsPortOccupiedPrompt" xml:space="preserve">
|
<data name="_NginxHttpsPortOccupiedPrompt" xml:space="preserve">
|
||||||
<value>本地 443 端口被占用,这可能导致全局伪造无法正常生效,是否继续?</value>
|
<value>本地 443 端口被占用,这可能导致全局伪造无法正常工作,是否继续?</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="_OverrideUpstreamHostPrompt" xml:space="preserve">
|
<data name="_OverrideUpstreamHostPrompt" xml:space="preserve">
|
||||||
<value>上游规则有更新可用,需要更新吗?否则只为你打开上游规则网页</value>
|
<value>上游规则有更新可用,需要更新吗?否则只为你打开上游规则网页</value>
|
||||||
|
@ -47,8 +47,6 @@ public partial class MainWin : Window
|
|||||||
private static string? MihomoConfs;
|
private static string? MihomoConfs;
|
||||||
private static string? ExtraMihomoConfs;
|
private static string? ExtraMihomoConfs;
|
||||||
|
|
||||||
private static bool IsCealHostError = false;
|
|
||||||
|
|
||||||
private static int NginxHttpPort = 80;
|
private static int NginxHttpPort = 80;
|
||||||
private static int NginxHttpsPort = 443;
|
private static int NginxHttpsPort = 443;
|
||||||
private static int MihomoMixedPort = 7880;
|
private static int MihomoMixedPort = 7880;
|
||||||
@ -158,7 +156,7 @@ public partial class MainWin : Window
|
|||||||
{
|
{
|
||||||
HoldButtonTimer?.Stop();
|
HoldButtonTimer?.Stop();
|
||||||
|
|
||||||
if ((IsCealHostError && MessageBox.Show(MainConst._HostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
if ((CealHostRulesDict.ContainsValue(null!) && MessageBox.Show(MainConst._HostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||||
(MessageBox.Show(MainConst._KillBrowserProcessPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
|
(MessageBox.Show(MainConst._KillBrowserProcessPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -190,7 +188,7 @@ public partial class MainWin : Window
|
|||||||
|
|
||||||
if (!MainPres!.IsNginxRunning)
|
if (!MainPres!.IsNginxRunning)
|
||||||
{
|
{
|
||||||
if ((IsCealHostError && MessageBox.Show(MainConst._HostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
if ((CealHostRulesDict.ContainsValue(null!) && MessageBox.Show(MainConst._HostErrorPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||||
(NginxHttpPort != 80 && MessageBox.Show(MainConst._NginxHttpPortOccupiedPrompt, 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) ||
|
(NginxHttpsPort != 443 && MessageBox.Show(MainConst._NginxHttpsPortOccupiedPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||||
(MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
(MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes) ||
|
||||||
@ -366,12 +364,21 @@ public partial class MainWin : Window
|
|||||||
private void EditConfButton_Click(object sender, RoutedEventArgs e)
|
private void EditConfButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Button? senderButton = sender as Button;
|
Button? senderButton = sender as Button;
|
||||||
|
string confPath;
|
||||||
|
|
||||||
string confPath = senderButton == EditHostsConfButton ? MainConst.HostsConfPath :
|
if (senderButton == EditHostsConfButton)
|
||||||
senderButton == EditNginxConfButton ? MainConst.NginxConfPath : MainConst.MihomoConfPath;
|
{
|
||||||
|
confPath = MainConst.HostsConfPath;
|
||||||
|
|
||||||
if (!File.Exists(confPath))
|
File.SetAttributes(MainConst.HostsConfPath, File.GetAttributes(MainConst.HostsConfPath) & ~FileAttributes.ReadOnly);
|
||||||
File.Create(confPath).Dispose();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
confPath = senderButton == EditNginxConfButton ? MainConst.NginxConfPath : MainConst.MihomoConfPath;
|
||||||
|
|
||||||
|
if (!File.Exists(confPath))
|
||||||
|
File.Create(confPath).Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
ProcessStartInfo processStartInfo = new(confPath) { UseShellExecute = true };
|
ProcessStartInfo processStartInfo = new(confPath) { UseShellExecute = true };
|
||||||
Process.Start(processStartInfo);
|
Process.Start(processStartInfo);
|
||||||
@ -490,10 +497,12 @@ public partial class MainWin : Window
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
CealHostRulesDict[cealHostName] = [];
|
CealHostRulesDict[cealHostName] = [];
|
||||||
string cealHostRulesFragments = string.Empty;
|
|
||||||
string cealHostResolverRulesFragments = string.Empty;
|
|
||||||
|
|
||||||
using FileStream cealHostStream = new(e.FullPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
using FileStream cealHostStream = new(e.FullPath, FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete);
|
||||||
|
|
||||||
|
if (cealHostStream.Length == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
JsonDocumentOptions cealHostOptions = new() { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip };
|
JsonDocumentOptions cealHostOptions = new() { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip };
|
||||||
JsonElement cealHostArray = JsonDocument.Parse(cealHostStream, cealHostOptions).RootElement;
|
JsonElement cealHostArray = JsonDocument.Parse(cealHostStream, cealHostOptions).RootElement;
|
||||||
|
|
||||||
@ -517,25 +526,19 @@ public partial class MainWin : Window
|
|||||||
if (cealHostDomainPairs.Count != 0)
|
if (cealHostDomainPairs.Count != 0)
|
||||||
CealHostRulesDict[cealHostName].Add((cealHostDomainPairs, cealHostSni, cealHostIp));
|
CealHostRulesDict[cealHostName].Add((cealHostDomainPairs, cealHostSni, cealHostIp));
|
||||||
}
|
}
|
||||||
|
|
||||||
IsCealHostError = false;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
CealHostRulesDict.Remove(cealHostName);
|
|
||||||
|
|
||||||
IsCealHostError = true;
|
|
||||||
}
|
}
|
||||||
|
catch { CealHostRulesDict[cealHostName] = null!; }
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
string hostRules = string.Empty;
|
string hostRules = string.Empty;
|
||||||
string hostResolverRules = string.Empty;
|
string hostResolverRules = string.Empty;
|
||||||
int nullSniNum = 0;
|
int nullSniNum = 0;
|
||||||
|
|
||||||
foreach (List<(List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp)> cealHostRules in CealHostRulesDict.Values)
|
foreach (KeyValuePair<string, List<(List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp)>> cealHostRulesPair in CealHostRulesDict)
|
||||||
foreach ((List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp) in cealHostRules)
|
{
|
||||||
|
foreach ((List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp) in cealHostRulesPair.Value ?? [])
|
||||||
{
|
{
|
||||||
string cealHostSniWithoutNull = cealHostSni ?? $"{cealHostName}{CealHostRulesDict[cealHostName].Count + ++nullSniNum}";
|
string cealHostSniWithoutNull = cealHostSni ?? $"{cealHostRulesPair.Key}{(cealHostRulesPair.Value ?? []).Count + ++nullSniNum}";
|
||||||
bool isValidCealHostDomainExist = false;
|
bool isValidCealHostDomainExist = false;
|
||||||
|
|
||||||
foreach ((string cealHostIncludeDomain, string cealHostExcludeDomain) in cealHostDomainPairs)
|
foreach ((string cealHostIncludeDomain, string cealHostExcludeDomain) in cealHostDomainPairs)
|
||||||
@ -550,6 +553,7 @@ public partial class MainWin : Window
|
|||||||
if (isValidCealHostDomainExist)
|
if (isValidCealHostDomainExist)
|
||||||
hostResolverRules += $"MAP {cealHostSniWithoutNull} {cealHostIp},";
|
hostResolverRules += $"MAP {cealHostSniWithoutNull} {cealHostIp},";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CealArgs = @$"--host-rules=""{hostRules.TrimEnd(',')}"" --host-resolver-rules=""{hostResolverRules.TrimEnd(',')}"" --test-type --ignore-certificate-errors";
|
CealArgs = @$"--host-rules=""{hostRules.TrimEnd(',')}"" --host-resolver-rules=""{hostResolverRules.TrimEnd(',')}"" --test-type --ignore-certificate-errors";
|
||||||
|
|
||||||
@ -600,7 +604,7 @@ public partial class MainWin : Window
|
|||||||
.AddOrUpdate($"http:server[{serverIndex}]:return", "https://$host$request_uri");
|
.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)
|
foreach (List<(List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp)> cealHostRules in CealHostRulesDict.Values)
|
||||||
foreach ((List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp) in cealHostRules)
|
foreach ((List<(string cealHostIncludeDomain, string cealHostExcludeDomain)> cealHostDomainPairs, string? cealHostSni, string cealHostIp) in cealHostRules ?? [])
|
||||||
{
|
{
|
||||||
string serverName = "~";
|
string serverName = "~";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user