fixed problem with not closing websocket

There was a problem that prevented socket events like close and error from
getting through our duplex and to the websocket so it could close
This commit is contained in:
tigerbot 2017-05-26 17:26:44 -06:00
parent 7112bfdbb2
commit 8e71ae02cf
3 changed files with 6 additions and 27 deletions

View File

@ -2,7 +2,7 @@
var http = require('http');
var tls = require('tls');
var packerStream = require('tunnel-packer').Stream;
var wrapSocket = require('tunnel-packer').wrapSocket;
var redirectHttps = require('redirect-https')();
module.exports.create = function (program) {
@ -57,19 +57,8 @@ module.exports.create = function (program) {
// tlsServer.emit('connection', socket); // this didn't work either
//console.log('chunkLen', firstChunk.byteLength);
var myDuplex = packerStream.create(socket);
console.log('httpsInvalid servername', servername);
program.tlsInvalidSniServer.emit('connection', myDuplex);
socket.on('data', function (chunk) {
console.log('[' + Date.now() + '] socket data', chunk.byteLength);
myDuplex.push(chunk);
});
socket.on('error', function (err) {
console.error('[error] httpsInvalid TODO close');
console.error(err);
});
program.tlsInvalidSniServer.emit('connection', wrapSocket(socket));
};
//
@ -97,18 +86,7 @@ module.exports.create = function (program) {
// tlsServer.emit('connection', socket); // this didn't work either
//console.log('chunkLen', firstChunk.byteLength);
var myDuplex = packerStream.create(socket);
console.log('httpsTunnel (Admin) servername', servername);
program.tlsTunnelServer.emit('connection', myDuplex);
socket.on('data', function (chunk) {
console.log('[' + Date.now() + '] socket data', chunk.byteLength);
myDuplex.push(chunk);
});
socket.on('error', function (err) {
console.error('[error] httpsTunnel (Admin) TODO close');
console.error(err);
});
program.tlsTunnelServer.emit('connection', wrapSocket(socket));
};
};

View File

@ -51,10 +51,10 @@
"commander": "^2.9.0",
"greenlock": "^2.1.12",
"jsonwebtoken": "^7.1.9",
"localhost.daplie.me-certificates": "^1.3.0",
"localhost.daplie.me-certificates": "^1.3.3",
"redirect-https": "^1.1.0",
"sni": "^1.0.0",
"tunnel-packer": "^1.2.0",
"tunnel-packer": "^1.3.0",
"ws": "^2.2.3"
}
}

View File

@ -347,6 +347,7 @@ module.exports.create = function (copts) {
Object.keys(remotes).forEach(function (jwtoken) {
removeToken(jwtoken);
});
ws.terminate();
}
ws.on('close', hangup);