added some error event handlers

This commit is contained in:
tigerbot 2017-05-26 19:28:39 -06:00
parent e259c4d0ce
commit be6900cd50
2 changed files with 10 additions and 1 deletions

View File

@ -68,7 +68,13 @@ module.exports.create = function (deps, config) {
return;
}
function onError(err) {
console.error('[error] socket errored peeking -', err);
conn.destroy();
}
conn.once('error', onError);
conn.once('data', function (chunk) {
conn.removeListener('error', onError);
peek(conn, chunk, opts);
});
}

View File

@ -183,7 +183,7 @@ module.exports.create = function (deps, config, netHandler) {
};
var terminateServer = tls.createServer(terminatorOpts, function (socket) {
console.log('(pre-terminated) tls connection, addr:', socket.remoteAddress);
console.log('(post-terminated) tls connection, addr:', extractSocketProp(socket, 'remoteAddress'));
netHandler(socket, {
servername: socket.servername
@ -194,6 +194,9 @@ module.exports.create = function (deps, config, netHandler) {
, remoteFamily: extractSocketProp(socket, 'remoteFamily')
});
});
terminateServer.on('error', function (err) {
console.log('[error] TLS termination server', err);
});
function proxy(socket, opts, mod) {
var newConnOpts = require('../domain-utils').separatePort(mod.address || '');