summaryrefslogtreecommitdiff
path: root/cli/bench/node_tcp_proxy.js
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2022-06-08 17:33:38 +0530
committerGitHub <noreply@github.com>2022-06-08 17:33:38 +0530
commit4305bb4bd8ec3747031ee92baa8e55d50d22b47c (patch)
tree0bd15f3e8082c7865f246696ec8ce644172ab129 /cli/bench/node_tcp_proxy.js
parent8113fac939c06b0d71a22d008c060bed3cb47d72 (diff)
chore(bench): generalized HTTP benchmarks framework (#14815)
Diffstat (limited to 'cli/bench/node_tcp_proxy.js')
-rw-r--r--cli/bench/node_tcp_proxy.js69
1 files changed, 0 insertions, 69 deletions
diff --git a/cli/bench/node_tcp_proxy.js b/cli/bench/node_tcp_proxy.js
deleted file mode 100644
index 8b4b958d7..000000000
--- a/cli/bench/node_tcp_proxy.js
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
-const net = require("net");
-
-process.on("uncaughtException", function (error) {
- console.error(error);
-});
-
-if (process.argv.length != 4) {
- console.log("usage: %s <localport> <remoteport>", process.argv[1]);
- process.exit();
-}
-
-const localport = process.argv[2];
-const remoteport = process.argv[3];
-
-const remotehost = "127.0.0.1";
-
-const server = net.createServer(function (localsocket) {
- const remotesocket = new net.Socket();
-
- remotesocket.connect(remoteport, remotehost);
-
- localsocket.on("data", function (data) {
- const flushed = remotesocket.write(data);
- if (!flushed) {
- localsocket.pause();
- }
- });
-
- remotesocket.on("data", function (data) {
- const flushed = localsocket.write(data);
- if (!flushed) {
- remotesocket.pause();
- }
- });
-
- localsocket.on("drain", function () {
- remotesocket.resume();
- });
-
- remotesocket.on("drain", function () {
- localsocket.resume();
- });
-
- localsocket.on("close", function () {
- remotesocket.end();
- });
-
- remotesocket.on("close", function () {
- localsocket.end();
- });
-
- localsocket.on("error", function () {
- localsocket.end();
- });
-
- remotesocket.on("error", function () {
- remotesocket.end();
- });
-});
-
-server.listen(localport);
-
-console.log(
- "redirecting connections from 127.0.0.1:%d to %s:%d",
- localport,
- remotehost,
- remoteport,
-);