mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
fix dns switch
This commit is contained in:
parent
ae37550845
commit
f68c312a98
@ -17,7 +17,7 @@ export async function getControledMihomoConfig(force = false): Promise<Partial<I
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>): Promise<void> {
|
export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>): Promise<void> {
|
||||||
const { useNameserverPolicy, controlDns, controlSniff } = await getAppConfig()
|
const { useNameserverPolicy, controlDns = true, controlSniff = true } = await getAppConfig()
|
||||||
if (patch.tun) {
|
if (patch.tun) {
|
||||||
const oldTun = controledMihomoConfig.tun || {}
|
const oldTun = controledMihomoConfig.tun || {}
|
||||||
const newTun = Object.assign(oldTun, patch.tun)
|
const newTun = Object.assign(oldTun, patch.tun)
|
||||||
@ -27,9 +27,9 @@ export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>):
|
|||||||
delete controledMihomoConfig.dns
|
delete controledMihomoConfig.dns
|
||||||
delete controledMihomoConfig.hosts
|
delete controledMihomoConfig.hosts
|
||||||
} else {
|
} else {
|
||||||
if (controledMihomoConfig.hosts === undefined) {
|
// 从不接管状态恢复
|
||||||
|
if (controledMihomoConfig.dns?.ipv6 === undefined) {
|
||||||
controledMihomoConfig.dns = defaultControledMihomoConfig.dns
|
controledMihomoConfig.dns = defaultControledMihomoConfig.dns
|
||||||
controledMihomoConfig.hosts = defaultControledMihomoConfig.hosts
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (patch.dns) {
|
if (patch.dns) {
|
||||||
@ -43,6 +43,7 @@ export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>):
|
|||||||
if (!controlSniff) {
|
if (!controlSniff) {
|
||||||
delete controledMihomoConfig.sniffer
|
delete controledMihomoConfig.sniffer
|
||||||
} else {
|
} else {
|
||||||
|
// 从不接管状态恢复
|
||||||
if (!controledMihomoConfig.sniffer) {
|
if (!controledMihomoConfig.sniffer) {
|
||||||
controledMihomoConfig.sniffer = defaultControledMihomoConfig.sniffer
|
controledMihomoConfig.sniffer = defaultControledMihomoConfig.sniffer
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user