From f68c312a98a6b9459e9e1bcd4b9c1f1b0672a3c4 Mon Sep 17 00:00:00 2001 From: pompurin404 Date: Wed, 14 Aug 2024 22:38:16 +0800 Subject: [PATCH] fix dns switch --- src/main/config/controledMihomo.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/config/controledMihomo.ts b/src/main/config/controledMihomo.ts index ab1fb4e..e46bc14 100644 --- a/src/main/config/controledMihomo.ts +++ b/src/main/config/controledMihomo.ts @@ -17,7 +17,7 @@ export async function getControledMihomoConfig(force = false): Promise): Promise { - const { useNameserverPolicy, controlDns, controlSniff } = await getAppConfig() + const { useNameserverPolicy, controlDns = true, controlSniff = true } = await getAppConfig() if (patch.tun) { const oldTun = controledMihomoConfig.tun || {} const newTun = Object.assign(oldTun, patch.tun) @@ -27,9 +27,9 @@ export async function patchControledMihomoConfig(patch: Partial): delete controledMihomoConfig.dns delete controledMihomoConfig.hosts } else { - if (controledMihomoConfig.hosts === undefined) { + // 从不接管状态恢复 + if (controledMihomoConfig.dns?.ipv6 === undefined) { controledMihomoConfig.dns = defaultControledMihomoConfig.dns - controledMihomoConfig.hosts = defaultControledMihomoConfig.hosts } } if (patch.dns) { @@ -43,6 +43,7 @@ export async function patchControledMihomoConfig(patch: Partial): if (!controlSniff) { delete controledMihomoConfig.sniffer } else { + // 从不接管状态恢复 if (!controledMihomoConfig.sniffer) { controledMihomoConfig.sniffer = defaultControledMihomoConfig.sniffer }