update version

This commit is contained in:
VincentChanX
2017-04-06 14:56:42 +08:00
parent f6e8fc4ed1
commit 5dabe063ec
4 changed files with 45 additions and 35 deletions

View File

@@ -2,7 +2,7 @@ const TCPRelay = require('./tcprelay').TCPRelay;
const local = require('commander'); const local = require('commander');
local local
.version('0.1.1') .version('0.1.2')
.option('-m --method [method]', 'encryption method, default: aes-256-cfb') .option('-m --method [method]', 'encryption method, default: aes-256-cfb')
.option('-k --password [password]', 'password') .option('-k --password [password]', 'password')
.option('-s --server-address [address]', 'server address') .option('-s --server-address [address]', 'server address')

View File

@@ -1,6 +1,6 @@
{ {
"name": "shadowsocks-over-websocket", "name": "shadowsocks-over-websocket",
"version": "0.1.1", "version": "0.1.2",
"description": "A fast tunnel proxy that helps you bypass firewalls", "description": "A fast tunnel proxy that helps you bypass firewalls",
"main": "tcprelay.js", "main": "tcprelay.js",
"scripts": { "scripts": {

View File

@@ -2,7 +2,7 @@ const TCPRelay = require('./tcprelay').TCPRelay;
const server = require('commander'); const server = require('commander');
server server
.version('0.1.1') .version('0.1.2')
.option('-m --method [method]', 'encryption method, default: aes-256-cfb') .option('-m --method [method]', 'encryption method, default: aes-256-cfb')
.option('-k --password [password]', 'password') .option('-k --password [password]', 'password')
.option('-s --server-address [address]', 'server address') .option('-s --server-address [address]', 'server address')

View File

@@ -107,16 +107,23 @@ TCPRelay.prototype.getServerName = function() {
TCPRelay.prototype.bootstrap = function() { TCPRelay.prototype.bootstrap = function() {
this.init(); return this.init();
}; };
TCPRelay.prototype.stop = function() { TCPRelay.prototype.stop = function() {
return new Promise(function(resolve, reject) {
if (this.server) { if (this.server) {
this.server.close(); this.server.close(function() {
resolve();
});
} else {
resolve();
} }
});
}; };
TCPRelay.prototype.init = function() { TCPRelay.prototype.init = function() {
return new Promise(function(resolve, reject) {
var self = this; var self = this;
var config = self.config; var config = self.config;
var port = self.isLocal ? config.localPort : config.serverPort; var port = self.isLocal ? config.localPort : config.serverPort;
@@ -145,9 +152,12 @@ TCPRelay.prototype.init = function() {
} }
server.on('error', function(error) { server.on('error', function(error) {
self.logger.error('an error of', self.getServerName(), 'occured', error); self.logger.error('an error of', self.getServerName(), 'occured', error);
reject(error);
}); });
server.on('listening', function() { server.on('listening', function() {
self.logger.info(self.getServerName(), 'is listening on', address + ':' + port); self.logger.info(self.getServerName(), 'is listening on', address + ':' + port);
resolve();
});
}); });
}; };