Squash dns-reverse-proxy branch for pull // FREEBIE

Squashed commit of the following:

commit 27c8698b3153b69b6deda5c2819649516eb26946
Merge: 95bc597 94338f7
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri May 16 22:57:18 2014 +0800

    Merge branch 'master' into dns-reverse-proxy

commit 95bc597fbfa34a663d43bab9f14ede00e1f04809
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri May 16 22:17:36 2014 +0800

    Safe guard DNS message decoding

commit 8b5c262960e75cd2de556c1b439328a24fa7683e
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Thu May 15 21:29:27 2014 +0800

    Clear env[] after chroot

commit 1d454ea579ee39773c3461c493c6e51e0dfb2cec
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Wed May 14 20:54:40 2014 +0800

    move utils.py to lutils.py

    Also handle HTTPd request port other than 80

commit cf16f3728d339ab746b416e556c767d7d97a47cf
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Mon May 12 22:48:27 2014 +0800

    Make sogou server renew more robust

commit 159aeb5ba25020bd0858ed9c8d3aeb90f714b63e
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sun May 11 22:19:57 2014 +0800

    Drop root privilege if package `chroot` installed

commit cac38eee6ba57dd56ad774d87a0f61f07bcd9b9b
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri May 9 21:32:34 2014 +0800

    speedup is_valid_url() and drop unknown http request

commit f337b4232b02fc7d58a6df192eb94abd1042cd16
Merge: 4d3aad2 6b4f423
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri May 9 01:11:38 2014 +0800

    Merge branch 'master' into dns-reverse-proxy

commit 4d3aad212e202e6a3356b94600f1a6b733d829da
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Thu May 8 23:10:10 2014 +0800

    Add rate limit to HTTP server too

commit 3995ff505edf467337c60dfbd93d85dd0109d0f2
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Wed May 7 20:49:28 2014 +0800

    Allow set external IP address

    For the servers setup behind a router, we need to be able to specify the
    public IP address for the DNS proxy to route to.

commit 431aa034fb4cb6d9cf9c48b9c0a6cfb5ce4d76c4
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Mon May 5 20:39:24 2014 +0800

    Warn when IP of sogou proxy seems wrong

    Sometime, ISP DNS might hijack sogou IP for reverse caching

commit d77822ee60e182b680641e9c0005f14b21466423
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sun May 4 16:03:08 2014 +0800

    Detect file being run by node use node convension

commit 0fc1a0ae1cf933630046394878ff72eeaf28882e
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sat May 3 11:19:18 2014 +0800

    Add options to load extra url list

    Could be used for temporary solution or testing...

commit 230b82563bfe76d614b4ff7342b2b0eb60a6d6fb
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri May 2 20:41:33 2014 +0800

    Add --dns-no-relay and --dns-rate-limit options

    Try to battle against common DoS attacks on DNS with added features.

     * Add query limit per second per IP to avoid flood. Once over
       the limit, the IP will be "cool down" for a few minutes.

     * Add option to not relay un-interested domain lookup to upstream
       DNS. For general domain lookup like "baidu.com", we send back a
       "Refused" DNS message immediately, with --dns-no-relay option.
       The getaddrinfo() is supposed to try another DNS server on error.

       So with --dns-no-relay on, the client OS should have some backup
       DNS which will do normal DNS lookup when our DNS return "Refused"
       message. Or it will not gonna be able to resolve most domain
       names!!

commit f026a3154996050083d1a2bd99c8a460b5f51449
Merge: d5cb2cd 3913f94
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Thu May 1 22:43:37 2014 +0800

    Merge branch 'master' into dns-reverse-proxy

commit d5cb2cda65fd7b1715e14d1989dcffc5c5f15365
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Thu May 1 21:45:10 2014 +0800

    Fix a bug on hardcoded sogou dns to 8.8.8.8

commit 6e2e7c6c935590af93c3f70021d9640f7b159d21
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Wed Apr 30 21:00:41 2014 +0800

    Fix a bug when using ip proxy

commit 9dd7b7aaef7d52136726e3ff6c5296a30517259f
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Wed Apr 30 20:19:06 2014 +0800

    Allow comments in config file

commit b459c479c97d61e54e4f8094dcd464249a56d944
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Mon Apr 28 20:48:29 2014 +0800

    Try to make Makefile more flexible/complex

commit 419a6ba64a8575a988effcf8b451db590402a552
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sun Apr 27 23:42:46 2014 +0800

    Add option to force "edu" or "dxt" sogou proxy

commit c477af9c6626895fe9e2ffabd11044ec4b7ce5ca
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sun Apr 27 22:52:24 2014 +0800

    Update Readme.md

commit c4a56f9e8af016fa98ca05ebd898c8ab5c3a8b7e
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sun Apr 27 21:49:50 2014 +0800

    sogou_dns option: use given DNS for sogou server

commit 2ab3760a82d6c1c1c79769b5b3c5f646c4f4d667
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sun Apr 27 21:09:27 2014 +0800

    Prepare to direct lookup ip for sogou proxy server

    Instead of function utils.renew_sogou_server(), we create a
    SogouManager emitter class to manage renew of sogou proxy servers.

commit 90ce5a1d3c9bac973e1aa6b9fed8670a35ff712a
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sun Apr 27 18:31:14 2014 +0800

    new DnsResolver: DNS lookup at given DNS server

    Direct query a DNS server to resolve domain names.

    Some ISP DNS server hijack domain to point to their own cache proxy.
    Just like what we intent to do ourselves. ;)

    Sogou proxy server domains can be hijacked in this way. Using system
    getaddrinfo() will fail us. We have to use some other DNS server to
    lookup sogou proxy server domain names when neccessary.

commit a628159d9cd21e96400f377ea67d050c7fe148ce
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sun Apr 27 00:02:08 2014 +0800

    Log more info when proxy screwed by ManInTheMiddle

commit 9cbeaa596dc66f895cf605e6149fa04c28f682ae
Merge: 0753b07 ac245de
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sat Apr 26 23:14:30 2014 +0800

    Merge branch 'master' into dns-reverse-proxy

commit 0753b07172af9461c43a66a7f1764c694eaa7366
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sat Apr 26 18:24:45 2014 +0800

    Ajust difference b/w simple HTTPd and Proxy servers

commit 40203a56c429e91ac22c77f0ec69e8af7c02b0b2
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sat Apr 26 14:37:46 2014 +0800

    Add dependency and usage info to Readme.md

commit 813a4e70984259772355c7637c6bf26e8bae7c36
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sat Apr 26 14:20:39 2014 +0800

    now we have runnable dns-revser-proxy server

commit 5c81482886d786abcc728f0a975b5517ec540e71
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sat Apr 26 14:19:27 2014 +0800

    clean up code

commit 3bb256736e5716adbe3926d0b8fede77309a4b1a
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sat Apr 26 09:51:14 2014 +0800

    rename ip/port in options to listen_address/port

commit bd194a071d0a57272173788b500acfc9204b997c
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Thu Apr 24 22:22:28 2014 +0800

    I really think anonymouse functions look like crap

commit 265db1d99af20fe21d9e189763cc1047407c0019
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Mon Apr 21 16:03:49 2014 +0800

    Remove require on uglify-js

    Since we don't serve pac file, we don't need uglify-js for now.

commit 3773121def4b9e53de5f3863a5c6578da6fbabd7
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Mon Apr 21 16:02:51 2014 +0800

    make dns-proxy.py works with `make run dns-proxy.js` for test

commit 205d779dc0e8b01f9c6bcc286835b6a0c0c92e91
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Mon Apr 21 15:54:03 2014 +0800

    First working reverse proxy server

    Also tweak Makefile to make it easier to test .js files

    The utils.py are just reinvent of ../server/utils.js except we
    don't need pac file and other functions just yet.

commit c2caa6a75498c1debcd2d971bd72078f9725762c
Merge: 7600ebd 38ed4ce
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sat Apr 19 15:19:37 2014 +0800

    Merge stand alone "unblock-youku-dns" repository

commit 38ed4ce2ca478405fe4e17fae755db95b80efaba
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Sat Apr 19 15:10:08 2014 +0800

    Move dns reverse proxy stuff into sub dir

commit b4db4cea7f119f78afae440379898753c6f966cb
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri Apr 18 19:23:28 2014 +0800

    Update QUERY_TYPES to RECORD_TYPES

commit f1eb4c1c4c554add59b024402bb65dd90cf3fbc6
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri Apr 18 15:18:47 2014 +0800

    Split long func

commit 363652d379f4e843eca52892c6df6ee3525ec16b
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri Apr 18 15:06:54 2014 +0800

    remove redundance

commit 9630d2d9194daefc1976f5e8e0b3659e1a5b270c
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri Apr 18 15:02:23 2014 +0800

    dns short cut for routed domains

commit 0446ffae5e7471a7c3e6ea6ba7d2100d7b23a7f0
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri Apr 18 14:16:49 2014 +0800

    local route domain to ip actually work now!

commit 1eded4831b18b32a200ea576032393c2957c1f74
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri Apr 18 11:09:36 2014 +0800

    Work better with label compression

commit 83f8743b60a60f83f814e7a7a490d20af242396b
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Fri Apr 18 01:20:02 2014 +0800

    straight proxy works

commit 1da9a3fbec619815a282adec625d3541d3d10824
Author: mozbugbox <mozbugbox@yahoo.com.au>
Date:   Thu Apr 17 19:27:26 2014 +0800

    initial commit
Merge pull request #275 from mozbugbox/dns-reverse-proxy-pull

Squash dns-reverse-proxy branch for pull // FREEBIE
add the DNS server by @mozbugbox to the main README file; polish the wording of the main README file a little bit  // FREEBIE
remove dxt servers  // FREEBIE
add a Makefile to package all crx-related files  // FREEBIE
fix letv apps and #289

fix for letv live and letv android.
also for #289
Merge pull request #290 from karlcheong/patch-1

fix letv apps and #289
restrict proxy servers to h0 ~ h3 only; we need to set up our own
servers soon  // FREEBIE
to test our own server  // FREEBIE
fix a bug for server side; increase timeout for testing proxy servers  // FREEBIE
add an experimental server provided by @whuhacker  // FREEBIE
polish Makefile  // FREEBIE
use ga to collect the ratio of different proxy servers  // FREEBIE
fix iqiyi apps #291

fix iqiyi apps #291
Merge pull request #292 from karlcheong/master

fix iqiyi apps #291
inscrease the ga report rate for the proxy server selction, since ga
does't show anything (?)  // FREEBIE
use new domain for our own proxy servers  // FREEBIE
reduce ga_report_event rate  // FREEBIE