diff --git a/Changelog.md b/Changelog.md
index 0110ee42a..87adb73ee 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -17,6 +17,7 @@
✨ 新增功能
+- 新增虚拟网卡设置的「DNS 模式」选项,支持配置 mihomo 系统 DNS 行为
diff --git a/src-tauri/src/constants.rs b/src-tauri/src/constants.rs
index 4dc70de31..da67ce13e 100644
--- a/src-tauri/src/constants.rs
+++ b/src-tauri/src/constants.rs
@@ -75,6 +75,7 @@ pub mod tun {
"auto-redirect",
"auto-detect-interface",
"dns-hijack",
+ "dns-mode",
"strict-route",
"mtu",
];
diff --git a/src/components/setting/mods/dns-mode-switch.tsx b/src/components/setting/mods/dns-mode-switch.tsx
new file mode 100644
index 000000000..9927ca525
--- /dev/null
+++ b/src/components/setting/mods/dns-mode-switch.tsx
@@ -0,0 +1,43 @@
+import { Button, ButtonGroup } from '@mui/material'
+
+interface Props {
+ value?: string
+ onChange?: (value: string) => void
+}
+
+export const DnsModeSwitch = (props: Props) => {
+ const { value, onChange } = props
+
+ return (
+
+
+
+
+
+
+ )
+}
diff --git a/src/components/setting/mods/tun-viewer.tsx b/src/components/setting/mods/tun-viewer.tsx
index b00355162..41071b723 100644
--- a/src/components/setting/mods/tun-viewer.tsx
+++ b/src/components/setting/mods/tun-viewer.tsx
@@ -26,6 +26,7 @@ import { showNotice } from '@/services/notice-service'
import getSystem from '@/utils/get-system'
import { areValidIpCidrs } from '@/utils/network'
+import { DnsModeSwitch } from './dns-mode-switch'
import { StackModeSwitch } from './stack-mode-switch'
const OS = getSystem()
@@ -52,6 +53,7 @@ export function TunViewer({ ref }: { ref?: Ref }) {
dnsHijack: ['any:53'],
strictRoute: false,
mtu: 1500,
+ dnsMode: '',
})
const routeExcludeAddressItems = splitRouteExcludeAddress(
@@ -84,6 +86,7 @@ export function TunViewer({ ref }: { ref?: Ref }) {
dnsHijack: clash?.tun['dns-hijack'] ?? ['any:53'],
strictRoute: clash?.tun['strict-route'] ?? false,
mtu: clash?.tun.mtu ?? 1500,
+ dnsMode: clash?.tun['dns-mode'] ?? '',
})
},
close: () => setOpen(false),
@@ -117,6 +120,7 @@ export function TunViewer({ ref }: { ref?: Ref }) {
: {}),
'auto-detect-interface': values.autoDetectInterface,
'dns-hijack': values.dnsHijack[0] === '' ? [] : values.dnsHijack,
+ 'dns-mode': values.dnsMode,
'strict-route': values.strictRoute,
mtu: values.mtu ?? 1500,
}
@@ -163,6 +167,7 @@ export function TunViewer({ ref }: { ref?: Ref }) {
'auto-detect-interface': true,
'dns-hijack': ['any:53'],
'route-exclude-address': [],
+ 'dns-mode': '',
'strict-route': false,
mtu: 1500,
}
@@ -176,6 +181,7 @@ export function TunViewer({ ref }: { ref?: Ref }) {
dnsHijack: ['any:53'],
strictRoute: false,
mtu: 1500,
+ dnsMode: '',
})
await patchClash({ tun })
await mutateClash(
@@ -212,6 +218,25 @@ export function TunViewer({ ref }: { ref?: Ref }) {
/>
+
+
+
+
+ {
+ setValues((v) => ({ ...v, dnsMode: value }))
+ }}
+ />
+
+
+