Skip to content

Instantly share code, notes, and snippets.

@cuber
Last active December 26, 2016 16:00
Show Gist options
  • Save cuber/7e1cb2864ec139236b59 to your computer and use it in GitHub Desktop.
Save cuber/7e1cb2864ec139236b59 to your computer and use it in GitHub Desktop.
O(1) proxy.pac file
// Generated by gfwlist2pac
// created by @clowwindy via python
// modified by @cube via native zsh
// https://github.com/cuber/gfwlist2pac
var domains = {
'dnsimple.com': 1,
'stackoverflow.com': 1,
'igvita.com': 1,
'jetbrains.com': 1,
'linost.com': 1,
'linode.com': 1,
'githubapp.com': 1,
'wikimedia.org': 1,
'v2ex.com': 1,
'btdigg.org': 1,
'eigenlogik.com': 1,
'apache.org': 1,
'digitalocean.com': 1,
'linkedin.com': 1,
'instagram.com': 1,
'jquery.com': 1,
'github.com': 1,
'iceimg.com': 1,
'firstrade.com': 1,
'godaddy.com': 1,
'amazon.com': 1,
'digitalattackmap.com': 1,
'startssl.com': 1,
'agilebits.com': 1,
'speedtest.net': 1
} // end of domains
// proxy failover
var proxy = 'SOCKS5 127.0.0.1:7070; SOCKS 127.0.0.1:7070; DIRECT;'
var direct = 'DIRECT;'
// function of proxy router
function FindProxyForURL(url, host) {
// restrict all google related domains to proxy
if (/google/i.test(host)) return proxy;
// recursive detection domains
do {
if (domains.hasOwnProperty(host)) return proxy;
off = host.indexOf('.') + 1;
host = host.slice(off);
} while (off >= 1);
return direct;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment