gs

grant-setproxy

setup proxy, type password only once

Showing:

Popularity

Downloads/wk

8

GitHub Stars

4

Maintenance

Last Commit

1yr ago

Contributors

1

Package

Dependencies

2

Size (min+gzip)

18.7KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

node-grant-setproxy

mac only!!! setup proxy, type password only once

Usage:

import {exec, setDialogName} from 'grant-setproxy';
// set mac os x grant dialog name
setDialogName('node-grant-setproxy');
await exec('-setwebproxystate', 'Wi-Fi', 'on');

type password once to authorize, never type again

you can find all avaliable args by typing networksetup in the command line;

Trouble Shooting

why can't my app change the proxy state?

use exactly 'Wi-Fi', not 'wi-fi', you can find the exact name in network settings

why does my app show grant dialog many times?

exec return a Promise, please use await

Wrong way, this will show dialog more than once:

exec('-setwebproxystate', 'Wi-Fi', 'on');
exec('-setwebproxystate', 'wi-Fi', 'off');

Right way, recommanded, es7

await exec('-setwebproxystate', 'Wi-Fi', 'on');
await exec('-setwebproxystate', 'Wi-Fi', 'off');

Right way, es6, es5 or es3

exec('-setwebproxystate', 'Wi-Fi', 'on').then(function () {
    exec('-setwebproxystate', 'Wi-Fi', 'off');
});

Example:

process.on('SIGINT', async function () {
    // disable proxy when control-c
    await exec('-setwebproxystate', 'Wi-Fi', 'off');
});

// set proxy to 127.0.0.1:8080
await exec('-setwebproxy', 'Wi-Fi', '127.0.0.1', '8080');

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100