mirror of
https://github.com/xenos1337/httptoolkit-patcher.git
synced 2026-07-15 16:20:02 +02:00
Fix Linux compatibility for permission elevation and HTTP Toolkit launching
- Show sudo instructions instead of auto-elevating on Linux - Show manual launch instructions instead of auto-launching HTTP Toolkit on Linux - Windows and macOS behavior unchanged
This commit is contained in:
@@ -130,7 +130,14 @@ const requestElevation = async () => {
|
|||||||
console.error(chalk.redBright`[-] Please run as administrator manually`);
|
console.error(chalk.redBright`[-] Please run as administrator manually`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
} else if (isLinux) {
|
||||||
|
// Linux: Cannot auto-elevate with sudo, show instructions instead
|
||||||
|
console.log(chalk.yellowBright`[!] Elevated permissions are required for patching on Linux`);
|
||||||
|
console.log(chalk.yellowBright`[!] Please re-run this script with sudo:`);
|
||||||
|
console.log(chalk.blueBright` sudo node ${__filename}`);
|
||||||
|
process.exit(1);
|
||||||
} else {
|
} else {
|
||||||
|
// macOS: Try to elevate with sudo
|
||||||
console.log(chalk.blueBright`[+] Restarting with sudo...`);
|
console.log(chalk.blueBright`[+] Restarting with sudo...`);
|
||||||
try {
|
try {
|
||||||
const child = spawn("sudo", ["node", __filename], {
|
const child = spawn("sudo", ["node", __filename], {
|
||||||
@@ -398,14 +405,21 @@ const patchApp = async () => {
|
|||||||
// Step 12: Open HTTP Toolkit as detached process
|
// Step 12: Open HTTP Toolkit as detached process
|
||||||
console.log(chalk.blueBright`[+] Opening HTTP Toolkit...`);
|
console.log(chalk.blueBright`[+] Opening HTTP Toolkit...`);
|
||||||
try {
|
try {
|
||||||
const command = isWin ? `"${path.resolve(appPath, "..", "HTTP Toolkit.exe")}"` : isMac ? 'open -a "HTTP Toolkit"' : "httptoolkit";
|
if (isLinux) {
|
||||||
const child = spawn(command, {
|
// Linux: Cannot auto-launch reliably, show manual instructions
|
||||||
stdio: "ignore",
|
console.log(chalk.yellowBright`[!] HTTP Toolkit has been successfully patched`);
|
||||||
shell: true,
|
console.log(chalk.yellowBright`[!] Please manually launch HTTP Toolkit from your applications menu or using the command:`);
|
||||||
detached: true,
|
console.log(chalk.blueBright` httptoolkit`);
|
||||||
});
|
} else {
|
||||||
child.unref(); // Completely detach the child process
|
const command = isWin ? `"${path.resolve(appPath, "..", "HTTP Toolkit.exe")}"` : isMac ? 'open -a "HTTP Toolkit"' : "httptoolkit";
|
||||||
console.log(chalk.greenBright`[+] HTTP Toolkit launched successfully`);
|
const child = spawn(command, {
|
||||||
|
stdio: "ignore",
|
||||||
|
shell: true,
|
||||||
|
detached: true,
|
||||||
|
});
|
||||||
|
child.unref(); // Completely detach the child process
|
||||||
|
console.log(chalk.greenBright`[+] HTTP Toolkit launched successfully`);
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(chalk.yellowBright`[!] Could not auto-start HTTP Toolkit: ${e.message}`);
|
console.error(chalk.yellowBright`[!] Could not auto-start HTTP Toolkit: ${e.message}`);
|
||||||
console.log(chalk.blueBright`[+] Please start HTTP Toolkit manually`);
|
console.log(chalk.blueBright`[+] Please start HTTP Toolkit manually`);
|
||||||
|
|||||||
Reference in New Issue
Block a user