mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-27 05:00:30 +08:00
rm grant logic for unix socket
This commit is contained in:
parent
f55ea7d320
commit
46486d75c9
@ -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 unix listening at')) ||
|
||||||
(process.platform === 'win32' && str.includes('RESTful API pipe listening at'))
|
(process.platform === 'win32' && str.includes('RESTful API pipe listening at'))
|
||||||
) {
|
) {
|
||||||
await autoGrantUnixSocket()
|
|
||||||
resolve([
|
resolve([
|
||||||
new Promise((resolve) => {
|
new Promise((resolve) => {
|
||||||
child.stdout?.on('data', async (data) => {
|
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> {
|
export async function autoGrantCorePermition(corePath: string): Promise<void> {
|
||||||
if (process.platform === 'win32') return
|
if (process.platform === 'win32') return
|
||||||
const { encryptedPassword } = await getAppConfig()
|
const { encryptedPassword } = await getAppConfig()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user