From dbd1e23bfabd1c720af8a8a04c98f58616f56842 Mon Sep 17 00:00:00 2001 From: tigerbot Date: Mon, 1 May 2017 17:52:22 -0600 Subject: [PATCH] fixed a few minor things --- bin/goldilocks.js | 2 +- lib/servers.js | 9 ++++++--- update-packages.sh | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/goldilocks.js b/bin/goldilocks.js index 59312c7..4b8616a 100755 --- a/bin/goldilocks.js +++ b/bin/goldilocks.js @@ -166,7 +166,7 @@ else if (process.argv.length > 2) { var program = require('commander'); program - .version(require('package.json').version) + .version(require('../package.json').version) .option('--agree-tos [url1,url2]', "agree to all Terms of Service for Daplie, Let's Encrypt, etc (or specific URLs only)") .option('--config', 'Path to config file (Goldilocks.json or Goldilocks.yml) example: --config /etc/goldilocks/Goldilocks.json') .option('--tunnel [token]', 'Turn tunnel on. This will enter interactive mode for login if no token is specified.') diff --git a/lib/servers.js b/lib/servers.js index a0afb0b..280e716 100644 --- a/lib/servers.js +++ b/lib/servers.js @@ -6,7 +6,7 @@ module.exports.addTcpListener = function (port, handler) { var PromiseA = require('bluebird'); return new PromiseA(function (resolve, reject) { - var stat = serversMap[port] || serversMap[port]; + var stat = serversMap[port]; if (stat) { if (stat._closing) { @@ -37,6 +37,10 @@ module.exports.addTcpListener = function (port, handler) { , _closing: false }; + // Add .destroy so we can close all open connections. Better if added before listen + // to eliminate any possibility of it missing an early connection in it's records. + enableDestroy(server); + server.on('connection', function (conn) { conn.__port = port; conn.__proto = 'tcp'; @@ -62,8 +66,6 @@ module.exports.addTcpListener = function (port, handler) { resolved = true; resolve(); }); - - enableDestroy(server); // adds .destroy }); }; module.exports.closeTcpListener = function (port) { @@ -72,6 +74,7 @@ module.exports.closeTcpListener = function (port) { return new PromiseA(function (resolve) { var stat = serversMap[port]; if (!stat) { + resolve(); return; } stat.server.on('close', function () { diff --git a/update-packages.sh b/update-packages.sh index ee658c2..776aa3c 100644 --- a/update-packages.sh +++ b/update-packages.sh @@ -18,5 +18,5 @@ popd mkdir -p well-known pushd well-known -ln -sf ../org.oauth3/well-known/oauth3 ./oauth3 +ln -snf ../org.oauth3/well-known/oauth3 ./oauth3 popd