Skip to content

Instantly share code, notes, and snippets.

@mdz
Created February 10, 2012 20:01
Show Gist options
  • Save mdz/1792301 to your computer and use it in GitHub Desktop.
Save mdz/1792301 to your computer and use it in GitHub Desktop.
diff --git a/slya-proxy.js b/slya-proxy.js
index 57d5c39..0df2ca0 100644
--- a/slya-proxy.js
+++ b/slya-proxy.js
@@ -109,6 +109,9 @@ function setupIptables(portMap) {
function TCPProxy(port, destPort, destHost) {
return net.createServer(function (inbound) {
+ // suppress data events until we're ready
+ inbound.pause();
+
var outbound = net.createConnection(destPort, destHost);
outbound.on('connect', function() {
// Pass all data back and forth
@@ -127,6 +130,9 @@ function TCPProxy(port, destPort, destHost) {
inbound.end();
cleanup();
});
+
+ // ok, all ready to pass data
+ inbound.resume();
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment