tcp-clone

Crates.iotcp-clone
lib.rstcp-clone
version0.99.4
sourcesrc
created_at2019-11-23 09:58:47.457358
updated_at2019-11-24 00:51:33.604821
descriptionTCP proxy server with ability to send client up- and/or downstream to observer(s).
homepage
repositoryhttps://github.com/benceszigeti/tcp-clone/
max_upload_size
id183689
size53,855
Bence Szigeti (benceszigeti)

documentation

README

tcp-clone

TCP proxy server with ability to send client up- and/or downstream to observer(s).

Build status crates.io version Latest release docs.rs docs License

Architecture

                               Simple proxy               ...with client up- and/or downstream observer(s):
                                                                                                           
##########################################################################                                 
#                                                                        #                                 
#                                (Proxy)                     Target      #                 Observer 0..N   
#    TCP client                `tcp-clone`                (TCP server)   #                (TCP server(s))  
#  +------------+            +-------------+             +------------+  #              +--------------+   
#  |            |            |             |             |            |  #              |              |--+
#  |    connect |----------->| accept      |             |            |  #              |              |  |
#  |         #1 |            |     connect |------------>| accept     |  #              |              |  |
#  |            |            |             |\------------------------------------------>| accept       |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |    connect |----------->| accept      |             |            |  #              |              |  |
#  |         #2 |            |     connect |------x----->|            |  #              |              |  |
#  | disconnect |<----x------| disconnect  |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             | full proxy  |            |  #              |              |  |
#  |            |            |             | (TX and RX) |            |  #              |              |  |
#  |      TX/RX |<---------->| TX/RX TX/RX |<----------->| TX/RX      |  #              |              |  |
#  |            |            |             |\ half proxy |            |  #              |              |  |
#  |            |            |             | \(TX or RX) |            |  #              |              |  |
#  |            |            |             |  \---------------------------------------->| RX           |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |     dropped |<-------------------------------------------| TX           |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  | disconnect |-----x----->| disconnect  |             |            |  #              |              |  |
#  |         #1 |            |  disconnect |------x----->|            |  #              |              |  |
#  |            |            |             |\            |            |  #              |              |  |
#  |            |            |             | -------------------x---------------------->| disconnect   |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |  disconnect |<-----x------| disconnect |  #              |              |  |
#  | disconnect |<----x------| disconnect  |             | #2         |  #              |              |  |
#  |            |            |  disconnect |--------------------x---------------------->| disconnect   |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |             |             |            |  #              |              |  |
#  |            |            |  disconnect |<-------------------x-----------------------| disconnect   |  |
#  |            |            |             |             |            |  #              | #3           |  |
#  +------------+            +-------------+             +------------+  #              +--------------+  |
##########################################################################               +----------------+

Installation

From source

With cargo installed run:

$ cargo install tcp-clone

Pre-builds

Download a released version.

Usage

$ tcp-clone --help

Configuration file

Example

[[tcp_clone]]

  [tcp_clone.server]
  listen_addr = "127.0.0.1:1202"

  [tcp_clone.target]
  addr = "127.0.0.1:5000"

  [[tcp_clone.client_tx_observer]]
  addr = "127.0.0.1:6000"

  [[tcp_clone.client_tx_observer]]
  addr = "127.0.0.1:7000"

  [[tcp_clone.client_rx_observer]]
  addr = "127.0.0.1:8000"

# Multiple servers:
#
#[[tcp_clone]]
#
#  [tcp_clone.server]
#  listen_addr = "127.0.0.1:1111"
#
#  [tcp_clone.target]
#  addr = "127.0.0.1:3333"
#
#  [[tcp_clone.client_tx_observer]]
#  addr = "127.0.0.1:5555"

Demo

With iperf

$ tcp-clone --config tcp-clone.toml      # `tcp-clone` server
$ iperf -s -p 5000 -b 800Mbits/sec       # Target server
$ iperf -s -p 6000 -b 1Gbytes/sec        # Observer #1
$ iperf -s -p 7000 -b 500Mbits/sec       # Observer #2
$ iperf -c 127.0.0.1 -p 1202 -n 250Mbytes -P 4

With netcat

$ tcp-clone --config tcp-clone.toml
$ nc -l -p 5000
$ nc -l -p 6000
$ nc -l -p 7000
$ nc -l -p 8000
$ nc 127.0.0.1 1202
$ # ...and now type into the netcat instances...

License

This project is licensed under the MIT license.
Copyright © 2019 Bence SZIGETI <bence.szigeti@gohyda.com>
Commit count: 0

cargo fmt