mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50:30 +08:00
add more sniff settings
This commit is contained in:
parent
04aad7fd40
commit
09921d984a
@ -90,12 +90,23 @@ export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
|
||||
},
|
||||
TLS: {
|
||||
ports: [443]
|
||||
},
|
||||
QUIC: {
|
||||
ports: [443]
|
||||
}
|
||||
},
|
||||
'skip-domain': ['+.push.apple.com']
|
||||
'skip-domain': ['+.push.apple.com'],
|
||||
'skip-dst-address': [
|
||||
'91.105.192.0/23',
|
||||
'91.108.4.0/22',
|
||||
'91.108.8.0/21',
|
||||
'91.108.16.0/21',
|
||||
'91.108.56.0/22',
|
||||
'95.161.64.0/20',
|
||||
'149.154.160.0/20',
|
||||
'185.76.151.0/24',
|
||||
'2001:67c:4e8::/48',
|
||||
'2001:b28:f23c::/47',
|
||||
'2001:b28:f23f::/48',
|
||||
'2a0a:f280:203::/48'
|
||||
]
|
||||
},
|
||||
profile: {
|
||||
'store-selected': true,
|
||||
|
||||
@ -4,7 +4,7 @@ import SettingCard from '@renderer/components/base/base-setting-card'
|
||||
import SettingItem from '@renderer/components/base/base-setting-item'
|
||||
import { useControledMihomoConfig } from '@renderer/hooks/use-controled-mihomo-config'
|
||||
import { restartCore } from '@renderer/utils/ipc'
|
||||
import React, { useState } from 'react'
|
||||
import React, { ReactNode, useState } from 'react'
|
||||
import { MdDeleteForever } from 'react-icons/md'
|
||||
|
||||
const Sniffer: React.FC = () => {
|
||||
@ -17,10 +17,25 @@ const Sniffer: React.FC = () => {
|
||||
sniff = {
|
||||
HTTP: { ports: [80, 443], 'override-destination': false },
|
||||
TLS: { ports: [443] },
|
||||
QUIC: { ports: [443] }
|
||||
QUIC: { ports: [] }
|
||||
},
|
||||
'skip-domain': skipDomain = ['+.push.apple.com'],
|
||||
'force-domain': forceDomain = []
|
||||
'force-domain': forceDomain = [],
|
||||
'skip-dst-address': skipDstAddress = [
|
||||
'91.105.192.0/23',
|
||||
'91.108.4.0/22',
|
||||
'91.108.8.0/21',
|
||||
'91.108.16.0/21',
|
||||
'91.108.56.0/22',
|
||||
'95.161.64.0/20',
|
||||
'149.154.160.0/20',
|
||||
'185.76.151.0/24',
|
||||
'2001:67c:4e8::/48',
|
||||
'2001:b28:f23c::/47',
|
||||
'2001:b28:f23f::/48',
|
||||
'2a0a:f280:203::/48'
|
||||
],
|
||||
'skip-src-address': skipSrcAddress = []
|
||||
} = sniffer || {}
|
||||
const [changed, setChanged] = useState(false)
|
||||
const [values, originSetValues] = useState({
|
||||
@ -29,7 +44,9 @@ const Sniffer: React.FC = () => {
|
||||
overrideDestination,
|
||||
sniff,
|
||||
skipDomain,
|
||||
forceDomain
|
||||
forceDomain,
|
||||
skipDstAddress,
|
||||
skipSrcAddress
|
||||
})
|
||||
const setValues = (v: typeof values): void => {
|
||||
originSetValues(v)
|
||||
@ -58,20 +75,45 @@ const Sniffer: React.FC = () => {
|
||||
}
|
||||
})
|
||||
}
|
||||
const handleDomainChange = (type: string, value: string, index: number): void => {
|
||||
const newDomains = [...values[type]]
|
||||
if (index === newDomains.length) {
|
||||
if (value.trim() !== '') {
|
||||
newDomains.push(value)
|
||||
const handleListChange = (type: string, value: string, index: number): void => {
|
||||
const list = [...values[type]]
|
||||
if (value.trim()) {
|
||||
if (index < list.length) {
|
||||
list[index] = value
|
||||
} else {
|
||||
list.push(value)
|
||||
}
|
||||
} else {
|
||||
if (value.trim() === '') {
|
||||
newDomains.splice(index, 1)
|
||||
} else {
|
||||
newDomains[index] = value
|
||||
list.splice(index, 1)
|
||||
}
|
||||
setValues({ ...values, [type]: list })
|
||||
}
|
||||
setValues({ ...values, [type]: newDomains })
|
||||
const renderListInputs = (type: string, placeholder: string): ReactNode => {
|
||||
const currentItems = values[type]
|
||||
const showNewLine = currentItems.every((item: string) => item.trim() !== '')
|
||||
|
||||
return [...currentItems, ...(showNewLine ? [''] : [])].map((item, index) => (
|
||||
<div key={index} className="mt-2 flex">
|
||||
<Input
|
||||
fullWidth
|
||||
size="sm"
|
||||
placeholder={placeholder}
|
||||
value={typeof item === 'string' ? item : item.domain}
|
||||
onValueChange={(v) => handleListChange(type, v, index)}
|
||||
/>
|
||||
{index < values[type].length && (
|
||||
<Button
|
||||
className="ml-2"
|
||||
size="sm"
|
||||
variant="flat"
|
||||
color="warning"
|
||||
onClick={() => handleListChange(type, '', index)}
|
||||
>
|
||||
<MdDeleteForever className="text-lg" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
))
|
||||
}
|
||||
|
||||
return (
|
||||
@ -144,6 +186,7 @@ const Sniffer: React.FC = () => {
|
||||
<Input
|
||||
size="sm"
|
||||
className="w-[50%]"
|
||||
placeholder="端口号,使用英文逗号分割"
|
||||
value={values.sniff.HTTP?.ports.join(',')}
|
||||
onValueChange={(v) => handleSniffPortChange('HTTP', v)}
|
||||
/>
|
||||
@ -152,6 +195,7 @@ const Sniffer: React.FC = () => {
|
||||
<Input
|
||||
size="sm"
|
||||
className="w-[50%]"
|
||||
placeholder="端口号,使用英文逗号分割"
|
||||
value={values.sniff.TLS?.ports.join(',')}
|
||||
onValueChange={(v) => handleSniffPortChange('TLS', v)}
|
||||
/>
|
||||
@ -160,60 +204,29 @@ const Sniffer: React.FC = () => {
|
||||
<Input
|
||||
size="sm"
|
||||
className="w-[50%]"
|
||||
placeholder="端口号,使用英文逗号分割"
|
||||
value={values.sniff.QUIC?.ports.join(',')}
|
||||
onValueChange={(v) => handleSniffPortChange('QUIC', v)}
|
||||
/>
|
||||
</SettingItem>
|
||||
<div className="flex flex-col items-stretch">
|
||||
<h3>跳过嗅探域名</h3>
|
||||
{[...values.skipDomain, ''].map((d, index) => (
|
||||
<div key={index} className="flex mt-2">
|
||||
<Input
|
||||
size="sm"
|
||||
fullWidth
|
||||
placeholder="例: push.apple.com"
|
||||
value={d}
|
||||
onValueChange={(v) => handleDomainChange('skipDomain', v, index)}
|
||||
/>
|
||||
{index < values.skipDomain.length && (
|
||||
<Button
|
||||
size="sm"
|
||||
color="warning"
|
||||
variant="flat"
|
||||
className="ml-2"
|
||||
onClick={() => handleDomainChange('skipDomain', '', index)}
|
||||
>
|
||||
<MdDeleteForever className="text-lg" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
<h3>跳过域名嗅探</h3>
|
||||
{renderListInputs('skipDomain', '例:+.push.apple.com')}
|
||||
</div>
|
||||
<Divider className="my-2" />
|
||||
<div className="flex flex-col items-stretch">
|
||||
<h3 className="mb-2">强制嗅探域名</h3>
|
||||
{[...values.forceDomain, ''].map((d, index) => (
|
||||
<div key={index} className="flex mb-2">
|
||||
<Input
|
||||
size="sm"
|
||||
fullWidth
|
||||
placeholder="例: v2ex.com"
|
||||
value={d}
|
||||
onValueChange={(v) => handleDomainChange('forceDomain', v, index)}
|
||||
/>
|
||||
{index < values.forceDomain.length && (
|
||||
<Button
|
||||
size="sm"
|
||||
color="warning"
|
||||
variant="flat"
|
||||
className="ml-2"
|
||||
onClick={() => handleDomainChange('forceDomain', '', index)}
|
||||
>
|
||||
<MdDeleteForever className="text-lg" />
|
||||
</Button>
|
||||
)}
|
||||
<h3 className="mb-2">强制域名嗅探</h3>
|
||||
{renderListInputs('forceDomain', '例:v2ex.com')}
|
||||
</div>
|
||||
))}
|
||||
<Divider className="my-2" />
|
||||
<div className="flex flex-col items-stretch">
|
||||
<h3 className="mb-2">跳过目标地址嗅探</h3>
|
||||
{renderListInputs('skipDstAddress', '例:1.1.1.1/32')}
|
||||
</div>
|
||||
<Divider className="my-2" />
|
||||
<div className="flex flex-col items-stretch">
|
||||
<h3 className="mb-2">跳过来源地址嗅探</h3>
|
||||
{renderListInputs('skipSrcAddress', '例:192.168.1.1/24')}
|
||||
</div>
|
||||
</SettingCard>
|
||||
</BasePage>
|
||||
|
||||
2
src/shared/types.d.ts
vendored
2
src/shared/types.d.ts
vendored
@ -352,6 +352,8 @@ interface IMihomoSnifferConfig {
|
||||
'force-dns-mapping'?: boolean
|
||||
'force-domain'?: string[]
|
||||
'skip-domain'?: string[]
|
||||
'skip-dst-address'?: string[]
|
||||
'skip-src-address'?: string[]
|
||||
sniff?: {
|
||||
HTTP?: {
|
||||
ports: (number | string)[]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user