Compare commits

...

3 Commits

Author SHA1 Message Date
Memory
7743097b51
fix: UWPTool no privileges 2025-08-29 20:06:43 +08:00
Memory
6d21f904b3
fix: tray icon refresh on shortcut usage 2025-08-29 13:16:19 +08:00
Memory
1da82c1b3b
feat: add IPv6 loopback addresses to skip-auth-prefixes 2025-08-29 13:15:23 +08:00
5 changed files with 29 additions and 5 deletions

View File

@ -10,6 +10,7 @@ import { triggerSysProxy } from '../sys/sysproxy'
import { patchMihomoConfig } from '../core/mihomoApi'
import { quitWithoutCore, restartCore } from '../core/manager'
import { floatingWindow, triggerFloatingWindow } from './floatingWindow'
import { updateTrayIcon } from './tray'
import i18next from '../../shared/i18n'
export async function registerShortcut(
@ -51,6 +52,7 @@ export async function registerShortcut(
// ignore
} finally {
ipcMain.emit('updateTrayMenu')
await updateTrayIcon()
}
})
}
@ -74,6 +76,7 @@ export async function registerShortcut(
// ignore
} finally {
ipcMain.emit('updateTrayMenu')
await updateTrayIcon()
}
})
}
@ -86,6 +89,7 @@ export async function registerShortcut(
}).show()
mainWindow?.webContents.send('controledMihomoConfigUpdated')
ipcMain.emit('updateTrayMenu')
await updateTrayIcon()
})
}
case 'globalModeShortcut': {
@ -97,6 +101,7 @@ export async function registerShortcut(
}).show()
mainWindow?.webContents.send('controledMihomoConfigUpdated')
ipcMain.emit('updateTrayMenu')
await updateTrayIcon()
})
}
case 'directModeShortcut': {
@ -108,6 +113,7 @@ export async function registerShortcut(
}).show()
mainWindow?.webContents.send('controledMihomoConfigUpdated')
ipcMain.emit('updateTrayMenu')
await updateTrayIcon()
})
}
case 'quitWithoutCoreShortcut': {

View File

@ -34,8 +34,20 @@ export function openFile(type: 'profile' | 'override', id: string, ext?: 'yaml'
}
export async function openUWPTool(): Promise<void> {
const execPromise = promisify(exec)
const execFilePromise = promisify(execFile)
const uwpToolPath = path.join(resourcesDir(), 'files', 'enableLoopback.exe')
const { checkAdminPrivileges } = await import('../core/manager')
const isAdmin = await checkAdminPrivileges()
if (!isAdmin) {
const escapedPath = uwpToolPath.replace(/'/g, "''")
const command = `powershell -Command "Start-Process -FilePath '${escapedPath}' -Verb RunAs -Wait"`
await execPromise(command, { windowsHide: true })
return
}
await execFilePromise(uwpToolPath)
}

View File

@ -272,7 +272,13 @@ async function migration(): Promise<void> {
}
// add default skip auth prefix
if (!skipAuthPrefixes) {
await patchControledMihomoConfig({ 'skip-auth-prefixes': ['127.0.0.1/32'] })
await patchControledMihomoConfig({ 'skip-auth-prefixes': ['127.0.0.1/32', '::1/128'] })
} else if (skipAuthPrefixes.length >= 1 && skipAuthPrefixes[0] === '127.0.0.1/32') {
const filteredPrefixes = skipAuthPrefixes.filter(ip => ip !== '::1/128')
const newPrefixes = [filteredPrefixes[0], '::1/128', ...filteredPrefixes.slice(1)]
if (JSON.stringify(newPrefixes) !== JSON.stringify(skipAuthPrefixes)) {
await patchControledMihomoConfig({ 'skip-auth-prefixes': newPrefixes })
}
}
// add default authentication
if (!authentication) {

View File

@ -65,7 +65,7 @@ export const defaultControledMihomoConfig: Partial<IMihomoConfig> = {
'lan-allowed-ips': ['0.0.0.0/0', '::/0'],
'lan-disallowed-ips': [],
authentication: [],
'skip-auth-prefixes': ['127.0.0.1/32'],
'skip-auth-prefixes': ['127.0.0.1/32', '::1/128'],
tun: {
enable: false,
device: process.platform === 'darwin' ? 'utun1500' : 'Mihomo',

View File

@ -48,7 +48,7 @@ const Mihomo: React.FC = () => {
'external-controller': externalController = '',
secret,
authentication = [],
'skip-auth-prefixes': skipAuthPrefixes = ['127.0.0.1/32'],
'skip-auth-prefixes': skipAuthPrefixes = ['127.0.0.1/32', '::1/128'],
'log-level': logLevel = 'info',
'find-process-mode': findProcessMode = 'strict',
'allow-lan': allowLan,
@ -743,7 +743,7 @@ const Mihomo: React.FC = () => {
return (
<div key={index} className="flex mb-2">
<Input
disabled={index === 0}
disabled={index === 0 || index === 1}
size="sm"
fullWidth
placeholder={t('mihomo.ipSegment.placeholder')}
@ -758,7 +758,7 @@ const Mihomo: React.FC = () => {
}
}}
/>
{index < skipAuthPrefixesInput.length && index !== 0 && (
{index < skipAuthPrefixesInput.length && index !== 0 && index !== 1 && (
<Button
className="ml-2"
size="sm"