How to survive a Chinese internet cafe

Most hotels in major Chinese cities now offer free wifi, but what if you're traveling a bit off the beaten path or didn't bring a computer? One of the most convenient options for getting online is to use an internet cafe. I keep a USB stick for this exact purpose, here's what I have on it:

  • PuTTY Portable
  • Firefox Portable
  • A .pac file
  • (Optional) SumatraPDF portable

Essentially, the USB stick contains all the necessary ingredients for a SSH tunnel proxy. All of the software are Portable Apps. Use as follows:

  1. Set up an SSH dynamic tunnel to a host of your choice--I'm a Stanford student, so myth.stanford.edu works well for this purpose. (You can find instructions online.) Just make sure the host is outside of China.
  2. Configure Firefox to use the tunnel either directly or using the PAC file. The PAC file is very convenient for long-term use in countries like China, where certain sites (e.g. Baidu, Weibo, Youku etc.) should be accessed direct and others (Facebook, YouTube) should be accessed through the proxy. I've included an example PAC file below, of course, be sure to change the site lists to taste.
  3. Browse the internet!

Example PAC file which includes several Chinese sites:

function FindProxyForURL(url, host) {
    var direct_sites = [
        'localhost',
        '192.168.*',

        '*.cn',
        'baidu.com',
        '*.baidu.com',
        '*.bdstatic.com',
        '*.bdimg.com',
        'renren.com',
        '*.renren.com',
        '*.xnimg.com',
        'weibo.com',
        '*.weibo.com',
        'youku.com',
        '*.youku.com',
        '*.ykimg.com',
        '*.tudou.com'
        ];

    for (var i = 0; i < direct_sites.length; i++) {
        if (shExpMatch(host, direct_sites[i])) {
            return "DIRECT";
        }
    }

    // This will change depending on how you set up your tunnel
    var proxy_url = "SOCKS5 127.0.0.1:9876";
    var proxy_sites = [
        'facebook.com',
        '*.facebook.com',
        'youtube.com',
        '*.youtube.com',
        'google.com',
        'www.google.com'
        ];

    for (var i = 0; i < proxy_sites.length; i++) {
        if (shExpMatch(host, proxy_sites[i])) {
            return proxy_url;
        }
    }

    return proxy_url + ";DIRECT";
}

Comments

comments powered by Disqus