Skip to content

Commit

Permalink
feat: add lan proxy for mac
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-AshishRanjan committed Jan 21, 2024
1 parent 7fdfa8f commit b36b728
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,13 @@ ipcMain.on("proxy:set", (e, options) => {
: null;
});

// if (isMac) {
// setMacAllProxy(
// `http://${options.ipAddress}:${options.port}`,
// options.ipAddress,
// options.port
// );
// }
if (isMac) {
setMacAllProxy(
`http://${options.ipAddress}:${options.port}`,
options.ipAddress,
options.port
);
}
});
ipcMain.on("proxy:unset", (e, options) => {
console.log(options);
Expand All @@ -474,9 +474,9 @@ ipcMain.on("proxy:unset", (e, options) => {
proxyManagerSudo = result;
result !== null && isLinux ? await unsetLinuxAllProxyPrompt() : null;
});
// if (isMac) {
// unsetMacAllProxy();
// }
if (isMac) {
unsetMacAllProxy();
}
});
ipcMain.on("proxy:check", (e, options) => {
console.log(options);
Expand Down Expand Up @@ -1066,29 +1066,16 @@ async function setMacAllProxy(proxyServer, host, port) {
exec(command, (error, stdout, stderr) => {
if (error) {
console.error("Got an Error : ", stderr);
mainWindow.webContents.send("proxy:error", {
msg: stderr,
});
return;
}
console.log({ stdout });
console.log(`command executed successfully: ${command}`);
})
);
mainWindow.webContents.send("proxy:success", {
msg: `success : set system env, npm`,
});
}

async function unsetMacAllProxy() {
console.log(proxyServer);
// const allCommands = [
// `npm config delete proxy`,
// `npm config delete https-proxy`,
// `networksetup -setmanual "USB 10/100/1000 LAN" 192.168.212.82 255.255.240.0 192.168.208.1`,
// `networksetup -setwebproxy "USB 10/100/1000 LAN" "" ""`,
// `networksetup -setsecurewebproxy "USB 10/100/1000 LAN" "" ""`,
// ];
const allCommands = [
`networksetup -setwebproxy "USB 10/100/1000 LAN" "" ""`,
`networksetup -setsecurewebproxy "USB 10/100/1000 LAN" "" ""`,
Expand All @@ -1097,18 +1084,12 @@ async function unsetMacAllProxy() {
exec(command, (error, stdout, stderr) => {
if (error) {
console.error("Got an Error : ", stderr);
mainWindow.webContents.send("proxy:error", {
msg: stderr,
});
return;
}
console.log({ stdout });
console.log(`command executed successfully: ${command}`);
})
);
mainWindow.webContents.send("proxy:success", {
msg: `success : unset system env, npm`,
});
}

// async function setMacAllProxyPrompt(host, port) {
Expand Down

0 comments on commit b36b728

Please sign in to comment.