Skip to content

Commit c026e6a

Browse files
authored
Use template interpolation to stringify keys (#26)
`toString()` always evaluates to `"[object Undefined]"`, so the current approach ends up storing all connections under the same key, leaking the ones that are overwritten. This converts to using template interpolation instead.
1 parent 6e897db commit c026e6a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tcp-proxy.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ TcpProxy.prototype.handleAuth = function(proxySocket) {
131131
TcpProxy.prototype.handleClient = function(proxySocket) {
132132
var self = this;
133133
var key = uniqueKey(proxySocket);
134-
self.proxySockets[toString(key)] = proxySocket;
134+
self.proxySockets[`${key}`] = proxySocket;
135135
var context = {
136136
buffers: [],
137137
connected: false,
@@ -225,7 +225,7 @@ TcpProxy.prototype.writeBuffer = function(context) {
225225
TcpProxy.prototype.end = function() {
226226
this.server.close();
227227
for (var key in this.proxySockets) {
228-
this.proxySockets[toString(key)].destroy();
228+
this.proxySockets[`${key}`].destroy();
229229
}
230230
this.server.unref();
231231
};

0 commit comments

Comments
 (0)