mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 21:20:29 +08:00
add fakeip settings and modify sniff (#4)
Co-authored-by: 布丁狗~ <pompurin404@mihomo.party>
This commit is contained in:
parent
77c2be261d
commit
586e2f6672
@ -35,17 +35,19 @@ export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
|
|||||||
ipv6: false,
|
ipv6: false,
|
||||||
'enhanced-mode': 'fake-ip',
|
'enhanced-mode': 'fake-ip',
|
||||||
'fake-ip-range': '198.18.0.1/16',
|
'fake-ip-range': '198.18.0.1/16',
|
||||||
|
'fake-ip-filter': ['*', '+.lan', '+.local', 'time.*.com', 'ntp.*.com', '+.market.xiaomi.com'],
|
||||||
'use-hosts': false,
|
'use-hosts': false,
|
||||||
'use-system-hosts': false,
|
'use-system-hosts': false,
|
||||||
nameserver: ['https://doh.pub/dns-query', 'https://dns.alidns.com/dns-query']
|
nameserver: ['https://doh.pub/dns-query', 'https://dns.alidns.com/dns-query']
|
||||||
},
|
},
|
||||||
sniffer: {
|
sniffer: {
|
||||||
enable: true,
|
enable: true,
|
||||||
'parse-pure-ip': true,
|
'parse-pure-ip': false,
|
||||||
'override-destination': false,
|
'override-destination': false,
|
||||||
sniff: {
|
sniff: {
|
||||||
HTTP: {
|
HTTP: {
|
||||||
ports: [80, 443]
|
ports: [80, 443],
|
||||||
|
'override-destination': false
|
||||||
},
|
},
|
||||||
TLS: {
|
TLS: {
|
||||||
ports: [443]
|
ports: [443]
|
||||||
|
|||||||
@ -12,6 +12,15 @@ const DNS: React.FC = () => {
|
|||||||
const { dns, hosts } = controledMihomoConfig || {}
|
const { dns, hosts } = controledMihomoConfig || {}
|
||||||
const {
|
const {
|
||||||
ipv6 = false,
|
ipv6 = false,
|
||||||
|
'fake-ip-range': fakeIPRange = '198.18.0.1/16',
|
||||||
|
'fake-ip-filter': fakeIPFilter = [
|
||||||
|
'*',
|
||||||
|
'+.lan',
|
||||||
|
'+.local',
|
||||||
|
'time.*.com',
|
||||||
|
'ntp.*.com',
|
||||||
|
'+.market.xiaomi.com'
|
||||||
|
],
|
||||||
'enhanced-mode': enhancedMode = 'fake-ip',
|
'enhanced-mode': enhancedMode = 'fake-ip',
|
||||||
'use-hosts': useHosts = false,
|
'use-hosts': useHosts = false,
|
||||||
'use-system-hosts': useSystemHosts = false,
|
'use-system-hosts': useSystemHosts = false,
|
||||||
@ -22,25 +31,27 @@ const DNS: React.FC = () => {
|
|||||||
ipv6,
|
ipv6,
|
||||||
useHosts,
|
useHosts,
|
||||||
enhancedMode,
|
enhancedMode,
|
||||||
|
fakeIPRange,
|
||||||
|
fakeIPFilter,
|
||||||
useSystemHosts,
|
useSystemHosts,
|
||||||
nameserver,
|
nameserver,
|
||||||
hosts: Object.entries(hosts || {}).map(([domain, value]) => ({ domain, value }))
|
hosts: Object.entries(hosts || {}).map(([domain, value]) => ({ domain, value }))
|
||||||
})
|
})
|
||||||
|
|
||||||
const handleNameserverChange = (value: string, index: number): void => {
|
const handleListChange = (type: string, value: string, index: number): void => {
|
||||||
const newNameservers = [...values.nameserver]
|
const newValues = [...values[type]]
|
||||||
if (index === newNameservers.length) {
|
if (index === newValues.length) {
|
||||||
if (value.trim() !== '') {
|
if (value.trim() !== '') {
|
||||||
newNameservers.push(value)
|
newValues.push(value)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (value.trim() === '') {
|
if (value.trim() === '') {
|
||||||
newNameservers.splice(index, 1)
|
newValues.splice(index, 1)
|
||||||
} else {
|
} else {
|
||||||
newNameservers[index] = value
|
newValues[index] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setValues({ ...values, nameserver: newNameservers })
|
setValues({ ...values, [type]: newValues })
|
||||||
}
|
}
|
||||||
const handleHostsChange = (domain: string, value: string, index: number): void => {
|
const handleHostsChange = (domain: string, value: string, index: number): void => {
|
||||||
const newHosts = [...values.hosts]
|
const newHosts = [...values.hosts]
|
||||||
@ -81,6 +92,8 @@ const DNS: React.FC = () => {
|
|||||||
onSave({
|
onSave({
|
||||||
dns: {
|
dns: {
|
||||||
ipv6: values.ipv6,
|
ipv6: values.ipv6,
|
||||||
|
'fake-ip-range': values.fakeIPRange,
|
||||||
|
'fake-ip-filter': values.fakeIPFilter,
|
||||||
'enhanced-mode': values.enhancedMode,
|
'enhanced-mode': values.enhancedMode,
|
||||||
'use-hosts': values.useHosts,
|
'use-hosts': values.useHosts,
|
||||||
'use-system-hosts': values.useSystemHosts,
|
'use-system-hosts': values.useSystemHosts,
|
||||||
@ -107,6 +120,46 @@ const DNS: React.FC = () => {
|
|||||||
<Tab key="normal" title="取消映射" className="select-none" />
|
<Tab key="normal" title="取消映射" className="select-none" />
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
|
{values.enhancedMode === 'fake-ip' ? (
|
||||||
|
<>
|
||||||
|
<SettingItem title="回应范围" divider>
|
||||||
|
<Input
|
||||||
|
size="sm"
|
||||||
|
className="w-[50%]"
|
||||||
|
value={values.fakeIPRange}
|
||||||
|
onValueChange={(v) => {
|
||||||
|
setValues({ ...values, fakeIPRange: v })
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</SettingItem>
|
||||||
|
<div className="flex flex-col items-stretch">
|
||||||
|
<h3 className="select-none mb-2">真实IP回应</h3>
|
||||||
|
{[...values.fakeIPFilter, ''].map((ns, index) => (
|
||||||
|
<div key={index} className="mb-2 flex">
|
||||||
|
<Input
|
||||||
|
fullWidth
|
||||||
|
size="sm"
|
||||||
|
placeholder="例: +.lan"
|
||||||
|
value={ns}
|
||||||
|
onValueChange={(v) => handleListChange('fakeIPFilter', v, index)}
|
||||||
|
/>
|
||||||
|
{index < values.fakeIPFilter.length && (
|
||||||
|
<Button
|
||||||
|
className="ml-2"
|
||||||
|
size="sm"
|
||||||
|
variant="flat"
|
||||||
|
color="warning"
|
||||||
|
onClick={() => handleListChange('fakeIPFilter', '', index)}
|
||||||
|
>
|
||||||
|
<MdDeleteForever className="text-lg" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<Divider style={{ marginTop: '2px', marginBottom: '6px' }} />
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
<SettingItem title="IPv6" divider>
|
<SettingItem title="IPv6" divider>
|
||||||
<Switch
|
<Switch
|
||||||
size="sm"
|
size="sm"
|
||||||
@ -125,7 +178,7 @@ const DNS: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
placeholder="例: tls://223.5.5.5"
|
placeholder="例: tls://223.5.5.5"
|
||||||
value={ns}
|
value={ns}
|
||||||
onValueChange={(v) => handleNameserverChange(v, index)}
|
onValueChange={(v) => handleListChange('nameserver', v, index)}
|
||||||
/>
|
/>
|
||||||
{index < values.nameserver.length && (
|
{index < values.nameserver.length && (
|
||||||
<Button
|
<Button
|
||||||
@ -133,7 +186,7 @@ const DNS: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
variant="flat"
|
variant="flat"
|
||||||
color="warning"
|
color="warning"
|
||||||
onClick={() => handleNameserverChange('', index)}
|
onClick={() => handleListChange('nameserver', '', index)}
|
||||||
>
|
>
|
||||||
<MdDeleteForever className="text-lg" />
|
<MdDeleteForever className="text-lg" />
|
||||||
</Button>
|
</Button>
|
||||||
@ -141,7 +194,7 @@ const DNS: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<Divider />
|
<Divider style={{ marginTop: '2px', marginBottom: '6px' }} />
|
||||||
<SettingItem title="使用系统hosts" divider>
|
<SettingItem title="使用系统hosts" divider>
|
||||||
<Switch
|
<Switch
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|||||||
@ -14,7 +14,7 @@ const Sniffer: React.FC = () => {
|
|||||||
'parse-pure-ip': parsePureIP = true,
|
'parse-pure-ip': parsePureIP = true,
|
||||||
'override-destination': overrideDestination = false,
|
'override-destination': overrideDestination = false,
|
||||||
sniff = {
|
sniff = {
|
||||||
HTTP: { ports: [80, 443] },
|
HTTP: { ports: [80, 443], 'override-destination': false },
|
||||||
TLS: { ports: [443] },
|
TLS: { ports: [443] },
|
||||||
QUIC: { ports: [443] }
|
QUIC: { ports: [443] }
|
||||||
},
|
},
|
||||||
@ -92,7 +92,18 @@ const Sniffer: React.FC = () => {
|
|||||||
size="sm"
|
size="sm"
|
||||||
isSelected={values.overrideDestination}
|
isSelected={values.overrideDestination}
|
||||||
onValueChange={(v) => {
|
onValueChange={(v) => {
|
||||||
setValues({ ...values, overrideDestination: v })
|
setValues({
|
||||||
|
...values,
|
||||||
|
overrideDestination: v,
|
||||||
|
sniff: {
|
||||||
|
...values.sniff,
|
||||||
|
HTTP: {
|
||||||
|
...values.sniff.HTTP,
|
||||||
|
'override-destination': v,
|
||||||
|
ports: values.sniff.HTTP?.ports || [80, 443]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
@ -154,7 +165,7 @@ const Sniffer: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
<Divider />
|
<Divider style={{ marginTop: '2px', marginBottom: '6px' }} />
|
||||||
<div className="flex flex-col items-stretch">
|
<div className="flex flex-col items-stretch">
|
||||||
<h3 className="select-none mb-2">强制嗅探</h3>
|
<h3 className="select-none mb-2">强制嗅探</h3>
|
||||||
{[...values.forceDomain, ''].map((d, index) => (
|
{[...values.forceDomain, ''].map((d, index) => (
|
||||||
|
|||||||
1
src/shared/types.d.ts
vendored
1
src/shared/types.d.ts
vendored
@ -199,6 +199,7 @@ interface IMihomoDNSConfig {
|
|||||||
ipv6?: boolean
|
ipv6?: boolean
|
||||||
'enhanced-mode'?: DnsMode
|
'enhanced-mode'?: DnsMode
|
||||||
'fake-ip-range'?: string
|
'fake-ip-range'?: string
|
||||||
|
'fake-ip-filter'?: string[]
|
||||||
'use-hosts'?: boolean
|
'use-hosts'?: boolean
|
||||||
'use-system-hosts'?: boolean
|
'use-system-hosts'?: boolean
|
||||||
'respect-rules'?: boolean
|
'respect-rules'?: boolean
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user