Skip to content

dev-swarup/multiplex-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 authHandler and connectionHandler chains for complex logic.

Installation

npm install multiplex-proxy

Quick 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();
});

About

A lightweight, high-performance Node.js proxy solution that multiplexes HTTP and SOCKS5 protocols onto a single port.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors