refactor: simplify UID handling logic on unix

This commit is contained in:
ezequielnick 2025-09-05 10:47:14 +08:00
parent 895b74ca3f
commit dfbe11deb4

View File

@ -67,13 +67,10 @@ export const getMihomoIpcPath = (): string => {
}
}
const uid = process.getuid?.() || 0
const uid = process.getuid?.() || 'unknown'
const processId = process.pid
if (uid === 0) {
return '/tmp/mihomo-party-admin.sock'
} else {
return `/tmp/mihomo-party-${uid}.sock`
}
return `/tmp/mihomo-party-${uid}-${processId}.sock`
}
const ctlParam = process.platform === 'win32' ? '-ext-ctl-pipe' : '-ext-ctl-unix'