All Projects → robertklep → node-port-mux

robertklep / node-port-mux

Licence: other
TCP port multiplexer: run multiple services through the same port

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to node-port-mux

ebook
Third edition of the Computer Networking: Principles, Protocols and Practice ebook
Stars: ✭ 64 (+433.33%)
Mutual labels:  tcp
cs
开箱即用的基于命令的消息处理框架,让 websocket 和 tcp 开发就像 http 那样简单
Stars: ✭ 19 (+58.33%)
Mutual labels:  tcp
ddos
Simple dos attack utility
Stars: ✭ 36 (+200%)
Mutual labels:  tcp
opengnb
GNB is open source de-centralized VPN to achieve layer3 network via p2p with the ultimate capability of NAT Traversal.GNB是一个开源的去中心化的具有极致内网穿透能力的通过P2P进行三层网络交换的VPN。
Stars: ✭ 440 (+3566.67%)
Mutual labels:  tcp
PsNetTools
PsNetTools is a cross platform PowerShell module to test network features on Windows, Linux and Mac.
Stars: ✭ 13 (+8.33%)
Mutual labels:  tcp
Layr
A decentralized (p2p) file storage system built atop Kademlia DHT that enforces data integrity, privacy, and availability through sharding, proofs of retrievability, redundancy, and encryption, with smart-contract powered incentive scheme
Stars: ✭ 90 (+650%)
Mutual labels:  tcp
sol
Lightweight MQTT broker, written from scratch. IO is handled by a super simple event loop based upon the most common IO multiplexing implementations.
Stars: ✭ 72 (+500%)
Mutual labels:  tcp
node-jsonrpc2
JSON-RPC 2.0 server and client library, with HTTP (with Websocket support) and TCP endpoints
Stars: ✭ 103 (+758.33%)
Mutual labels:  tcp
ustcp
Pure Rust TCP stack in user-space running on TUN/TAP
Stars: ✭ 31 (+158.33%)
Mutual labels:  tcp
terabit-network-stack-profiling
Tools for profiling the Linux network stack.
Stars: ✭ 68 (+466.67%)
Mutual labels:  tcp
ParallelCollectionMonitoring
使用数十个.NET客户端控制硬件设备进行工作,采集数据并进行处理,管理人员通过 Android 应用实时控制各设备的工作。本作品获得第十二届中国研究生电子设计竞赛华南赛区一等奖。
Stars: ✭ 21 (+75%)
Mutual labels:  tcp
monte
The bare minimum for high performance, fully-encrypted bidirectional RPC over TCP in Go with zero memory allocations.
Stars: ✭ 103 (+758.33%)
Mutual labels:  tcp
Python-Botnet
This is a simple DDoS python botnet script with remote monitoring & management for education purposes.
Stars: ✭ 119 (+891.67%)
Mutual labels:  tcp
natcross2
内网穿透工具
Stars: ✭ 111 (+825%)
Mutual labels:  tcp
riemannx
A riemann client for elixir (TCP/UDP/TLS supported)
Stars: ✭ 23 (+91.67%)
Mutual labels:  tcp
Tiginx
Tiginx is a Shanzhai Nginx project , please buyao use it xian , if meet problem , I no fuze ...
Stars: ✭ 29 (+141.67%)
Mutual labels:  tcp
messenger
TCP 即时通讯 WPF 界面.
Stars: ✭ 18 (+50%)
Mutual labels:  tcp
escper
Ruby gem for printing of images and text on one or many thermal printers
Stars: ✭ 67 (+458.33%)
Mutual labels:  tcp
fire-im
分布式IM服务,参考https://github.com/crossoverJie/cim 实现
Stars: ✭ 17 (+41.67%)
Mutual labels:  tcp
black-hat-python3-code
🏴‍☠️ tools (py3 version) of Black Hat Python book 🏴‍☠️
Stars: ✭ 51 (+325%)
Mutual labels:  tcp

node-port-mux

Multiplex multiple services through one (TCP) port.

How?

The muxer basically sniffs the initial data packet sent by the client to determine (using a rule set) where to forward the request to.

Why?

Instead of having to expose all your services to the outside world on their respective ports, use a single port to access them all. Initially created to multiplex HTTP, HTTPS and SOCKS5 traffic over one port for a personal project.

Install

From the NPM repository:

$ npm install port-mux

From the Github repository:

$ git clone https://github.com/robertklep/node-port-mux.git
$ cd node-port-mux
$ npm install [-g]

Example

var Muxer = require('port-mux');

// instantiate Muxer
Muxer()
  // match HTTP GET requests (using a prefix string match) and forward them to localhost:80
  .addRule('GET ', 80)

  // match TLS (HTTPS) requests (versions 3.{0,1,2,3}) using a regular expression
  .addRule(/^\x16\x03[\x00-\x03]/, '192.168.1.1:443') // regex match

  // you can forward to UNIX domain sockets (which should already exist when you call .addRule()):
  .addRule(..., '/tmp/my-unix-domain-socket')

  // you can also provide a function to perform the matching:
  .addRule(function(chunk) {
    // - chunk is a Buffer containing the first incoming data
    // - if the function returns true, the match is considered a success.
  }, ...)

  // pass a function as a third argument and it will get called (once the proxy
  // has connected to the service) using the proxy connection and original
  // (incoming) connection as arguments:
  .addRule(..., ..., function(proxy, conn) {
    var addr = proxy.address();
    console.log('Incoming connection from %s passed to %s:%s',
      conn.remoteAddress,
      addr.address,
      addr.port
    );
  })

  // start listening on port 3000
  .listen(3000);

Performance impact

There's going to be a performance impact when using this module, since it's proxying connections to the endpoint.

Using httperf, these are the results I get on a Macbook Pro (using the modified version of the example.js script in the repository):

Type of connection Reqs/s I/O speed Remarks
Direct 9991 1863 KB/s access HTTP server directly (not muxed)
Muxed (TCP) 4881 910 KB/s HTTP server uses TCP sockets
Muxed (UNIX) 5629 1050 KB/s HTTP server uses UNIX domain sockets

So performance impact is about 50%, a bit less when you use UNIX domain sockets.

LICENSE

Simplified BSD License ( BSD-2-Clause ).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].