mirror of
https://github.com/denoland/deno.git
synced 2024-12-29 10:39:10 -05:00
c3a205bae8
Corrections made: * cli/js/tests/README.md:44:7: corrected "discoveres" to "discovers" * cli/js/tests/chown_test.ts:111:37: corrected "priviledge" to "privilege" * cli/worker.rs:231:56: corrected "decendants" to "descendants" * deno_typescript/lib.rs:136:50: corrected "emmited" to "emitted" * core/es_isolate.rs:492:67: corrected "registerd" to "registered" * core/isolate.rs:103:28: corrected "initalize" to "initialize" * docs/runtime.md:29:14: corrected "ect" to "etc" * docs/tools/debugger.md:122:16: corrected "implementes" to "implements" * std/encoding/_yaml/dumper/dumper_state.ts:57:63: corrected "everwhere" to "everywhere" * std/encoding/csv.ts:37:43: corrected "referal" to "referral" * std/fmt/sprintf.ts:209:20: corrected "unusuable" to "unusable" * std/fmt/README.md:21:40: corrected "Alternativly" to "Alternatively" * std/fmt/README.md:35:68: corrected "seperated" to "separated" * std/fmt/README.md:179:59: corrected "provded" to "provided" * std/mime/multipart.ts:581:46: corrected "writen" to "written" * std/path/_globrex.ts:19:52: corrected "equivelant" to "equivalent" * std/node/events_test.ts:447:9: corrected "asyncronous" to "asynchronous" * std/node/events_test.ts:475:9: corrected "asyncronous" to "asynchronous" * std/node/events_test.ts:500:29: corrected "asyncronous" to "asynchronous" * std/node/events_test.ts:530:40: corrected "asyncronous" to "asynchronous" * std/node/events_test.ts:555:9: corrected "asyncronous" to "asynchronous" * tools/deno_tcp_proxy.ts:1:42: corrected "perfromance" to "performance" * std/node/module.ts:1003:18: corrected "existend" to "existed"
30 lines
874 B
TypeScript
30 lines
874 B
TypeScript
// Used for benchmarking Deno's tcp proxy performance. See tools/http_benchmark.py
|
|
const addr = Deno.args[0] || "127.0.0.1:4500";
|
|
const originAddr = Deno.args[1] || "127.0.0.1:4501";
|
|
|
|
const [hostname, port] = addr.split(":");
|
|
const [originHostname, originPort] = originAddr.split(":");
|
|
|
|
const listener = Deno.listen({ hostname, port: Number(port) });
|
|
|
|
async function handle(conn: Deno.Conn): Promise<void> {
|
|
const origin = await Deno.connect({
|
|
hostname: originHostname,
|
|
port: Number(originPort),
|
|
});
|
|
try {
|
|
await Promise.all([Deno.copy(conn, origin), Deno.copy(origin, conn)]);
|
|
} catch (err) {
|
|
if (err.message !== "read error" && err.message !== "write error") {
|
|
throw err;
|
|
}
|
|
} finally {
|
|
conn.close();
|
|
origin.close();
|
|
}
|
|
}
|
|
|
|
console.log(`Proxy listening on http://${addr}/`);
|
|
for await (const conn of listener) {
|
|
handle(conn);
|
|
}
|