tcpipe
v1.0.0
Published
TCP from the browser. WebSocket relay and protocol clients.
Maintainers
Readme
tcpipe
Browsers can't open TCP sockets.
A WebSocket connects to a relay server. A TCP connection comes out the other side. Bytes flow both ways. The server doesn't care what protocol you're speaking.
There are clients for Redis, Postgres, MySQL, MongoDB, SSH, SMTP, POP3, DNS, and raw telnet. They cover the common operations and skip the rest. Each one is a single file that works in Node and in a <script> tag.
The SSH client does key exchange, encryption, and channels from scratch in 1,400 lines of WebCrypto. It will not replace OpenSSH. It will let you run uname -a from a web page.
Run it
npm startProxy listens on :3100. Point a WebSocket at ws://localhost:3100/targethost:port and you're through.
Use it
import { SSHClient } from "./clients/ssh.js";
const ssh = new SSHClient("ws://localhost:3100");
await ssh.connect(22, "myserver.com", { username: "root", password: "hunter2" });
const { stdout } = await ssh.exec("uname -a");
ssh.disconnect();import { RedisClient } from "./clients/redis.js";
const redis = new RedisClient("ws://localhost:3100");
await redis.connect(6379, "localhost");
await redis.set("k", "v");
await redis.get("k"); // "v"
await redis.quit();Clients
telnet · redis · smtp · pop3 · mysql · postgres · dns · mongodb · ssh
All in clients/. Shared transport is lib/proxy-socket.js.
Test it
docker compose up -d
npm testSpins up the databases, the mail server, the SSH server. Runs the same suite in Node and headless Chromium.
