lord-inflight

08
May
2012

Transockproxy

Uncategorized

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

This entry was posted on Tuesday, May 8th, 2012 at 4:57 AM and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

To deter spammers, your browser is required to perform some mathematical work before your comment can be posted.
The "Submit" button will be available once this is complete.
The time this takes is random, but should only be a few seconds.