Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions proxywrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down