Add support for system proxy

release
aandrew-me 2 months ago
parent ee343d82e6
commit 38b983dd35

@ -291,6 +291,11 @@ ipcMain.on("quit", () => {
app.quit();
});
ipcMain.handle('get-proxy', async (event, url) => {
const sess = event.sender.session; // get session from sender
const proxy = await sess.resolveProxy(url);
return proxy;
});
// Auto update
let autoUpdate = false;

@ -89,6 +89,19 @@ function checkMaxDownloads() {
}
checkMaxDownloads();
// Get system proxy
getSystemProxy("https://www.google.com").then(proxyInfo => {
if (proxyInfo != "DIRECT") {
try {
const proxyUrl = proxyInfo.split(" ")[1]
proxy = proxyUrl
console.log("System proxy: " + proxy)
} catch (_) {}
}
})
// Check for auto updates
let autoUpdate = true;
const autoUpdateStatus = localStorage.getItem("autoUpdate");
@ -345,6 +358,7 @@ async function getInfo(url) {
proxy = getLocalStorageItem("proxy");
// Whether to use browser cookies or not
if (localStorage.getItem("browser")) {
browser = localStorage.getItem("browser");
@ -1408,6 +1422,11 @@ function afterSave(location, filename, progressId, thumbnail) {
window.scrollTo(0, document.body.scrollHeight);
}
async function getSystemProxy(url) {
const proxy = await ipcRenderer.invoke("get-proxy", url);
return proxy;
}
function showItem(location, filename) {
shell.showItemInFolder(`${path.join(location, filename)}`);
}

Loading…
Cancel
Save