|
| 1 | +# TCP-Relay |
| 2 | +[](LICENSE) |
| 3 | + |
| 4 | +A high-performance and easy-to-use TCP-Relay write in C++20 based on [AISO](https://think-async.com/Asio/) and [Coroutines](https://en.cppreference.com/w/cpp/language/coroutines). In addition to basic TCP relay, it also supports relaying through intermediate proxies (such as HTTP-Proxy). |
| 5 | + |
| 6 | +# Getting Started |
| 7 | +## Build from source |
| 8 | +This project relies on some C++20 features. The following compilers and their respective versions are supported: |
| 9 | +- GCC >= 12.0 |
| 10 | +- Clang >= 14.0 |
| 11 | +- Microsoft Visual Studio (MSVC) >= 2019 |
| 12 | + |
| 13 | +``` bash |
| 14 | +# clone |
| 15 | +git clone --recursive https://github.com/lxrite/tcp-relay.git |
| 16 | +cd tcp-relay |
| 17 | + |
| 18 | +# build |
| 19 | +cmake -B build -DCMAKE_BUILD_TYPE=Release |
| 20 | +cmake --build build |
| 21 | +``` |
| 22 | + |
| 23 | +## Usage |
| 24 | +``` bash |
| 25 | +$ ./tcp-relay --help |
| 26 | +Usage: tcp-relay [options] |
| 27 | + |
| 28 | +options: |
| 29 | + -h, --help Show this help message and exit |
| 30 | + -v, --version Print the program version and exit |
| 31 | + -l, --listen_addr string Local address to listen on (default: 0.0.0.0) |
| 32 | + -p, --port number Local port to listen on (default: 8886) |
| 33 | + -t, --target string Taget address (host:port) to connect |
| 34 | + --timeout number Connection timeout (in seconds) (default: 240) |
| 35 | + --via [none | http_proxy] Transfer via other proxy (default: none) |
| 36 | + --http_proxy string HTTP-Proxy address (host:port) |
| 37 | + --log_level string [trace | debug | info | warn | error | disable] Log level (default: info) |
| 38 | +``` |
| 39 | + |
| 40 | +## Examples |
| 41 | +``` bash |
| 42 | +# basic |
| 43 | +./tcp-relay -t 172.16.1.1:8080 |
| 44 | + |
| 45 | +# IPv6 |
| 46 | +./tcp-relay -t [fd12:3456:789a:bcde::1]:8080 |
| 47 | + |
| 48 | +# domain |
| 49 | +./tcp-relay -t example.com:8080 |
| 50 | + |
| 51 | +# relay through HTTP intermediate proxy |
| 52 | +./tcp-relay -t example.com:8080 --via http_proxy --http_proxy proxy.example.com:1234 |
| 53 | +``` |
| 54 | + |
| 55 | +## Using Docker |
| 56 | +``` bash |
| 57 | +# build from local Dockerfile |
| 58 | +docker build -t lxrite/tcp-relay . |
| 59 | +# build from URL |
| 60 | +docker build -t lxrite/tcp-relay https://github.com/lxrite/tcp-relay.git |
| 61 | + |
| 62 | +# run |
| 63 | +docker run -d -p 8886:8886 lxrite/tcp-relay tcp-relay -t 172.16.1.1:8080 |
| 64 | +``` |
0 commit comments