mirror of
https://github.com/SpaceTimee/Sheas-Cealer.git
synced 2025-07-14 05:12:09 +08:00
1.1.1 -> 1.1.2 第36次更新
This commit is contained in:
parent
c8f2a208a2
commit
35adc69eb2
@ -22,7 +22,8 @@ using OnaCore;
|
|||||||
using Sheas_Cealer.Consts;
|
using Sheas_Cealer.Consts;
|
||||||
using Sheas_Cealer.Preses;
|
using Sheas_Cealer.Preses;
|
||||||
using Sheas_Cealer.Utils;
|
using Sheas_Cealer.Utils;
|
||||||
using YamlDotNet.RepresentationModel;
|
using YamlDotNet.Serialization;
|
||||||
|
using YamlDotNet.Serialization.NamingConventions;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
|
|
||||||
namespace Sheas_Cealer.Wins;
|
namespace Sheas_Cealer.Wins;
|
||||||
@ -306,25 +307,40 @@ public partial class MainWin : Window
|
|||||||
if (MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
if (MessageBox.Show(MainConst._LaunchProxyPrompt, string.Empty, MessageBoxButton.YesNo) != MessageBoxResult.Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
string configPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "config.yaml");
|
string confPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "config.yaml");
|
||||||
|
|
||||||
if (!File.Exists(configPath))
|
if (!File.Exists(confPath))
|
||||||
File.Create(configPath).Dispose();
|
File.Create(confPath).Dispose();
|
||||||
|
|
||||||
YamlStream configStream = [];
|
Dictionary<string, object> mihomoConfs = new DeserializerBuilder()
|
||||||
YamlMappingNode configMapNode;
|
.WithNamingConvention(HyphenatedNamingConvention.Instance)
|
||||||
YamlNode mihomoPortNode;
|
.Build().Deserialize<Dictionary<string, object>>(File.ReadAllText(confPath)) ?? []; ;
|
||||||
|
|
||||||
configStream.Load(File.OpenText(configPath));
|
mihomoConfs["mixed-port"] = 7880;
|
||||||
|
mihomoConfs["ipv6"] = true;
|
||||||
|
mihomoConfs["log-level"] = "silent";
|
||||||
|
mihomoConfs["dns"] = new
|
||||||
|
{
|
||||||
|
enable = true,
|
||||||
|
listen = ":53",
|
||||||
|
enhancedMode = "redir-host",
|
||||||
|
nameserver = new[] { "https://dns.alidns.com/dns-query" },
|
||||||
|
fallback = new[] { "https://doh.apad.pro/dns-query" }
|
||||||
|
};
|
||||||
|
mihomoConfs["tun"] = new
|
||||||
|
{
|
||||||
|
enable = true,
|
||||||
|
stack = "system",
|
||||||
|
autoRoute = true,
|
||||||
|
autoDetectInterface = true,
|
||||||
|
dnsHijack = new[] { "any:53", "tcp://any:53" }
|
||||||
|
};
|
||||||
|
mihomoConfs["rules"] = new[] { "MATCH,DIRECT" };
|
||||||
|
|
||||||
try { configMapNode = (YamlMappingNode)configStream.Documents[0].RootNode; }
|
File.WriteAllText(confPath, new SerializerBuilder().WithNamingConvention(HyphenatedNamingConvention.Instance).Build().Serialize(mihomoConfs));
|
||||||
catch { throw new Exception(MainConst._ConfErrorMsg); }
|
|
||||||
|
|
||||||
if (!configMapNode.Children.TryGetValue("mixed-port", out mihomoPortNode!) && !configMapNode.Children.TryGetValue("port", out mihomoPortNode!))
|
|
||||||
mihomoPortNode = "7890";
|
|
||||||
|
|
||||||
proxyKey.SetValue("ProxyEnable", 1);
|
proxyKey.SetValue("ProxyEnable", 1);
|
||||||
proxyKey.SetValue("ProxyServer", "127.0.0.1:" + mihomoPortNode);
|
proxyKey.SetValue("ProxyServer", "127.0.0.1:7880");
|
||||||
|
|
||||||
new MihomoProc().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "-d .");
|
new MihomoProc().ShellRun(AppDomain.CurrentDomain.SetupInformation.ApplicationBase!, "-d .");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user