mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
31f32ed8c4
All benchmarks are done in Rust and can be invoked with `cargo bench`. Currently this has it's own "harness" that behaves like `./tools/benchmark.py` did. Because of this tests inside `cli/bench` are currently not run. This should be switched to the language provided harness once the `#[bench]` attribute has been stabilized.
68 lines
1.3 KiB
JavaScript
68 lines
1.3 KiB
JavaScript
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,
|
|
);
|