diff --git a/lib/socks5-server.js b/lib/socks5-server.js index cd31862..6ad9eb0 100644 --- a/lib/socks5-server.js +++ b/lib/socks5-server.js @@ -2,16 +2,16 @@ module.exports.create = function () { var PromiseA = require('bluebird'); - var enableDestroy = require('server-destroy'); var server; function curState() { - if (!server) { + var addr = server && server.address(); + if (!addr) { return PromiseA.resolve({running: false}); } return PromiseA.resolve({ running: true - , port: server.address().port + , port: addr.port }); } @@ -24,7 +24,9 @@ module.exports.create = function () { accept(); }); - enableDestroy(server); + // It would be nice if we could use `server-destroy` here, but we can't because + // the socksv5 library will not give us access to any sockets it actually + // handles, so we have no way of keeping track of them or closing them. server.on('close', function () { server = null; }); @@ -51,11 +53,7 @@ module.exports.create = function () { return curState(); } return new PromiseA(function (resolve, reject) { - var timeoutId = setTimeout(function () { - server.destroy(); - }, 1000); server.close(function (err) { - clearTimeout(timeoutId); if (err) { reject(err); } else {