tweaked proxy behavior on error/close
This commit is contained in:
parent
aa28a72f3f
commit
5bbf57a57a
|
@ -45,13 +45,16 @@ module.exports.create = function (deps, config) {
|
||||||
conn.pipe(newConn);
|
conn.pipe(newConn);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Listening for this largely to prevent uncaught exceptions.
|
||||||
|
conn.on('error', function (err) {
|
||||||
|
console.log('proxy client error', err);
|
||||||
|
});
|
||||||
newConn.on('error', function (err) {
|
newConn.on('error', function (err) {
|
||||||
if (connected) {
|
if (connected) {
|
||||||
// Not sure how to report this to a user or a client. We can assume that some data
|
// Not sure how to report this to a user or a client. We can assume that some data
|
||||||
// has already been exchanged, so we can't really be sure what we can send in addition
|
// has already been exchanged, so we can't really be sure what we can send in addition
|
||||||
// that wouldn't result in a parse error.
|
// that wouldn't result in a parse error.
|
||||||
console.log('proxy remote error', err);
|
console.log('proxy remote error', err);
|
||||||
conn.end();
|
|
||||||
} else {
|
} else {
|
||||||
console.log('proxy connection error', err);
|
console.log('proxy connection error', err);
|
||||||
if (decrypt) {
|
if (decrypt) {
|
||||||
|
@ -62,10 +65,12 @@ module.exports.create = function (deps, config) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Listening for this largely to prevent uncaught exceptions.
|
// Make sure that once one side closes, no I/O activity will happen on the other side.
|
||||||
conn.on('error', function (err) {
|
conn.on('close', function () {
|
||||||
console.log('proxy client error', err);
|
newConn.destroy();
|
||||||
newConn.end();
|
});
|
||||||
|
newConn.on('close', function () {
|
||||||
|
conn.destroy();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue