Skip to content

Commit

Permalink
#2 Changing OS proxy settings programmatically - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kdzwinel committed Apr 1, 2016
1 parent ce0e2f2 commit 2935b35
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"chalk": "^1.1.1",
"http-mitm-proxy": "^0.4.0",
"istextorbinary": "^1.0.2",
"minimist": "^1.2.0"
"minimist": "^1.2.0",
"system-proxy": "https://github.com/kdzwinel/system-proxy"
},
"devDependencies": {
"electron-packager": "^6.0.0",
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ const options = {

app.on('ready', () => {

process.title = 'betwixt';

let mainWindow = new BrowserWindow({
title: 'Betwixt ⚡',
width: 800,
Expand Down
17 changes: 17 additions & 0 deletions src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const shell = require('electron').shell;
const path = require('path');
const proxy = require('system-proxy');

function buildMenu(app, options) {
const template = [
Expand Down Expand Up @@ -51,6 +52,22 @@ function buildMenu(app, options) {
click: () => {
shell.showItemInFolder(path.resolve(options.sslCaDir, 'certs', 'ca.pem'));
}
},
{
label: 'Enable system proxy',
click: () => {
proxy.setProxyOn('localhost', options.port)
.then(() => console.log('Proxy enable OK'))
.catch(() => console.log('Proxy enable FAIL'));
}
},
{
label: 'Disable system proxy',
click: () => {
proxy.setProxyOff('localhost', options.port)
.then(() => console.log('Proxy disable OK'))
.catch(() => console.log('Proxy enable FAIL'));
}
}
]
}
Expand Down

0 comments on commit 2935b35

Please sign in to comment.