mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50:30 +08:00
adjust
This commit is contained in:
parent
c338051802
commit
ec3efe89c7
@ -241,6 +241,11 @@ const resolveMmdb = () =>
|
||||
file: 'country.mmdb',
|
||||
downloadURL: `https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb`
|
||||
})
|
||||
const resolveMetadb = () =>
|
||||
resolveResource({
|
||||
file: 'geoip.metadb',
|
||||
downloadURL: `https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb`
|
||||
})
|
||||
const resolveGeosite = () =>
|
||||
resolveResource({
|
||||
file: 'geosite.dat',
|
||||
@ -351,6 +356,7 @@ const tasks = [
|
||||
retry: 5
|
||||
},
|
||||
{ name: 'mmdb', func: resolveMmdb, retry: 5 },
|
||||
{ name: 'metadb', func: resolveMetadb, retry: 5 },
|
||||
{ name: 'geosite', func: resolveGeosite, retry: 5 },
|
||||
{ name: 'geoip', func: resolveGeoIP, retry: 5 },
|
||||
{ name: 'asn', func: resolveASN, retry: 5 },
|
||||
|
||||
@ -56,6 +56,7 @@ async function prepareProfileWorkDir(current: string | undefined): Promise<void>
|
||||
}
|
||||
await Promise.all([
|
||||
copy('country.mmdb'),
|
||||
copy('geoip.metadb'),
|
||||
copy('geoip.dat'),
|
||||
copy('geosite.dat'),
|
||||
copy('ASN.mmdb')
|
||||
@ -125,7 +126,7 @@ function runOverrideScript(
|
||||
log('info', '脚本执行成功')
|
||||
return newProfile
|
||||
} catch (e) {
|
||||
log('exception', `脚本执行失败: ${e}`)
|
||||
log('exception', `脚本执行失败:${e}`)
|
||||
return profile
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,11 +114,6 @@ export const mihomoUpdateProxyProviders = async (name: string): Promise<void> =>
|
||||
return await instance.put(`/providers/proxies/${encodeURIComponent(name)}`)
|
||||
}
|
||||
|
||||
export const mihomoRunProxyProviders = async (): Promise<IMihomoProxyProviders> => {
|
||||
const runtime = await getRuntimeConfig()
|
||||
return runtime?.['proxy-providers']
|
||||
}
|
||||
|
||||
export const mihomoRuleProviders = async (): Promise<IMihomoRuleProviders> => {
|
||||
const instance = await getAxios()
|
||||
return await instance.get('/providers/rules')
|
||||
@ -129,11 +124,6 @@ export const mihomoUpdateRuleProviders = async (name: string): Promise<void> =>
|
||||
return await instance.put(`/providers/rules/${encodeURIComponent(name)}`)
|
||||
}
|
||||
|
||||
export const mihomoRunRuleProviders = async (): Promise<IMihomoRuleProviders> => {
|
||||
const runtime = await getRuntimeConfig()
|
||||
return runtime?.['rule-providers']
|
||||
}
|
||||
|
||||
export const mihomoChangeProxy = async (group: string, proxy: string): Promise<IMihomoProxy> => {
|
||||
const instance = await getAxios()
|
||||
return await instance.put(`/proxies/${encodeURIComponent(group)}`, { name: proxy })
|
||||
@ -204,9 +194,9 @@ const mihomoTraffic = async (): Promise<void> => {
|
||||
if (process.platform !== 'linux') {
|
||||
tray?.setToolTip(
|
||||
'↑' +
|
||||
`${calcTraffic(json.up)}/s`.padStart(9) +
|
||||
'\n↓' +
|
||||
`${calcTraffic(json.down)}/s`.padStart(9)
|
||||
`${calcTraffic(json.up)}/s`.padStart(9) +
|
||||
'\n↓' +
|
||||
`${calcTraffic(json.down)}/s`.padStart(9)
|
||||
)
|
||||
}
|
||||
floatingWindow?.webContents.send('mihomoTraffic', json)
|
||||
|
||||
@ -99,6 +99,7 @@ async function initFiles(): Promise<void> {
|
||||
}
|
||||
await Promise.all([
|
||||
copy('country.mmdb'),
|
||||
copy('geoip.metadb'),
|
||||
copy('geoip.dat'),
|
||||
copy('geosite.dat'),
|
||||
copy('ASN.mmdb')
|
||||
|
||||
@ -8,9 +8,7 @@ import {
|
||||
mihomoProxies,
|
||||
mihomoProxyDelay,
|
||||
mihomoProxyProviders,
|
||||
mihomoRunProxyProviders,
|
||||
mihomoRuleProviders,
|
||||
mihomoRunRuleProviders,
|
||||
mihomoRules,
|
||||
mihomoUnfixedProxy,
|
||||
mihomoUpdateProxyProviders,
|
||||
@ -119,12 +117,10 @@ export function registerIpcMainHandlers(): void {
|
||||
ipcMain.handle('mihomoProxies', ipcErrorWrapper(mihomoProxies))
|
||||
ipcMain.handle('mihomoGroups', ipcErrorWrapper(mihomoGroups))
|
||||
ipcMain.handle('mihomoProxyProviders', ipcErrorWrapper(mihomoProxyProviders))
|
||||
ipcMain.handle('mihomoRunProxyProviders', ipcErrorWrapper(mihomoRunProxyProviders))
|
||||
ipcMain.handle('mihomoUpdateProxyProviders', (_e, name) =>
|
||||
ipcErrorWrapper(mihomoUpdateProxyProviders)(name)
|
||||
)
|
||||
ipcMain.handle('mihomoRuleProviders', ipcErrorWrapper(mihomoRuleProviders))
|
||||
ipcMain.handle('mihomoRunRuleProviders', ipcErrorWrapper(mihomoRunRuleProviders))
|
||||
ipcMain.handle('mihomoUpdateRuleProviders', (_e, name) =>
|
||||
ipcErrorWrapper(mihomoUpdateRuleProviders)(name)
|
||||
)
|
||||
|
||||
@ -107,7 +107,7 @@ export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
|
||||
'geox-url': {
|
||||
geoip: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip-lite.dat',
|
||||
geosite: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat',
|
||||
mmdb: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb',
|
||||
mmdb: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb',
|
||||
asn: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoLite2-ASN.mmdb'
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,20 +26,41 @@ const CopyableSettingItem: React.FC<{
|
||||
{ key: 'raw', text: displayName || (Array.isArray(value) ? value.join(', ') : value) },
|
||||
...(Array.isArray(value) && value.length === prefix.length
|
||||
? prefix.map((p, i) => value[i] ? ({
|
||||
key: `${p},${value[i]}${suffix}`,
|
||||
text: `${p},${value[i]}${suffix}`
|
||||
key: `${p},${p === 'IP-ASN' ? value[i].split(' ')[0] : value[i]}${suffix}`,
|
||||
text: `${p},${p === 'IP-ASN' ? value[i].split(' ')[0] : value[i]}${suffix}`
|
||||
}) : null).filter(Boolean)
|
||||
: prefix.flatMap(p =>
|
||||
(p === 'DOMAIN-SUFFIX'
|
||||
? getSubDomains(Array.isArray(value) ? value[0] : value)
|
||||
: p === 'IP-ASN'
|
||||
? [(Array.isArray(value) ? value[0] : value).split(' ')[0]]
|
||||
: [Array.isArray(value) ? value[0] : value]
|
||||
).map(v => ({
|
||||
key: `${p},${v}${suffix}`,
|
||||
text: `${p},${v}${suffix}`
|
||||
}))
|
||||
))
|
||||
(Array.isArray(value)
|
||||
? value.map(v => p === 'DOMAIN-SUFFIX'
|
||||
? getSubDomains(v).map(subV => ({
|
||||
key: `${p},${subV}${suffix}`,
|
||||
text: `${p},${subV}${suffix}`
|
||||
}))
|
||||
: p === 'IP-ASN' || p === 'SRC-IP-ASN'
|
||||
? [{
|
||||
key: `${p},${v.split(' ')[0]}${suffix}`,
|
||||
text: `${p},${v.split(' ')[0]}${suffix}`
|
||||
}]
|
||||
: [{
|
||||
key: `${p},${v}${suffix}`,
|
||||
text: `${p},${v}${suffix}`
|
||||
}]
|
||||
).flat()
|
||||
: p === 'DOMAIN-SUFFIX'
|
||||
? getSubDomains(value).map(v => ({
|
||||
key: `${p},${v}${suffix}`,
|
||||
text: `${p},${v}${suffix}`
|
||||
}))
|
||||
: p === 'IP-ASN' || p === 'SRC-IP-ASN'
|
||||
? [{
|
||||
key: `${p},${value.split(' ')[0]}${suffix}`,
|
||||
text: `${p},${value.split(' ')[0]}${suffix}`
|
||||
}]
|
||||
: [{
|
||||
key: `${p},${value}${suffix}`,
|
||||
text: `${p},${value}${suffix}`
|
||||
}]
|
||||
)))
|
||||
]
|
||||
|
||||
return (
|
||||
@ -137,7 +158,7 @@ const ConnectionDetailModal: React.FC<Props> = (props) => {
|
||||
suffix='/32'
|
||||
/>
|
||||
)}
|
||||
{connection.metadata.sourceGeoIP && (
|
||||
{connection.metadata.sourceGeoIP && connection.metadata.sourceGeoIP.length > 0 && (
|
||||
<CopyableSettingItem
|
||||
title='来源GeoIP'
|
||||
value={connection.metadata.sourceGeoIP}
|
||||
@ -159,7 +180,7 @@ const ConnectionDetailModal: React.FC<Props> = (props) => {
|
||||
suffix='/32'
|
||||
/>
|
||||
)}
|
||||
{connection.metadata.destinationGeoIP && (
|
||||
{connection.metadata.destinationGeoIP && connection.metadata.destinationGeoIP.length > 0 && (
|
||||
<CopyableSettingItem
|
||||
title='目标GeoIP'
|
||||
value={connection.metadata.destinationGeoIP}
|
||||
|
||||
@ -12,7 +12,7 @@ const GeoData: React.FC = () => {
|
||||
'geox-url': geoxUrl = {
|
||||
geoip: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip-lite.dat',
|
||||
geosite: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geosite.dat',
|
||||
mmdb: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/country-lite.mmdb',
|
||||
mmdb: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/geoip.metadb',
|
||||
asn: 'https://github.com/MetaCubeX/meta-rules-dat/releases/download/latest/GeoLite2-ASN.mmdb'
|
||||
},
|
||||
'geodata-mode': geoMode = false,
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
import { mihomoProxyProviders, mihomoUpdateProxyProviders, mihomoRunProxyProviders } from '@renderer/utils/ipc'
|
||||
import {
|
||||
mihomoProxyProviders,
|
||||
mihomoUpdateProxyProviders,
|
||||
getRuntimeConfig
|
||||
} from '@renderer/utils/ipc'
|
||||
import { Fragment, useEffect, useMemo, useState } from 'react'
|
||||
import Viewer from './viewer'
|
||||
import useSWR from 'swr'
|
||||
@ -7,6 +11,7 @@ import SettingItem from '../base/base-setting-item'
|
||||
import { Button, Chip } from '@nextui-org/react'
|
||||
import { IoMdRefresh, IoMdEye } from 'react-icons/io'
|
||||
import { CgLoadbarDoc } from 'react-icons/cg'
|
||||
import { MdEditDocument } from 'react-icons/md'
|
||||
import dayjs from 'dayjs'
|
||||
import { calcTraffic } from '@renderer/utils/calc'
|
||||
import { getHash } from '@renderer/utils/hash'
|
||||
@ -19,8 +24,9 @@ const ProxyProvider: React.FC = () => {
|
||||
useEffect(() => {
|
||||
const fetchProviderPath = async (name: string) => {
|
||||
try {
|
||||
const providers = await mihomoRunProxyProviders()
|
||||
const provider = providers[name]
|
||||
const providers = await getRuntimeConfig()
|
||||
const provider = providers['proxy-providers'][name]
|
||||
console.log(provider)
|
||||
if (provider?.path) {
|
||||
setShowPath(provider.path)
|
||||
} else if (provider?.url) {
|
||||
@ -73,7 +79,17 @@ const ProxyProvider: React.FC = () => {
|
||||
|
||||
return (
|
||||
<SettingCard>
|
||||
{ShowProvider && <Viewer onClose={() => { setShowProvider(false); setShowPath(''); setShowType('')}} path={ShowPath} type={ShowType} />}
|
||||
{ShowProvider && (
|
||||
<Viewer
|
||||
onClose={() => {
|
||||
setShowProvider(false)
|
||||
setShowPath('')
|
||||
setShowType('')
|
||||
}}
|
||||
path={ShowPath}
|
||||
type={ShowType}
|
||||
/>
|
||||
)}
|
||||
<SettingItem title="代理集合" divider>
|
||||
<Button
|
||||
size="sm"
|
||||
@ -100,21 +116,7 @@ const ProxyProvider: React.FC = () => {
|
||||
>
|
||||
<div className="flex h-[32px] leading-[32px] text-foreground-500">
|
||||
<div>{dayjs(provider.updatedAt).fromNow()}</div>
|
||||
<Button
|
||||
isIconOnly
|
||||
className="ml-2"
|
||||
size="sm"
|
||||
onPress={() => {
|
||||
onUpdate(provider.name, index)
|
||||
}}
|
||||
>
|
||||
<IoMdRefresh className={`text-lg ${updating[index] ? 'animate-spin' : ''}`} />
|
||||
</Button>
|
||||
<Button
|
||||
isIconOnly
|
||||
className="ml-2"
|
||||
size="sm"
|
||||
>
|
||||
<Button isIconOnly className="ml-2" size="sm">
|
||||
<IoMdEye className="text-lg" />
|
||||
</Button>
|
||||
<Button
|
||||
@ -126,7 +128,21 @@ const ProxyProvider: React.FC = () => {
|
||||
setShowPath(provider.name)
|
||||
}}
|
||||
>
|
||||
<CgLoadbarDoc className="text-lg" />
|
||||
{provider.vehicleType == 'File' ? (
|
||||
<MdEditDocument className={`text-lg`} />
|
||||
) : (
|
||||
<CgLoadbarDoc className={`text-lg`} />
|
||||
)}
|
||||
</Button>
|
||||
<Button
|
||||
isIconOnly
|
||||
className="ml-2"
|
||||
size="sm"
|
||||
onPress={() => {
|
||||
onUpdate(provider.name, index)
|
||||
}}
|
||||
>
|
||||
<IoMdRefresh className={`text-lg ${updating[index] ? 'animate-spin' : ''}`} />
|
||||
</Button>
|
||||
</div>
|
||||
</SettingItem>
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
import { mihomoRuleProviders, mihomoUpdateRuleProviders, mihomoRunRuleProviders } from '@renderer/utils/ipc'
|
||||
import {
|
||||
mihomoRuleProviders,
|
||||
mihomoUpdateRuleProviders,
|
||||
getRuntimeConfig
|
||||
} from '@renderer/utils/ipc'
|
||||
import { getHash } from '@renderer/utils/hash'
|
||||
import Viewer from './viewer'
|
||||
import { Fragment, useEffect, useMemo, useState } from 'react'
|
||||
@ -8,6 +12,7 @@ import SettingItem from '../base/base-setting-item'
|
||||
import { Button, Chip } from '@nextui-org/react'
|
||||
import { IoMdRefresh } from 'react-icons/io'
|
||||
import { CgLoadbarDoc } from 'react-icons/cg'
|
||||
import { MdEditDocument } from 'react-icons/md'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
const RuleProvider: React.FC = () => {
|
||||
@ -27,8 +32,8 @@ const RuleProvider: React.FC = () => {
|
||||
useEffect(() => {
|
||||
const fetchProviderPath = async (name: string) => {
|
||||
try {
|
||||
const providers = await mihomoRunRuleProviders()
|
||||
const provider = providers[name]
|
||||
const providers = await getRuntimeConfig()
|
||||
const provider = providers['rule-providers'][name]
|
||||
if (provider?.path) {
|
||||
setShowPath(provider.path)
|
||||
} else if (provider?.url) {
|
||||
@ -68,12 +73,18 @@ const RuleProvider: React.FC = () => {
|
||||
|
||||
return (
|
||||
<SettingCard>
|
||||
{ShowProvider && <Viewer
|
||||
path={ShowPath}
|
||||
type={ShowType}
|
||||
format={ShowFormat}
|
||||
onClose={() => { setShowProvider(false); setShowPath(''); setShowType('') }}
|
||||
/>}
|
||||
{ShowProvider && (
|
||||
<Viewer
|
||||
path={ShowPath}
|
||||
type={ShowType}
|
||||
format={ShowFormat}
|
||||
onClose={() => {
|
||||
setShowProvider(false)
|
||||
setShowPath('')
|
||||
setShowType('')
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<SettingItem title="规则集合" divider>
|
||||
<Button
|
||||
size="sm"
|
||||
@ -99,17 +110,7 @@ const RuleProvider: React.FC = () => {
|
||||
>
|
||||
<div className="flex h-[32px] leading-[32px] text-foreground-500">
|
||||
<div>{dayjs(provider.updatedAt).fromNow()}</div>
|
||||
<Button
|
||||
isIconOnly
|
||||
className="ml-2"
|
||||
size="sm"
|
||||
onPress={() => {
|
||||
onUpdate(provider.name, index)
|
||||
}}
|
||||
>
|
||||
<IoMdRefresh className={`text-lg ${updating[index] ? 'animate-spin' : ''}`} />
|
||||
</Button>
|
||||
{provider.format !== "MrsRule" && (
|
||||
{provider.format !== 'MrsRule' && (
|
||||
<Button
|
||||
isIconOnly
|
||||
className="ml-2"
|
||||
@ -120,9 +121,23 @@ const RuleProvider: React.FC = () => {
|
||||
setShowPath(provider.name)
|
||||
}}
|
||||
>
|
||||
<CgLoadbarDoc className={`text-lg`} />
|
||||
{provider.vehicleType == 'File' ? (
|
||||
<MdEditDocument className={`text-lg`} />
|
||||
) : (
|
||||
<CgLoadbarDoc className={`text-lg`} />
|
||||
)}
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
isIconOnly
|
||||
className="ml-2"
|
||||
size="sm"
|
||||
onPress={() => {
|
||||
onUpdate(provider.name, index)
|
||||
}}
|
||||
>
|
||||
<IoMdRefresh className={`text-lg ${updating[index] ? 'animate-spin' : ''}`} />
|
||||
</Button>
|
||||
</div>
|
||||
</SettingItem>
|
||||
<SettingItem
|
||||
|
||||
@ -43,10 +43,6 @@ export async function mihomoUpdateProxyProviders(name: string): Promise<void> {
|
||||
)
|
||||
}
|
||||
|
||||
export async function mihomoRunProxyProviders(): Promise<IMihomoRuleProviders> {
|
||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('mihomoRunProxyProviders'))
|
||||
}
|
||||
|
||||
export async function mihomoRuleProviders(): Promise<IMihomoRuleProviders> {
|
||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('mihomoRuleProviders'))
|
||||
}
|
||||
@ -57,10 +53,6 @@ export async function mihomoUpdateRuleProviders(name: string): Promise<void> {
|
||||
)
|
||||
}
|
||||
|
||||
export async function mihomoRunRuleProviders(): Promise<IMihomoRuleProviders> {
|
||||
return ipcErrorWrapper(await window.electron.ipcRenderer.invoke('mihomoRunRuleProviders'))
|
||||
}
|
||||
|
||||
export async function mihomoChangeProxy(group: string, proxy: string): Promise<IMihomoProxy> {
|
||||
return ipcErrorWrapper(
|
||||
await window.electron.ipcRenderer.invoke('mihomoChangeProxy', group, proxy)
|
||||
|
||||
8
src/shared/types.d.ts
vendored
8
src/shared/types.d.ts
vendored
@ -88,10 +88,10 @@ interface IMihomoConnectionDetail {
|
||||
network: 'tcp' | 'udp'
|
||||
type: string
|
||||
sourceIP: string
|
||||
sourceGeoIP: string
|
||||
sourceGeoIP: string[]
|
||||
sourceIPASN: string
|
||||
destinationIP: string
|
||||
destinationGeoIP: string
|
||||
destinationGeoIP: string[]
|
||||
destinationIPASN: string
|
||||
sourcePort: string
|
||||
destinationPort: string
|
||||
@ -181,8 +181,6 @@ interface IMihomoRuleProvider {
|
||||
type: string
|
||||
updatedAt: string
|
||||
vehicleType: string
|
||||
url: string
|
||||
path: string
|
||||
}
|
||||
|
||||
interface IMihomoProxyProviders {
|
||||
@ -205,8 +203,6 @@ interface IMihomoProxyProvider {
|
||||
testUrl?: string
|
||||
updatedAt?: string
|
||||
vehicleType: string
|
||||
url: string
|
||||
path: string
|
||||
}
|
||||
|
||||
interface ISysProxyConfig {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user