multiplex-proxy
v1.0.1
Published
A lightweight, high-performance Node.js proxy solution that multiplexes HTTP and SOCKS5 protocols onto a single port.
Maintainers
Readme
Multiplex Proxy
A Commercial-Grade, High-Performance Node.js proxy solution that multiplexes HTTP and SOCKS5 protocols onto a single TCP port.
Features
- Protocol Multiplexing: Automatically detects and routes SOCKS5 and HTTP/HTTPS traffic on the same port.
- Middleware Architecture: Sequential
authHandlerandconnectionHandlerchains for complex logic.
Installation
npm install multiplex-proxyQuick Start
import { ProxyServer } from "multiplex-proxy";
const Server = new ProxyServer();
Server.listen(8080, () => {
console.log("Multiplex Proxy running on port 8080");
});Documentation
Authentication Middleware (authHandler)
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;
});Connection Middleware (connectionHandler)
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();
});