Template
chor(all): bug
This commit is contained in:
1 parent
8233c591c3
commit
db19393985
12 files changed
+613
-64
No files matched your search
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env node
|
||||
/* Tiny TCP forwarder: listens on 127.0.0.1:8765 and pipes to 127.0.0.1:8555.
|
||||
Exists only because the preview browser cannot attach to Docker's
|
||||
published port process. Ctrl+C to stop. */
|
||||
const net = require("net");
|
||||
|
||||
const LISTEN = 8765;
|
||||
const TARGET_PORT = 8555;
|
||||
const TARGET_HOST = "127.0.0.1";
|
||||
|
||||
const server = net.createServer((client) => {
|
||||
const upstream = net.connect(TARGET_PORT, TARGET_HOST);
|
||||
client.pipe(upstream);
|
||||
upstream.pipe(client);
|
||||
const cleanup = () => {
|
||||
client.destroy();
|
||||
upstream.destroy();
|
||||
};
|
||||
client.on("error", cleanup);
|
||||
upstream.on("error", cleanup);
|
||||
});
|
||||
|
||||
server.listen(LISTEN, "127.0.0.1", () => {
|
||||
console.log(`forwarding 127.0.0.1:${LISTEN} -> ${TARGET_HOST}:${TARGET_PORT}`);
|
||||
});
|
||||
Reference in new issue
Block a user