Multiplexer over TCP. Useful if target server only allows you to create limited tcp connections concurrently.

tcp-multiplexer

Use it in front of target server and let your client programs connect it, if target server only allows you to create limited tcp connections concurrently. While it has its limitation: increased latency as incoming request will block each other. Suitable for testing purpose.

arch

┌──────────┐
│ ┌────────┴──┐      ┌─────────────────┐      ┌───────────────┐
│ │           ├─────►│                 │      │               │
│ │ client(s) │      │ tcp-multiplexer ├─────►│ target server │
└─┤           ├─────►│                 │      │               │
  └───────────┘      └─────────────────┘      └───────────────┘


─────► tcp connection

drawn by https://asciiflow.com/

Unlike reverse proxy, tcp connection between tcp-multiplexer and target server will be reused for all clients' tcp connections.

Multiplexer is simple. For every tcp connection from clients, the handling logic:

for {
get lock...
data pipe:
	1. get request message from client
	2. forward request message to target server
	3. get response message from target server
	4. forward response message to client
release lock...
}

lock make sure that at the same time, tcp connection to target server will be used in exactly one request-response loop. That's key point for every connection from clients share one tcp connection to target server.

Next key point is how to detect message (e.g., HTTP Message format) from tcp data stream.

supported application protocol

Every application protocol (request–response message exchange pattern) has it's own message format. For now, support:

  1. echo: \n terminated
  2. http1 (not include https, websocket): not fully supported
  3. iso8583: with 2 bytes header of the length of iso8583 message
$ ./tcp-multiplexer list                                    
* iso8583
* echo
* http

usage for example: ./tcp-multiplexer server -p echo

See detailed: https://github.com/XUJiahua/tcp-multiplexer/tree/master/example

usage

$ ./tcp-multiplexer server -h
start multiplexer proxy server

Usage:
  tcp-multiplexer server [flags]

Flags:
  -p, --applicationProtocol string   multiplexer will parse to message echo/http/iso8583 (default "echo")
  -h, --help                         help for server
  -l, --listen string                multiplexer will listen on (default "8000")
  -t, --targetServer string          multiplexer will forward message to (default "127.0.0.1:1234")

Global Flags:
  -v, --verbose   verbose log

multiplexing echo server

start echo server (listen on port 1234)

$ go run example/echo-server/main.go
1: 127.0.0.1:1234 <-> 127.0.0.1:58088

start tcp multiplexing (listen on port 8000)

$ ./tcp-multiplexer server -p echo -t 127.0.0.1:1234 -l 8000
INFO[2021-05-09T02:06:40+08:00] creating target connection
INFO[2021-05-09T02:06:40+08:00] new target connection: 127.0.0.1:58088 <-> 127.0.0.1:1234
INFO[2021-05-09T02:07:57+08:00] #1: 127.0.0.1:58342 <-> 127.0.0.1:8000
INFO[2021-05-09T02:08:16+08:00] closed: 127.0.0.1:58342 <-> 127.0.0.1:8000
INFO[2021-05-09T02:08:19+08:00] #2: 127.0.0.1:58402 <-> 127.0.0.1:8000

client test

$ nc 127.0.0.1 8000
kkk
kkk
^C
$ nc 127.0.0.1 8000
mmm
mmm
Similar Resources

GOWS is GoLang web-socket module Provides you with ease of handling web socket connections with a few lines

GOWS GOWS is GoLang web-socket module Provides you with ease of handling web socket connections with a few lines, it supports multi-connection on one

Apr 4, 2022

HTTP(S)/WS(S)/TCP Tunnels to localhost using only SSH.

An open source serveo/ngrok alternative.

Dec 29, 2022

An n:m message multiplexer written in Go

An n:m message multiplexer written in Go

What is Gollum? Gollum is an n:m multiplexer that gathers messages from different sources and broadcasts them to a set of destinations. Gollum origina

Dec 23, 2022

This plugin allows you to start a local server with hot reloading with Esbuild

esbuild-dev-server This plugin allows you to start a local server with hot reloading with Esbuild Installation npm npm i esbuild-dev-server -D yarn y

Nov 4, 2022

Minekube Connect allows you to connect any Minecraft server

Minekube Connect allows you to connect any Minecraft server, whether online mode, public, behind your protected home network or anywhere else in the world, with our highly available, performant and low latency edge proxies network nearest to you.

Dec 27, 2022

The devs are over here at devzat, chat over SSH!

Devzat Where are the devs at? Devzat! Devzat is chat over SSH Try it out: ssh sshchat.hackclub.com Add this to ~/.ssh/config: Host chat HostName s

Jan 7, 2023

Lightweight rest api that allows users to run Powershell commands over HTTP.

Powershell Proxy Lightweight rest api that allows users to run Powershell commands over HTTP. Requests require a valid JWT and responses are returned

Mar 18, 2022

Chisel is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH.

Chisel is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH.

Chisel is a fast TCP/UDP tunnel, transported over HTTP, secured via SSH. Single executable including both client and server. Written in Go (golang). Chisel is mainly useful for passing through firewalls, though it can also be used to provide a secure endpoint into your network.

Jan 1, 2023

Send network packets over a TCP or UDP connection.

Packet is the main class representing a single network message. It has a byte code indicating the type of the message and a []byte type payload.

Nov 28, 2022
TCP output for beats to send events over TCP socket.

beats-tcp-output How To Use Clone this project to elastic/beats/libbeat/output/ Modify elastic/beats/libbeat/publisher/includes/includes.go : // add i

Aug 25, 2022
Tcp chat go - Create tcp chat in golang

TCP chat in GO libs Go net package and goroutines and channels tcp tcp or transm

Feb 5, 2022
UDP Transport: compress, encrypt and send any data reliably over unreliable UDP connections

udpt UDP Transport Compresses, encrypts and transfers data between a sender and receiver using UDP protocol. Features and Design Aims: Avoid the overh

Nov 5, 2022
Remake of the original sqlifinder but in GOlang, and allows for listed targets, domain crawling, and tor connections
Remake of the original sqlifinder but in GOlang, and allows for listed targets, domain crawling, and tor connections

_______ _____ _____ _______ _____ __ _ ______ _______ ______ |______ | __| | | |______ | | \ | | \ |______ |_____/

Jan 4, 2023
A little library for turning TCP connections into go channels.

netutils By Tim Henderson ([email protected]) This is a little library that was part of a larger project that I decided to pull out and make public.

Aug 13, 2020
a go mini version TCP top on UDP for game connections or others.

sanhua sanhua(三花猫) is kind of cat with black, red and white color. This is a mini version TCP top on UDP, but with out resend lost packet. As we know.

May 31, 2022
Helps you to send ssh commands to target machine in your local network from outside via gRPC
Helps you to send ssh commands to target machine in your local network from outside via gRPC

rpc-ssh In case, you don't want to make your ssh port accessible from outside local network. This repository helps you to send ssh commands to target

Nov 16, 2022
Golang pow implementation client <-> server over UDP and TCP protocols
Golang pow implementation client <-> server over UDP and TCP protocols

Client <-> server over UDP and TCP pow protocol Denial-of-Service-attacks are a typical situation when providing services over a network. A method for

Jan 13, 2022
rconn is a multiplatform program for creating generic reverse connections. Lets you consume services that are behind firewall or NAT without opening ports or port-forwarding.
rconn is a multiplatform program for creating generic reverse connections. Lets you consume services that are behind firewall or NAT without opening ports or port-forwarding.

rconn (r[everse] conn[ection]) is a multiplatform program for creating reverse connections. It lets you consume services that are behind NAT and/or fi

Jan 1, 2023