From 47411fc5e2d548ebae2071ddd8606e9b1b92e8fd Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 27 Aug 2016 12:38:33 -0700 Subject: [PATCH] proxysocket: minor. fix disconnect handling. --- lib/net/proxysocket.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/net/proxysocket.js b/lib/net/proxysocket.js index a4ea4e69..6ee3e7a7 100644 --- a/lib/net/proxysocket.js +++ b/lib/net/proxysocket.js @@ -56,8 +56,9 @@ ProxySocket.prototype._init = function _init() { }); this.socket.on('tcp data', function(data) { - self.bytesRead += data.length / 2; - self.emit('data', new Buffer(data, 'hex')); + data = new Buffer(data, 'hex'); + self.bytesRead += data.length; + self.emit('data', data); }); this.socket.on('tcp close', function(data) { @@ -73,7 +74,7 @@ ProxySocket.prototype._init = function _init() { self.emit('error', err); }); - this.socket.on('close', function() { + this.socket.on('disconnect', function() { if (self.closed) return; self.closed = true;