C++ TCP Proxy Server

 www.partow.net  .: Home :.   .: Links :.   .: Search :.   .: Contact :. 


Description

The C++ TCP Proxy server is a simple and high performance utility using the ASIO networking library, for proxying (tunneling or redirecting) connections from external clients to a designated server. The TCP Proxy server can be used to easily and efficiently:

  • Limit the number of client connections to the server
  • Load balance client connections between multiple server instances
  • Provide IP or connection time based filtering and access control mechanisms

Usage: ./tcpproxy_server <proxy machine ip> <proxy machine port> <server ip> <server port>


TCP Proxy Server Diagram - Copyright Arash Partow


Example Use-Case (Simple Proxy Server)

A simple scenario is as follows: There exists a server at 192.168.0.100 that accepts connections on port 20000, however due to firewall rules external clients can only access a host at 192.168.20.200 on port 8080 (eth0), which coincidentally has access to the 192.168.0 network segment via a second NIC (eth1). A solution for allowing the external clients access to the server is to run the TCP proxy server on the host at 192.168.0.200 with the following configuration:

tcpproxy_server 192.168.20.200 8080 192.168.0.100 20000

The above command when run upon the proxy machine at 192.168.20.200, will bind to port 8080 on eth0 in order to accept connections from external clients - which presumbly will originate from the firewall. Upon a new client connecting the proxy will make a connection on behalf of the client to the server residing at 192.168.0.100 on port 20000 via eth1, and then proceed to send all incoming data from the client to the server and vice versa. Once either party (client or server) disconnects, the proxy will immediately disconnect the other party.


C++ TCP Proxy License

Free use of the C++ TCP Proxy is permitted under the guidelines and in accordance with the Boost Software License


Compatability

The C++ TCP Proxy implementation is compatible with the following C++ compilers:

  • GNU Compiler Collection (3.4+)
  • Intel® C++ Compiler (9.x+)
  • Clang/LLVM (1.1+)
  • Microsoft Visual Studio C++ Compiler (8.1+)

Download






Copyright Arash Partow