A Commercial-Grade, High-Performance Node.js proxy solution that multiplexes HTTP and SOCKS5 protocols onto a single TCP port.
- Protocol Multiplexing: Automatically detects and routes SOCKS5 and HTTP/HTTPS traffic on the same port.
- Middleware Architecture: Sequential
authHandlerandconnectionHandlerchains for complex logic.
npm install multiplex-proxyimport { ProxyServer } from "multiplex-proxy";
const Server = new ProxyServer();
Server.listen(8080, () => {
console.log("Multiplex Proxy running on port 8080");
});Server.authHandler(async (options, next) => {
const { ip, username, password } = options;
if (ip === "127.0.0.1") {
// Pass data to the next handler or metrics
return next({ plan: "premium", userId: "admin" });
}
return username === "user" && password === "pass" ? next() : false;
});Server.connectionHandler(async (options, submit, next) => {
const { protocol, destAddress, destPort } = options;
const upstream = net.createConnection({ host: "upstream.com", port: 9000 }, () => {
submit("GRANTED");
options.socket.pipe(upstream).pipe(options.socket);
});
await next();
});