rm grant logic for unix socket

This commit is contained in:
pompurin404 2024-09-27 22:39:34 +08:00
parent f55ea7d320
commit 46486d75c9
No known key found for this signature in database

View File

@ -125,7 +125,6 @@ export async function startCore(detached = false): Promise<Promise<void>[]> {
(process.platform !== 'win32' && str.includes('RESTful API unix listening at')) ||
(process.platform === 'win32' && str.includes('RESTful API pipe listening at'))
) {
await autoGrantUnixSocket()
resolve([
new Promise((resolve) => {
child.stdout?.on('data', async (data) => {
@ -217,25 +216,6 @@ async function checkProfile(): Promise<void> {
}
}
async function autoGrantUnixSocket(): Promise<void> {
if (process.platform === 'win32') return
const { encryptedPassword } = await getAppConfig()
const { 'external-controller-unix': mihomoUnix = 'mihomo-party.sock' } =
await getControledMihomoConfig()
const execPromise = promisify(exec)
if (encryptedPassword && isEncryptionAvailable()) {
try {
const password = safeStorage.decryptString(Buffer.from(encryptedPassword))
await execPromise(
`echo "${password}" | sudo -S chmod 777 "${path.join(mihomoWorkDir(), mihomoUnix)}"`
)
} catch (error) {
patchAppConfig({ encryptedPassword: undefined })
throw error
}
}
}
export async function autoGrantCorePermition(corePath: string): Promise<void> {
if (process.platform === 'win32') return
const { encryptedPassword } = await getAppConfig()