mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 13:10:30 +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,
|
||||
'enhanced-mode': 'fake-ip',
|
||||
'fake-ip-range': '198.18.0.1/16',
|
||||
'fake-ip-filter': ['*', '+.lan', '+.local', 'time.*.com', 'ntp.*.com', '+.market.xiaomi.com'],
|
||||
'use-hosts': false,
|
||||
'use-system-hosts': false,
|
||||
nameserver: ['https://doh.pub/dns-query', 'https://dns.alidns.com/dns-query']
|
||||
},
|
||||
sniffer: {
|
||||
enable: true,
|
||||
'parse-pure-ip': true,
|
||||
'parse-pure-ip': false,
|
||||
'override-destination': false,
|
||||
sniff: {
|
||||
HTTP: {
|
||||
ports: [80, 443]
|
||||
ports: [80, 443],
|
||||
'override-destination': false
|
||||
},
|
||||
TLS: {
|
||||
ports: [443]
|
||||
|
||||
@ -12,6 +12,15 @@ const DNS: React.FC = () => {
|
||||
const { dns, hosts } = controledMihomoConfig || {}
|
||||
const {
|
||||
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',
|
||||
'use-hosts': useHosts = false,
|
||||
'use-system-hosts': useSystemHosts = false,
|
||||
@ -22,25 +31,27 @@ const DNS: React.FC = () => {
|
||||
ipv6,
|
||||
useHosts,
|
||||
enhancedMode,
|
||||
fakeIPRange,
|
||||
fakeIPFilter,
|
||||
useSystemHosts,
|
||||
nameserver,
|
||||
hosts: Object.entries(hosts || {}).map(([domain, value]) => ({ domain, value }))
|
||||
})
|
||||
|
||||
const handleNameserverChange = (value: string, index: number): void => {
|
||||
const newNameservers = [...values.nameserver]
|
||||
if (index === newNameservers.length) {
|
||||
const handleListChange = (type: string, value: string, index: number): void => {
|
||||
const newValues = [...values[type]]
|
||||
if (index === newValues.length) {
|
||||
if (value.trim() !== '') {
|
||||
newNameservers.push(value)
|
||||
newValues.push(value)
|
||||
}
|
||||
} else {
|
||||
if (value.trim() === '') {
|
||||
newNameservers.splice(index, 1)
|
||||
newValues.splice(index, 1)
|
||||
} 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 newHosts = [...values.hosts]
|
||||
@ -81,6 +92,8 @@ const DNS: React.FC = () => {
|
||||
onSave({
|
||||
dns: {
|
||||
ipv6: values.ipv6,
|
||||
'fake-ip-range': values.fakeIPRange,
|
||||
'fake-ip-filter': values.fakeIPFilter,
|
||||
'enhanced-mode': values.enhancedMode,
|
||||
'use-hosts': values.useHosts,
|
||||
'use-system-hosts': values.useSystemHosts,
|
||||
@ -107,6 +120,46 @@ const DNS: React.FC = () => {
|
||||
<Tab key="normal" title="取消映射" className="select-none" />
|
||||
</Tabs>
|
||||
</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>
|
||||
<Switch
|
||||
size="sm"
|
||||
@ -125,7 +178,7 @@ const DNS: React.FC = () => {
|
||||
size="sm"
|
||||
placeholder="例: tls://223.5.5.5"
|
||||
value={ns}
|
||||
onValueChange={(v) => handleNameserverChange(v, index)}
|
||||
onValueChange={(v) => handleListChange('nameserver', v, index)}
|
||||
/>
|
||||
{index < values.nameserver.length && (
|
||||
<Button
|
||||
@ -133,7 +186,7 @@ const DNS: React.FC = () => {
|
||||
size="sm"
|
||||
variant="flat"
|
||||
color="warning"
|
||||
onClick={() => handleNameserverChange('', index)}
|
||||
onClick={() => handleListChange('nameserver', '', index)}
|
||||
>
|
||||
<MdDeleteForever className="text-lg" />
|
||||
</Button>
|
||||
@ -141,7 +194,7 @@ const DNS: React.FC = () => {
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Divider />
|
||||
<Divider style={{ marginTop: '2px', marginBottom: '6px' }} />
|
||||
<SettingItem title="使用系统hosts" divider>
|
||||
<Switch
|
||||
size="sm"
|
||||
|
||||
@ -14,7 +14,7 @@ const Sniffer: React.FC = () => {
|
||||
'parse-pure-ip': parsePureIP = true,
|
||||
'override-destination': overrideDestination = false,
|
||||
sniff = {
|
||||
HTTP: { ports: [80, 443] },
|
||||
HTTP: { ports: [80, 443], 'override-destination': false },
|
||||
TLS: { ports: [443] },
|
||||
QUIC: { ports: [443] }
|
||||
},
|
||||
@ -92,7 +92,18 @@ const Sniffer: React.FC = () => {
|
||||
size="sm"
|
||||
isSelected={values.overrideDestination}
|
||||
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>
|
||||
@ -154,7 +165,7 @@ const Sniffer: React.FC = () => {
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Divider />
|
||||
<Divider style={{ marginTop: '2px', marginBottom: '6px' }} />
|
||||
<div className="flex flex-col items-stretch">
|
||||
<h3 className="select-none mb-2">强制嗅探</h3>
|
||||
{[...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
|
||||
'enhanced-mode'?: DnsMode
|
||||
'fake-ip-range'?: string
|
||||
'fake-ip-filter'?: string[]
|
||||
'use-hosts'?: boolean
|
||||
'use-system-hosts'?: boolean
|
||||
'respect-rules'?: boolean
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user