From a450190c5d73d031323df99b077c80a3f58da805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Moreira?= Date: Wed, 3 Sep 2014 15:15:06 +0100 Subject: [PATCH] Implementation of: proxyAddress and proxyPort closes #1 --- proxywrap.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/proxywrap.js b/proxywrap.js index 6c2ee99..1002604 100644 --- a/proxywrap.js +++ b/proxywrap.js @@ -136,6 +136,8 @@ exports.proxy = function(iface, options) { header = header.split(' '); if (!protocolError) { + + // Source properties of TCP connection Object.defineProperty(socket, 'remoteAddress', { enumerable: false, configurable: true, @@ -150,6 +152,22 @@ exports.proxy = function(iface, options) { return parseInt(header[4], 10); } }); + + // Destination properties of TCP connection + Object.defineProperty(socket, 'proxyAddress', { + enumerable: false, + configurable: true, + get: function() { + return header[3]; + } + }); + Object.defineProperty(socket, 'proxyPort', { + enumerable: false, + configurable: true, + get: function() { + return parseInt(header[5], 10); + } + }); } // unshifting will fire the readable event