ssr-helper
Advanced tools
Comparing version 1.0.9 to 1.1.0
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
const config = new Conf() | ||
const localConfig = new Conf({configName: 'local'}) | ||
const localConfig = new Conf({ configName: 'local' }) | ||
@@ -22,3 +22,3 @@ if (!config.has('servers')) config.set('servers', []) // Fix servers undefined problem | ||
.usage('[options] {command} ...') | ||
.command('welcome', 'show Welcome Message', {isDefault: true}) | ||
.command('welcome', 'show Welcome Message', { isDefault: true }) | ||
.command('config [path]', 'set ssr python client\'s location') | ||
@@ -29,2 +29,3 @@ .command('add', 'add a host mannually') | ||
.command('ls', 'list all hosts by group and you can view their config') | ||
.command('delay', 'test routes delay') | ||
.command('edit', 'list all hosts by group and you can edit their config') | ||
@@ -31,0 +32,0 @@ .command('local', 'edit SSR\'s local config, need reconnect after config') |
@@ -9,3 +9,5 @@ const request = require('then-request') | ||
const SocksProxyAgent = require('socks-proxy-agent') | ||
const program = require('commander') | ||
const socksaddress = 'socks://127.0.0.1:1080' | ||
if (!config.has('subscribe')) config.set('subscribe', []) | ||
@@ -16,21 +18,30 @@ let list = config.get('subscribe') | ||
inquirer.prompt([ | ||
{ | ||
type: 'list', | ||
name: 'proxy', | ||
message: 'Do you want to update list through proxy?', | ||
choices: [{ | ||
name: 'Direct(without proxy)', | ||
value: 0 | ||
}, { | ||
name: 'Through connected SSR proxy', | ||
value: 1 | ||
}] | ||
} | ||
]).then(function (answers) { | ||
return answers.proxy ? new SocksProxyAgent('socks://127.0.0.1:1080') : false | ||
program.option("-d, --direct", "Direct(without proxy)") | ||
.option("-p, --proxy", "Through connected SSR proxy") | ||
.parse(process.argv) | ||
new Promise((resolve, reject) => { | ||
if (program.proxy) return resolve(new SocksProxyAgent(socksaddress)); | ||
else if (program.direct) return resolve(false); | ||
//interactive mode | ||
else resolve(inquirer.prompt([ | ||
{ | ||
type: 'list', | ||
name: 'proxy', | ||
message: 'Do you want to update list through proxy?', | ||
choices: [{ | ||
name: 'Direct(without proxy)', | ||
value: 0 | ||
}, { | ||
name: 'Through connected SSR proxy', | ||
value: 1 | ||
}] | ||
} | ||
]).then(function (answers) { | ||
return answers.proxy ? new SocksProxyAgent(socksaddress) : false | ||
})) | ||
}).then(proxy => { | ||
//fetch and update | ||
while (i--) { | ||
const spinner = ora(chalk.green(chalk.green(list[i]))).start() | ||
request('GET', list[i], {agent: proxy}) | ||
request('GET', list[i], { agent: proxy }) | ||
.then(r => { | ||
@@ -42,7 +53,7 @@ if (r.statusCode !== 200) throw new Error() | ||
let tArr = Buffer.from(body, 'base64') | ||
.toString() | ||
.replace(/\r\n/g, '') | ||
.replace(/\n/g, '') | ||
.split('ssr://') | ||
.reverse() | ||
.toString() | ||
.replace(/\r\n/g, '') | ||
.replace(/\n/g, '') | ||
.split('ssr://') | ||
.reverse() | ||
let j = tArr.length | ||
@@ -49,0 +60,0 @@ console.log() |
{ | ||
"name": "ssr-helper", | ||
"version": "1.0.9", | ||
"version": "1.1.0", | ||
"description": "A CLI Helper designed for Python port of ShadowsocksR", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
54984
34
540
1