I proxy almost all my web traffic through a SOCKS proxy. After going through a bunch of different servers, each with its own issues, I decided to just write my own. I ended up using ProxyMachine and it only took seven lines!
# socks4.rb
proxy do |data|
next if data.size < 9
v, c, port, o1, o2, o3, o4, user = data.unpack("CCnC4a*")
return { :close => "\x0\x5b\x0\x0\x0\x0\x0\x0" } if v != 4 or c != 1
next if ! idx = user.index("\x0")
{ :remote => "#{[o1,o2,o3,o4]*'.'}:#{port}", :reply => "\x0\x5a\x0\x0\x0\x0\x0\x0", :data => data[idx+9..-1] }
end
run it with:
$ proxymachine -h 127.0.0.1 -p 1080 -c socks4.rb
* note this only actually covers half of the SOCKS4 protocol, but it’s the only half that pretty much anyone uses

[...] SOCKS 4 server with ProxyMachine « coderrr a few seconds ago from xmpp [...]
Pingback by Postmodern (postmodern) 's status on Friday, 06-Nov-09 08:00:29 UTC - Identi.ca — November 6, 2009 @ 8:00 am