Skip to content

Commit

Permalink
add direct-nameserver setting
Browse files Browse the repository at this point in the history
  • Loading branch information
xishang0128 committed Nov 6, 2024
1 parent c043281 commit bc631f7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/main/utils/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
'use-hosts': false,
'use-system-hosts': false,
nameserver: ['https://120.53.53.53/dns-query', 'https://223.5.5.5/dns-query'],
'proxy-server-nameserver': ['https://120.53.53.53/dns-query', 'https://223.5.5.5/dns-query']
'proxy-server-nameserver': ['https://120.53.53.53/dns-query', 'https://223.5.5.5/dns-query'],
'direct-nameserver': []
},
sniffer: {
enable: true,
Expand Down
12 changes: 10 additions & 2 deletions src/renderer/src/pages/dns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const DNS: React.FC = () => {
'proxy-server-nameserver': proxyServerNameserver = [
'https://120.53.53.53/dns-query',
'https://223.5.5.5/dns-query'
]
],
'direct-nameserver': directNameserver = []
} = dns || {}
const [changed, setChanged] = useState(false)
const [values, originSetValues] = useState({
Expand All @@ -45,6 +46,7 @@ const DNS: React.FC = () => {
respectRules,
nameserver,
proxyServerNameserver,
directNameserver,
useNameserverPolicy,
nameserverPolicy: Object.entries(nameserverPolicy || {}).map(([domain, value]) => ({
domain,
Expand Down Expand Up @@ -149,6 +151,7 @@ const DNS: React.FC = () => {
'respect-rules': values.respectRules,
nameserver: values.nameserver,
'proxy-server-nameserver': values.proxyServerNameserver,
'direct-nameserver': values.directNameserver,
fallback: [],
'fallback-filter': {}
}
Expand Down Expand Up @@ -209,7 +212,7 @@ const DNS: React.FC = () => {
}}
/>
</SettingItem>
<SettingItem title="连接遵守规则" divider>
<SettingItem title="遵守规则" divider>
<Switch
size="sm"
isSelected={values.respectRules}
Expand All @@ -229,6 +232,11 @@ const DNS: React.FC = () => {
{renderListInputs('nameserver', '例:tls://223.5.5.5')}
</div>
<Divider className="my-2" />
<div className="flex flex-col items-stretch">
<h3>直连 DNS 服务器</h3>
{renderListInputs('directNameserver', '例:tls://223.5.5.5')}
</div>
<Divider className="my-2" />
<SettingItem title="覆盖DNS策略" divider>
<Switch
size="sm"
Expand Down
9 changes: 9 additions & 0 deletions src/shared/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type MihomoProxyType =
type TunStack = 'gvisor' | 'mixed' | 'system'
type FindProcessMode = 'off' | 'strict' | 'always'
type DnsMode = 'normal' | 'fake-ip' | 'redir-host'
type FilterMode = 'blacklist' | 'whitelist'
type NetworkInterfaceInfo = os.NetworkInterfaceInfo

interface IAppVersion {
Expand Down Expand Up @@ -311,18 +312,26 @@ interface IMihomoTunConfig {
}
interface IMihomoDNSConfig {
enable?: boolean
listen?: string
ipv6?: boolean
'ipv6-timeout'?: number
'prefer-h3'?: boolean
'enhanced-mode'?: DnsMode
'fake-ip-range'?: string
'fake-ip-filter'?: string[]
'fake-ip-filter-mode'?: FilterMode
'use-hosts'?: boolean
'use-system-hosts'?: boolean
'respect-rules'?: boolean
'default-nameserver'?: string[]
nameserver?: string[]
fallback?: string[]
'fallback-filter'?: { [key: string]: boolean | string | string[] }
'proxy-server-nameserver'?: string[]
'direct-nameserver'?: string[]
'direct-nameserver-follow-policy'?: boolean
'nameserver-policy'?: { [key: string]: string | string[] }
'cache-algorithm'?: string
}

interface IMihomoSnifferConfig {
Expand Down

0 comments on commit bc631f7

Please sign in to comment.