fix: apply DNS hosts only if useHosts is true (#742)

Co-authored-by: 2045gemini <2045gemini@gmail.com>
This commit is contained in:
Xia Wanxu 2025-05-30 10:17:18 +08:00 committed by GitHub
parent da5336ee36
commit 27ab6d1b5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -142,9 +142,6 @@ const DNS: React.FC = () => {
className="app-nodrag"
color="primary"
onPress={() => {
const hostsObject = Object.fromEntries(
values.hosts.map(({ domain, value }) => [domain, value])
)
const dnsConfig = {
ipv6: values.ipv6,
'fake-ip-range': values.fakeIPRange,
@ -165,10 +162,13 @@ const DNS: React.FC = () => {
values.nameserverPolicy.map(({ domain, value }) => [domain, value])
)
}
onSave({
dns: dnsConfig,
hosts: hostsObject
})
const result = { dns: dnsConfig }
if (values.useHosts) {
result['hosts'] = Object.fromEntries(
values.hosts.map(({ domain, value }) => [domain, value])
)
}
onSave(result)
}}
>
{t('common.save')}