evan_tech

Previous Entry Share Next Entry
03:45 pm, 21 Feb 10

socks5 proxying flash via ssh

Suppose you're in Germany and want to watch some Flash-based videos that are IP-limited to the US for whatever reason. At first you'd think you could set up a proxy in the US and just tell your browser to use that, but it seems that Flash makes its own network connections on the side, and it's not clear how to configure that.

(Perhaps it reaches into the Mozilla settings? Perhaps this just works in Mozilla when you have a proxy set up?
$ strings /etc/alternatives/mozilla-flashplugin | grep \\.proxy
network.proxy.type
network.proxy.http
network.proxy.http_port
network.proxy.ssl
network.proxy.ssl_port
Hmm.)

In any case, it's actually even more trivial to set up a socks5 proxy via ssh and LD_PRELOAD over all the connection functions so no matter how the program connects, it gets your proxy.
  1. sudo apt-get install tsocks (this is the preloader)
  2. sudo vi /etc/tsocks.conf, remove the example block, and add in
    server = 127.0.0.1
    server_type = 5
    server_port = 1080
    at the bottom in the defaults area
  3. ssh -D 1080 box-in-america (or add a DynamicForward 1080 line to the appropriate stanza in your ~/.ssh/config)
  4. tsocks firefox (I didn't try Chrome -- I was worried that our multiple processes and loaders would eat the LD_PRELOAD, but actually all the network is done by the outermost process so it perhaps ought to work)
Note that, as compared to proxying HTTP via ssh, you don't need to run an HTTP proxy on box-in-america -- ssh does the proxying implicitly. However, it seems perhaps slower than an HTTP proxy.