BSDProxy provides a kqueue/kevent based TCP proxy for FreeBSD.
bsdproxy is an event-driven TCP proxy for FreeBSD which uses the kqueue(2)/kevent(2) API in the event loop. It can be used to proxy any communication between a server and its clients which takes place over a TCP connection.
It was mainly written to serve as an example of the uses of FreeBSD kernel event queues for event-driven I/O.
The program is designed to be as efficient as possible so as to maximize the number of simultaneous connections it can support. It works especially well when there is an asymmetry between the connections to the "client" on one side and the "server" on the other.
For example, if bsdproxy is used in front of a web server on the same machine, and serves data to clients on slow modem connections, it will buffer the responses from the server (which should arrive very quickly) in a queue of chunks of data which are sequentially written to the (slow) client whenever the client is ready to receive more data. This way, the server can close the connection to the proxy and continue satisfying other requests, while bsdproxy quietly continues emptying the queued response from the server.
All I/O is done in nonblocking mode, and connections to other hosts are also done without blocking. This way, bsdproxy never needs to block. Every event in the event loop is handled as rapidly as possible.
What's New in This Release: [ read full changelog ]
· If you do a "kill -HUP server_pid", where the server_pid is the process id reported by ps, the server will close its log file and reopen it.
· This is useful for logfile maintenance scripts.
· Fixed a bug which caused the server to die when loads become so heavy that connections must be refused.