mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2026-02-10 19:50:28 +08:00
fix: sanitize NaN port values when reading config
This commit is contained in:
parent
36027cecea
commit
5eee22292e
@ -33,6 +33,14 @@ export async function getControledMihomoConfig(force = false): Promise<Partial<I
|
|||||||
|
|
||||||
// 确保配置包含所有必要的默认字段,处理升级场景
|
// 确保配置包含所有必要的默认字段,处理升级场景
|
||||||
controledMihomoConfig = deepMerge(defaultControledMihomoConfig, controledMihomoConfig)
|
controledMihomoConfig = deepMerge(defaultControledMihomoConfig, controledMihomoConfig)
|
||||||
|
|
||||||
|
// 清理端口字段中的 NaN 值,恢复为默认值
|
||||||
|
const portFields = ['mixed-port', 'socks-port', 'port', 'redir-port', 'tproxy-port'] as const
|
||||||
|
for (const field of portFields) {
|
||||||
|
if (typeof controledMihomoConfig[field] !== 'number' || Number.isNaN(controledMihomoConfig[field])) {
|
||||||
|
controledMihomoConfig[field] = defaultControledMihomoConfig[field]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (typeof controledMihomoConfig !== 'object')
|
if (typeof controledMihomoConfig !== 'object')
|
||||||
controledMihomoConfig = defaultControledMihomoConfig
|
controledMihomoConfig = defaultControledMihomoConfig
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user