mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-25 21:22:20 +08:00
feat(tun): expose mihomo tun dns-mode in TUN settings
Support the dns-mode field introduced in mihomo v1.19.33. A button group below the stack selector offers Auto/Disabled/Native/Hijack; Auto writes an empty string, which the core treats as the legacy behavior. Adding dns-mode to GUI_KEYS makes the value GUI-authoritative once saved, matching the other TUN dialog fields.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
<details>
|
||||
<summary><strong> ✨ 新增功能 </strong></summary>
|
||||
|
||||
- 新增虚拟网卡设置的「DNS 模式」选项,支持配置 mihomo 系统 DNS 行为
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ pub mod tun {
|
||||
"auto-redirect",
|
||||
"auto-detect-interface",
|
||||
"dns-hijack",
|
||||
"dns-mode",
|
||||
"strict-route",
|
||||
"mtu",
|
||||
];
|
||||
|
||||
@@ -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 (
|
||||
<ButtonGroup size="small" sx={{ my: '4px' }}>
|
||||
<Button
|
||||
variant={!value ? 'contained' : 'outlined'}
|
||||
onClick={() => onChange?.('')}
|
||||
sx={{ textTransform: 'capitalize' }}
|
||||
>
|
||||
Auto
|
||||
</Button>
|
||||
<Button
|
||||
variant={value === 'disabled' ? 'contained' : 'outlined'}
|
||||
onClick={() => onChange?.('disabled')}
|
||||
sx={{ textTransform: 'capitalize' }}
|
||||
>
|
||||
Disabled
|
||||
</Button>
|
||||
<Button
|
||||
variant={value === 'native' ? 'contained' : 'outlined'}
|
||||
onClick={() => onChange?.('native')}
|
||||
sx={{ textTransform: 'capitalize' }}
|
||||
>
|
||||
Native
|
||||
</Button>
|
||||
<Button
|
||||
variant={value === 'hijack' ? 'contained' : 'outlined'}
|
||||
onClick={() => onChange?.('hijack')}
|
||||
sx={{ textTransform: 'capitalize' }}
|
||||
>
|
||||
Hijack
|
||||
</Button>
|
||||
</ButtonGroup>
|
||||
)
|
||||
}
|
||||
@@ -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<DialogRef> }) {
|
||||
dnsHijack: ['any:53'],
|
||||
strictRoute: false,
|
||||
mtu: 1500,
|
||||
dnsMode: '',
|
||||
})
|
||||
|
||||
const routeExcludeAddressItems = splitRouteExcludeAddress(
|
||||
@@ -84,6 +86,7 @@ export function TunViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
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<DialogRef> }) {
|
||||
: {}),
|
||||
'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<DialogRef> }) {
|
||||
'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<DialogRef> }) {
|
||||
dnsHijack: ['any:53'],
|
||||
strictRoute: false,
|
||||
mtu: 1500,
|
||||
dnsMode: '',
|
||||
})
|
||||
await patchClash({ tun })
|
||||
await mutateClash(
|
||||
@@ -212,6 +218,25 @@ export function TunViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
/>
|
||||
</ListItem>
|
||||
|
||||
<ListItem sx={{ padding: '5px 2px' }}>
|
||||
<ListItemText
|
||||
primary={t('settings.modals.tun.fields.dnsMode')}
|
||||
sx={{ maxWidth: 'fit-content' }}
|
||||
/>
|
||||
<TooltipIcon
|
||||
title={t('settings.modals.tun.tooltips.dnsMode')}
|
||||
sx={{ opacity: 0.7 }}
|
||||
/>
|
||||
<Box sx={{ marginLeft: 'auto' }}>
|
||||
<DnsModeSwitch
|
||||
value={values.dnsMode}
|
||||
onChange={(value) => {
|
||||
setValues((v) => ({ ...v, dnsMode: value }))
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
</ListItem>
|
||||
|
||||
<ListItem sx={{ padding: '5px 2px' }}>
|
||||
<ListItemText primary={t('settings.modals.tun.fields.device')} />
|
||||
<TextField
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "توجيه صارم",
|
||||
"autoDetectInterface": "الكشف التلقائي عن الواجهة",
|
||||
"dnsHijack": "اختطاف DNS",
|
||||
"dnsMode": "وضع DNS",
|
||||
"mtu": "وحدة الإرسال القصوى",
|
||||
"autoRedirect": "Auto Redirect"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Please use , to separate multiple DNS servers",
|
||||
"dnsMode": "يحافظ Auto على السلوك القديم؛ يتطلب hijack تفعيل توجيه صارم على Windows أو Auto Redirect على Linux",
|
||||
"autoRedirect": "Automatically configures nftables/iptables TCP redirects"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "Strenges Routing",
|
||||
"autoDetectInterface": "Netzwerkschnittstelle automatisch auswählen",
|
||||
"dnsHijack": "DNS-Hijacking",
|
||||
"dnsMode": "DNS-Modus",
|
||||
"mtu": "Maximale Übertragungseinheit",
|
||||
"autoRedirect": "Automatische Umleitung"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Mehrere DNS-Server durch Kommas trennen",
|
||||
"dnsMode": "Auto behält das alte Verhalten bei; hijack erfordert Strenges Routing unter Windows oder Automatische Umleitung unter Linux",
|
||||
"autoRedirect": "Richtet TCP-Umleitungen per nftables/iptables automatisch ein"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "Strict Route",
|
||||
"autoDetectInterface": "Auto Detect Interface",
|
||||
"dnsHijack": "DNS Hijack",
|
||||
"dnsMode": "DNS Mode",
|
||||
"mtu": "Max Transmission Unit",
|
||||
"autoRedirect": "Auto Redirect"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Please use , to separate multiple DNS servers",
|
||||
"dnsMode": "Auto keeps the legacy behavior; hijack requires Strict Route on Windows or Auto Redirect on Linux",
|
||||
"autoRedirect": "Automatically configures nftables/iptables TCP redirects"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "Enrutamiento estricto",
|
||||
"autoDetectInterface": "Detectar automáticamente la interfaz de salida del tráfico",
|
||||
"dnsHijack": "Secuestro de DNS",
|
||||
"dnsMode": "Modo DNS",
|
||||
"mtu": "Unidad máxima de transmisión",
|
||||
"autoRedirect": "Auto Redirect"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Please use , to separate multiple DNS servers",
|
||||
"dnsMode": "Auto mantiene el comportamiento anterior; hijack requiere Enrutamiento estricto en Windows o Auto Redirect en Linux",
|
||||
"autoRedirect": "Automatically configures nftables/iptables TCP redirects"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "مسیر دقیق",
|
||||
"autoDetectInterface": "تشخیص خودکار رابط",
|
||||
"dnsHijack": "ربایش DNS",
|
||||
"dnsMode": "حالت DNS",
|
||||
"mtu": "واحد حداکثر انتقال",
|
||||
"autoRedirect": "Auto Redirect"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "لطفا برای جدا کردن چندین سرور DNS از , استفاده کنید.",
|
||||
"dnsMode": "Auto رفتار قدیمی را حفظ میکند؛ hijack در ویندوز نیاز به مسیر دقیق یا در لینوکس نیاز به Auto Redirect دارد",
|
||||
"autoRedirect": "پیکربندی خودکار ریدایرکتهای TCP در nftables/iptables"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "Rute Ketat",
|
||||
"autoDetectInterface": "Deteksi Antarmuka Otomatis",
|
||||
"dnsHijack": "Pembajakan DNS",
|
||||
"dnsMode": "Mode DNS",
|
||||
"mtu": "Unit Transmisi Maksimum",
|
||||
"autoRedirect": "Auto Redirect"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Please use , to separate multiple DNS servers",
|
||||
"dnsMode": "Auto mempertahankan perilaku lama; hijack memerlukan Rute Ketat di Windows atau Auto Redirect di Linux",
|
||||
"autoRedirect": "Automatically configures nftables/iptables TCP redirects"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "厳格なルート",
|
||||
"autoDetectInterface": "トラフィックの出口インターフェースを自動選択",
|
||||
"dnsHijack": "DNSハイジャック",
|
||||
"dnsMode": "DNSモード",
|
||||
"mtu": "最大転送単位",
|
||||
"autoRedirect": "Auto Redirect"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Please use , to separate multiple DNS servers",
|
||||
"dnsMode": "Auto は従来の動作を維持します。hijack には Windows で厳格なルートまたは Linux で Auto Redirect が必要です",
|
||||
"autoRedirect": "Automatically configures nftables/iptables TCP redirects"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "엄격 라우팅",
|
||||
"autoDetectInterface": "인터페이스 자동 감지",
|
||||
"dnsHijack": "DNS 하이재킹",
|
||||
"dnsMode": "DNS 모드",
|
||||
"mtu": "MTU",
|
||||
"autoRedirect": "Auto Redirect"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "여러 DNS 서버는 쉼표(,)로 구분하세요",
|
||||
"dnsMode": "Auto는 기존 동작을 유지합니다. hijack은 Windows에서 엄격 라우팅 또는 Linux에서 Auto Redirect가 필요합니다",
|
||||
"autoRedirect": "Automatically configures nftables/iptables TCP redirects"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "Rota Estrita",
|
||||
"autoDetectInterface": "Detectar Interface Automaticamente",
|
||||
"dnsHijack": "Sequestro de DNS",
|
||||
"dnsMode": "Modo DNS",
|
||||
"mtu": "Unidade Máxima de Transmissão",
|
||||
"autoRedirect": "Redirecionamento Automático"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Use , para separar vários servidores DNS",
|
||||
"dnsMode": "Auto mantém o comportamento antigo; hijack requer Rota Estrita no Windows ou Redirecionamento Automático no Linux",
|
||||
"autoRedirect": "Configura automaticamente os redirecionamentos TCP do nftables/iptables"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "Строгая маршрутизация",
|
||||
"autoDetectInterface": "Автоопределение интерфейса",
|
||||
"dnsHijack": "Перехват DNS",
|
||||
"dnsMode": "Режим DNS",
|
||||
"mtu": "MTU",
|
||||
"autoRedirect": "Автоматическое перенаправление"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Используйте запятую для разделения нескольких DNS-серверов",
|
||||
"dnsMode": "Auto сохраняет прежнее поведение; для hijack нужна Строгая маршрутизация в Windows или Автоматическое перенаправление в Linux",
|
||||
"autoRedirect": "Автоматически настраивает перенаправление TCP через nftables/iptables"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "Katı Yönlendirme",
|
||||
"autoDetectInterface": "Arayüzü Otomatik Algıla",
|
||||
"dnsHijack": "DNS Ele Geçirme",
|
||||
"dnsMode": "DNS Modu",
|
||||
"mtu": "Maksimum İletim Birimi",
|
||||
"autoRedirect": "Otomatik Yönlendirme"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Birden fazla DNS sunucusunu ayırmak için lütfen , kullanın",
|
||||
"dnsMode": "Auto eski davranışı korur; hijack için Windows'ta Katı Yönlendirme veya Linux'ta Otomatik Yönlendirme gerekir",
|
||||
"autoRedirect": "nftables/iptables TCP yönlendirmelerini otomatik olarak yapılandırır"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "Катгый маршрутлау",
|
||||
"autoDetectInterface": "Интерфейсны автоматик ачыклау",
|
||||
"dnsHijack": "DNS'ны үзгәртеп тоту (hijack)",
|
||||
"dnsMode": "DNS режиме",
|
||||
"mtu": "MTU (макс. тапшыру берәмлеге)",
|
||||
"autoRedirect": "Auto Redirect"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "Please use , to separate multiple DNS servers",
|
||||
"dnsMode": "Auto иске тәртипне саклый; hijack өчен Windows'ta Катгый маршрутлау яки Linux'ta Auto Redirect кирәк",
|
||||
"autoRedirect": "Automatically configures nftables/iptables TCP redirects"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "严格路由",
|
||||
"autoDetectInterface": "自动选择流量出口接口",
|
||||
"dnsHijack": "DNS 劫持",
|
||||
"dnsMode": "DNS 模式",
|
||||
"mtu": "最大传输单元",
|
||||
"autoRedirect": "自动重定向"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "多个 DNS 服务器请使用 , 分隔",
|
||||
"dnsMode": "Auto 保持旧行为;hijack 需 Windows 开启严格路由或 Linux 开启自动重定向",
|
||||
"autoRedirect": "自动配置 nftables/iptables 的 TCP 重定向"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -495,11 +495,13 @@
|
||||
"strictRoute": "嚴格路由",
|
||||
"autoDetectInterface": "自動偵測流量輸出介面",
|
||||
"dnsHijack": "DNS 綁架",
|
||||
"dnsMode": "DNS 模式",
|
||||
"mtu": "最大傳輸單位",
|
||||
"autoRedirect": "自動重導"
|
||||
},
|
||||
"tooltips": {
|
||||
"dnsHijack": "請用半形逗號來區隔多個 DNS 伺服器",
|
||||
"dnsMode": "Auto 保持舊行為;hijack 需 Windows 開啟嚴格路由或 Linux 開啟自動重導",
|
||||
"autoRedirect": "自動配置 nftables/iptables 的 TCP 重導"
|
||||
},
|
||||
"messages": {
|
||||
|
||||
@@ -704,9 +704,11 @@ export const translationKeys = [
|
||||
'settings.modals.tun.fields.strictRoute',
|
||||
'settings.modals.tun.fields.autoDetectInterface',
|
||||
'settings.modals.tun.fields.dnsHijack',
|
||||
'settings.modals.tun.fields.dnsMode',
|
||||
'settings.modals.tun.fields.mtu',
|
||||
'settings.modals.tun.fields.autoRedirect',
|
||||
'settings.modals.tun.tooltips.dnsHijack',
|
||||
'settings.modals.tun.tooltips.dnsMode',
|
||||
'settings.modals.tun.tooltips.autoRedirect',
|
||||
'settings.modals.tun.messages.applied',
|
||||
'settings.modals.tun.messages.invalidRouteExcludeAddress',
|
||||
|
||||
@@ -1190,6 +1190,7 @@ export interface TranslationResources {
|
||||
autoRoute: string
|
||||
device: string
|
||||
dnsHijack: string
|
||||
dnsMode: string
|
||||
mtu: string
|
||||
routeExcludeAddress: string
|
||||
stack: string
|
||||
@@ -1204,6 +1205,7 @@ export interface TranslationResources {
|
||||
tooltips: {
|
||||
autoRedirect: string
|
||||
dnsHijack: string
|
||||
dnsMode: string
|
||||
}
|
||||
}
|
||||
update: {
|
||||
|
||||
Vendored
+1
@@ -40,6 +40,7 @@ interface IConfigData {
|
||||
'auto-redirect'?: boolean
|
||||
'auto-detect-interface': boolean
|
||||
'dns-hijack': string[]
|
||||
'dns-mode'?: string
|
||||
'route-exclude-address'?: string[]
|
||||
'strict-route': boolean
|
||||
mtu: number
|
||||
|
||||
Reference in New Issue
Block a user