Skip to content

Commit a084863

Browse files
committed
Add usage instructions with Docker
1 parent 97d220d commit a084863

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

README.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
21
# tcp-multiplexer
32

4-
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.
3+
Use it in front of a target server and let your client programs connect it, if target server **only allows you to create
4+
a limited TCP connections concurrently**. While it has its limitation: increased latency as incoming request will block
5+
each other.
56

6-
## arch
7+
## Architecture
78

89
```
910
┌──────────┐
@@ -14,15 +15,15 @@ Use it in front of target server and let your client programs connect it, if tar
1415
└───────────┘ └─────────────────┘ └───────────────┘
1516
1617
17-
─────► tcp connection
18+
─────► TCP connection
1819
1920
drawn by https://asciiflow.com/
2021
```
2122

22-
Unlike reverse proxy, tcp connection between tcp-multiplexer and target server will be reused for all clients' tcp connections.
23-
23+
Unlike with a reverse proxy, the TCP connection between `tcp-multiplexer` and the target server will be reused for all
24+
clients' TCP connections.
2425

25-
Multiplexer is simple. For every tcp connection from clients, the handling logic:
26+
Multiplexer is simple. For every TCP connection from clients, the handling logic:
2627

2728
```
2829
for {
@@ -36,31 +37,35 @@ release lock...
3637
}
3738
```
3839

39-
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.
40+
The lock makes sure that at any time, the TCP connection to the target server will be used in exactly one
41+
request-response loop.
42+
This way, all connections from clients share one TCP connection to the target server.
4043

41-
Next key point is how to detect message (e.g., HTTP Message format) from tcp data stream.
44+
Next key point is how to detect message (e.g., HTTP) from the TCP data stream.
4245

43-
## supported application protocol
46+
## Supported application protocols
4447

45-
Every application protocol (request–response message exchange pattern) has it's own message format. For now, support:
48+
Every application protocol (request–response message exchange pattern) has its own message format. For now, support:
4649

4750
1. echo: \n terminated
4851
2. http1 (not include https, websocket): not fully supported
4952
3. iso8583: with 2 bytes header of the length of iso8583 message
53+
4. modbus-tcp
5054

5155
```
5256
$ ./tcp-multiplexer list
5357
* iso8583
5458
* echo
5559
* http
60+
* modbus
5661
5762
usage for example: ./tcp-multiplexer server -p echo
5863
5964
```
6065

61-
See detailed: https://github.com/XUJiahua/tcp-multiplexer/tree/master/example
66+
See detailed: https://github.com/ingmarstein/tcp-multiplexer/tree/master/example
6267

63-
## usage
68+
## Usage
6469

6570
```
6671
$ ./tcp-multiplexer server -h
@@ -79,16 +84,22 @@ Global Flags:
7984
-v, --verbose verbose log
8085
```
8186

82-
### multiplexing echo server
87+
#### In a container
88+
```
89+
docker run ghcr.io/ingmarstein/tcp-multiplexer server -t 127.0.0.1:1234 -l 8000 -p modbus
90+
```
91+
Alternatively, use the included `compose.yml` file as a template if you prefer to use Docker Compose.
92+
93+
### Multiplexing echo server
8394

84-
start echo server (listen on port 1234)
95+
Start echo server (listen on port 1234)
8596

8697
```
8798
$ go run example/echo-server/main.go
8899
1: 127.0.0.1:1234 <-> 127.0.0.1:58088
89100
```
90101

91-
start tcp multiplexing (listen on port 8000)
102+
Start TCP multiplexing (listen on port 8000)
92103

93104
```
94105
$ ./tcp-multiplexer server -p echo -t 127.0.0.1:1234 -l 8000
@@ -110,7 +121,3 @@ $ nc 127.0.0.1 8000
110121
mmm
111122
mmm
112123
```
113-
114-
115-
116-

compose.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
modbus-proxy:
3+
image: ghcr.io/ingmarstein/tcp-multiplexer
4+
container_name: modbus_proxy
5+
ports:
6+
- "5020:5020"
7+
command: [ "server", "-t", "192.168.1.22:1502", "-l", "5020", "-p", "modbus", "-v" ]
8+
restart: unless-stopped

0 commit comments

Comments
 (0)