-
-
Save vqiu/d1b1e1fa97e9a1871f43344f34e721e5 to your computer and use it in GitHub Desktop.
PAC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function FindProxyForURL(url, host) { | |
var proxy = "SOCKS5 127.0.0.1:1080; SOCKS 127.0.0.1:1080; DIRECT"; | |
var black = "PROXY 127.0.0.1:65535"; | |
var direct = "DIRECT"; | |
var PROXY_LIST = [ | |
"instagram.com", | |
"google.com", | |
"facebook.com", | |
"github.com", | |
"httpbin.org", | |
]; | |
/* | |
var BLACK_LIST = [ | |
"jd.com", | |
"taobao.com", | |
"dangdang.com", | |
"tmall.com", | |
"pinduoduo.com" | |
]; | |
*/ | |
url = url.toLowerCase(); | |
host = host.toLowerCase(); | |
if (host == "127.0.0.1") { | |
return direct; | |
} | |
if (isPlainHostName(host)) { | |
return direct; | |
} | |
var ip = dnsResolve(host); | |
if (isInNet(ip, "10.0.0.0", "255.0.0.0") || isInNet(ip, "192.168.0.0", "255.255.0.0")) { | |
return direct; | |
} | |
for (i = 0; i < PROXY_LIST.length; i++) { | |
domain = '*' + PROXY_LIST[i]; | |
if (shExpMatch(host, domain)) { | |
return proxy; | |
} | |
} | |
/* | |
for (i = 0; i < BLACK_LIST.length; i++) { | |
domain = '*' + BLACK_LIST[i]; | |
if (shExpMatch(host, domain)) { | |
return black; | |
} | |
} | |
*/ | |
return direct; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment