08 May 2012
Transockproxy
This is a pretty special-case utility, but I happened to have a use for it, so maybe someone else will too. It’s released under GPL v2.
Basically, it’s a lightweight, non-caching, transparent HTTP proxy which relays through an upstream SOCKS4a server. It’s designed for Linux, but is fairly generic so should probably work on other UNIX OSes too.
It uses 1 thread per connection, and select() internally to do relaying in both directions. This also means it supports HTTP 1.1 features like chunked encoding, keep-alive, and pipelining.
Known limitation: It can’t currently handle HTTP connections to ports other than 80.
Download: transockproxy.c
To compile:
gcc -O2 -o transockproxy transockproxy.c -lpthread
To use:
./transockproxy <listen port> <socks server> <socks port>
For example, to listen on port 1888 and relay via a SOCKS4a server on 10.0.0.1:1080:
./transockproxy 1888 10.0.0.1 1080
You may also wish to redirect HTTP requests to it via iptables, via something like:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to 1888