feat(bin): add 'blinksocks-init' and 'blinksocks-run' sub commands

This commit is contained in:
Micooz 2017-03-09 16:17:46 +08:00
parent 2c0323cfc0
commit c17751a041
7 changed files with 45 additions and 21 deletions

6
bin/bootstrap.js vendored

@ -27,13 +27,13 @@ const examples = `
Examples:
As simple as possible:
$ blinksocks -c config.json
$ blinksocks run -c config.json
To start a server:
$ blinksocks --host 0.0.0.0 --port 7777 --key password
$ blinksocks run --host 0.0.0.0 --port 7777 --key password
To start a client:
$ blinksocks --host localhost --port 1080 --server-host example.com --server-port 7777 --key password
$ blinksocks run --host localhost --port 1080 --server-host example.com --server-port 7777 --key password
`;
/**

3
bin/cli-init.js Executable file

@ -0,0 +1,3 @@
#!/usr/bin/env node
// TODO

6
bin/cli-run.js Executable file

@ -0,0 +1,6 @@
#!/usr/bin/env node
require('babel-polyfill');
const Hub = require('../lib').Hub;
const bootstrap = require('./bootstrap');
bootstrap({Hub});

@ -1,6 +1,19 @@
#!/usr/bin/env node
require('babel-polyfill');
const Hub = require('../lib').Hub;
const bootstrap = require('./bootstrap');
const program = require('commander');
const packageJson = require('../package.json');
bootstrap({Hub});
const usage = '[command] [options]';
program
.version(packageJson.version)
.usage(usage)
.command('init', 'generate configuration pair randomly')
.command('run [options]', 'start service')
.parse(process.argv);
// no options provided
if (process.argv.length < 2) {
program.help();
process.exit(0);
}

@ -4,7 +4,9 @@
"description": "Yet another socks5 proxy, designed for speed.",
"main": "lib/index.js",
"bin": {
"blinksocks": "bin/cli.js"
"blinksocks": "bin/cli.js",
"blinksocks-init": "bin/cli-init.js",
"blinksocks-run": "bin/cli-run.js"
},
"scripts": {
"test": "npm run lint && npm run test:coverage",
@ -40,10 +42,10 @@
"babel-preset-latest": "^6.22.0",
"babel-register": "^6.23.0",
"benchmark": "^2.1.3",
"eslint": "^3.17.0",
"eslint": "^3.17.1",
"eslint-config-babel": "^6.0.0",
"eslint-plugin-babel": "^4.1.0",
"eslint-plugin-flowtype": "^2.30.0",
"eslint-plugin-babel": "^4.1.1",
"eslint-plugin-flowtype": "^2.30.3",
"husky": "^0.13.2",
"jest": "^19.0.2"
},

@ -19,4 +19,4 @@ mkdir -p /blinksocks && touch ${CONFIG_FILE}
echo ">>> Generated configuration with random key..."
echo ">>> Running blinksocks with ${CONFIG_FILE}"
pm2 start blinksocks -i 3 -- --config ${CONFIG_FILE}
pm2 start blinksocks-run -i 3 -- --config ${CONFIG_FILE}

@ -1170,19 +1170,19 @@ eslint-config-babel@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/eslint-config-babel/-/eslint-config-babel-6.0.0.tgz#66feedf6ce6e04abe585cec1a65b5bcc96bed50a"
eslint-plugin-babel@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-4.1.0.tgz#837a74c092ad4d74f9fc74aed43f750906adc827"
eslint-plugin-babel@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-babel/-/eslint-plugin-babel-4.1.1.tgz#ef285c87039b67beb3bbd227f5b0eed4fb376b87"
eslint-plugin-flowtype@^2.30.0:
version "2.30.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.30.0.tgz#3054a265f9c8afe3046c3d41b72d32a736f9b4ae"
eslint-plugin-flowtype@^2.30.3:
version "2.30.3"
resolved "https://registry.yarnpkg.com/eslint-plugin-flowtype/-/eslint-plugin-flowtype-2.30.3.tgz#57835d2c0ed388da7a2725803ec32af2f437c301"
dependencies:
lodash "^4.15.0"
eslint@^3.17.0:
version "3.17.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.17.0.tgz#e2704b09c5bae9fb49ee8bafeea3832c7257d498"
eslint@^3.17.1:
version "3.17.1"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-3.17.1.tgz#b80ae12d9c406d858406fccda627afce33ea10ea"
dependencies:
babel-code-frame "^6.16.0"
chalk "^1.1.3"