mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
optimized tun enable logic
This commit is contained in:
parent
253e2f20df
commit
8e00cb4bbf
@ -8,8 +8,13 @@ import {
|
||||
mihomoWorkDir
|
||||
} from '../utils/dirs'
|
||||
import { generateProfile } from './factory'
|
||||
import { getAppConfig, getControledMihomoConfig, patchAppConfig } from '../config'
|
||||
import { dialog, safeStorage } from 'electron'
|
||||
import {
|
||||
getAppConfig,
|
||||
getControledMihomoConfig,
|
||||
patchAppConfig,
|
||||
patchControledMihomoConfig
|
||||
} from '../config'
|
||||
import { dialog, ipcMain, safeStorage } from 'electron'
|
||||
import {
|
||||
startMihomoTraffic,
|
||||
startMihomoConnections,
|
||||
@ -74,6 +79,9 @@ export async function startCore(): Promise<Promise<void>[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
child.stdout?.on('data', async (data) => {
|
||||
if (data.toString().includes('configure tun interface: operation not permitted')) {
|
||||
patchControledMihomoConfig({ tun: { enable: false } })
|
||||
mainWindow?.webContents.send('controledMihomoConfigUpdated')
|
||||
ipcMain.emit('updateTrayMenu')
|
||||
reject('虚拟网卡启动失败, 请尝试手动授予内核权限')
|
||||
}
|
||||
if (data.toString().includes('External controller listen error')) {
|
||||
|
||||
@ -71,7 +71,9 @@ const TunSwitcher: React.FC = () => {
|
||||
try {
|
||||
const encrypted = await encryptString(password)
|
||||
await patchAppConfig({ encryptedPassword: encrypted })
|
||||
await patchControledMihomoConfig({ tun: { enable: true }, dns: { enable: true } })
|
||||
await restartCore()
|
||||
window.electron.ipcRenderer.send('updateTrayMenu')
|
||||
setOpenPasswordModal(false)
|
||||
} catch (e) {
|
||||
alert(e)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user