Skip to content

High-performance TCP proxy implemented in C. All I/O operations are asynchronous. Pool of I/O threads using pthreads. Automatically chooses epoll, kqueue, or poll as polling backend.

License

GPL-3.0, LGPL-3.0 licenses found

Licenses found

GPL-3.0
COPYING.GPLv3
LGPL-3.0
COPYING.LGPLv3
Notifications You must be signed in to change notification settings

aaronriekenberg/cproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cproxy

High-performance TCP proxy implemented in C.

Usage

cproxy -l <local addr>:<local port> [-l <local addr>:<local port>...] 
       -r <remote addr>:<remote port> [-b <buf size>] [-n] [-t <num io threads>]
Arguments:
  -l <local addr>:<local port>: specify listen address and port
  -r <remote addr>:<remote port>: specify remote address and port
  -b <buf size>: specify session buffer size in bytes
  -n: enable TCP no delay
  -t: <num io threads>: specify number of I/O threads

Theory of Operation

  • 1 acceptor thread to accept incoming client connections.
  • Pool of 1 to N I/O threads to handle read, write, and connect operations. Pool size is configurable with -t option. Client sessions assigned to I/O threads using round robin.
  • 2 buffers per client session, one for each direction of traffic. Buffer size is configurable with -b option. Buffers are allocated from per-thread buffer pools in each I/O thread.
  • All sockets are non-blocking. All read, write, connect, and accept operations are asynchronous.
  • Automatically chooses between epoll, kqueue, and poll as the poll system call. epoll or kqueue are recommended because they allow storing pointers to connection state information in events passed to and from the kernel, eliminating lookup of state information every time through the event loop. If poll is used, connection state information is stored in a red-black tree from libavl 2.0.3.
  • kqueue is currently only supported on FreeBSD because that's the only platform I have access to test. It should also work on OS X and other BSDs.

About

High-performance TCP proxy implemented in C. All I/O operations are asynchronous. Pool of I/O threads using pthreads. Automatically chooses epoll, kqueue, or poll as polling backend.

Resources

License

GPL-3.0, LGPL-3.0 licenses found

Licenses found

GPL-3.0
COPYING.GPLv3
LGPL-3.0
COPYING.LGPLv3

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages