forked from coolaj86/goldilocks.js
improved error handling for TLS/TCP proxying
This commit is contained in:
parent
158c363c88
commit
e24f9412dd
|
@ -94,6 +94,17 @@ module.exports.create = function (deps, config) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Not sure how to effectively report this to the user or client, but we need to listen
|
||||||
|
// for the event to prevent it from crashing us.
|
||||||
|
newConn.on('error', function (err) {
|
||||||
|
console.error('TCP forward connection error', err);
|
||||||
|
conn.end();
|
||||||
|
});
|
||||||
|
conn.on('error', function (err) {
|
||||||
|
console.error('TCP forward client error', err);
|
||||||
|
newConn.end();
|
||||||
|
});
|
||||||
|
|
||||||
newConn.pipe(conn);
|
newConn.pipe(conn);
|
||||||
conn.pipe(newConn);
|
conn.pipe(newConn);
|
||||||
};
|
};
|
||||||
|
|
|
@ -147,6 +147,17 @@ module.exports.create = function (deps, config, netHandler) {
|
||||||
, remotePort: opts.port || extractSocketProp(socket, 'remotePort')
|
, remotePort: opts.port || extractSocketProp(socket, 'remotePort')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Not sure how to effectively report this to the user or client, but we need to listen
|
||||||
|
// for the event to prevent it from crashing us.
|
||||||
|
newConn.on('error', function (err) {
|
||||||
|
console.error('TLS proxy connection error', err);
|
||||||
|
socket.end();
|
||||||
|
});
|
||||||
|
socket.on('error', function (err) {
|
||||||
|
console.error('TLS proxy client error', err);
|
||||||
|
newConn.end();
|
||||||
|
});
|
||||||
|
|
||||||
newConn.write(opts.firstChunk);
|
newConn.write(opts.firstChunk);
|
||||||
newConn.pipe(socket);
|
newConn.pipe(socket);
|
||||||
socket.pipe(newConn);
|
socket.pipe(newConn);
|
||||||
|
|
Loading…
Reference in New Issue