nameserver policy can not delete

This commit is contained in:
pompurin404 2024-08-27 23:15:27 +08:00
parent ed69c1261d
commit 6240351cb9
No known key found for this signature in database
2 changed files with 7 additions and 0 deletions

View File

@ -14,6 +14,9 @@ export async function getAppConfig(force = false): Promise<IAppConfig> {
} }
export async function patchAppConfig(patch: Partial<IAppConfig>): Promise<void> { export async function patchAppConfig(patch: Partial<IAppConfig>): Promise<void> {
if (patch.nameserverPolicy) {
appConfig.nameserverPolicy = patch.nameserverPolicy
}
appConfig = deepMerge(appConfig, patch) appConfig = deepMerge(appConfig, patch)
await writeFile(appConfigPath(), yaml.stringify(appConfig)) await writeFile(appConfigPath(), yaml.stringify(appConfig))
} }

View File

@ -39,6 +39,10 @@ export async function patchControledMihomoConfig(patch: Partial<IMihomoConfig>):
if (patch.hosts) { if (patch.hosts) {
controledMihomoConfig.hosts = patch.hosts controledMihomoConfig.hosts = patch.hosts
} }
if (patch.dns?.['nameserver-policy']) {
controledMihomoConfig.dns = controledMihomoConfig.dns || {}
controledMihomoConfig.dns['nameserver-policy'] = patch.dns['nameserver-policy']
}
controledMihomoConfig = deepMerge(controledMihomoConfig, patch) controledMihomoConfig = deepMerge(controledMihomoConfig, patch)
if (!useNameserverPolicy) { if (!useNameserverPolicy) {
delete controledMihomoConfig?.dns?.['nameserver-policy'] delete controledMihomoConfig?.dns?.['nameserver-policy']