From 3fe62c6b022365b1ed2587dd9bbcc81be81416de Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Fri, 1 Jun 2018 06:48:18 +0000 Subject: [PATCH] fix server.close() bug --- telebitd.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/telebitd.js b/telebitd.js index d6e233c..5fee923 100644 --- a/telebitd.js +++ b/telebitd.js @@ -49,7 +49,7 @@ module.exports.create = function (state) { } conn.once('data', function (firstChunk) { - console.log("[DynTcp] examining firstChunk", serviceport); + if (state.debug) { console.log("[DynTcp]", serviceport, "examining firstChunk from", Packer.socketToId(conn)); } conn.pause(); conn.unshift(firstChunk); @@ -78,7 +78,7 @@ module.exports.create = function (state) { // pipeWs(servername, servicename, client, remote, serviceport) // remote.clients is managed as part of the piping process - console.log("[DynTcp] piping to remote", serviceport); + if (state.debug) { console.log("[DynTcp]", serviceport, "piping to remote"); } pipeWs(null, 'tcp', conn, remote, serviceport) process.nextTick(function () { conn.resume(); }); @@ -256,8 +256,10 @@ module.exports.create = function (state) { }); remote.ws = null; remote.upgradeReq = null; + remote.serverPort = remote.server.address().port; remote.server.close(function () { - console.log("[DynTcpConn] closing server for ", remote.server.address().port); + console.log("[DynTcpConn] closing server for ", remote.serverPort); + remote.serverPort = null; }); remote.server = null;