function setProxy (mode, proxyServer) {
mode = mode || store.get('enableProxy');
switch (mode) {
case 'custom': {
const { host, port, protocol } = store.get('proxy');
log('Custom proxy %s:%s.', host, port);
proxyServer = protocol + host + ':' + port;
log(proxyServer);
mainWindow.webContents.session.setProxy({
proxyRules: proxyServer
});
break;
}
case 'system': {
log('Auto detect proxy');
mainWindow.webContents.session.setProxy({ mode: 'system' });
break;
}
case 'disable':
default:
log('Disable proxy');
mainWindow.webContents.session.setProxy({ mode: 'direct' });
break;
}
}