Skip to content

Instantly share code, notes, and snippets.

@JaHIY
Last active September 29, 2020 03:45
Show Gist options
  • Save JaHIY/2861871 to your computer and use it in GitHub Desktop.
Save JaHIY/2861871 to your computer and use it in GitHub Desktop.
Javacript: My Pac File (some code from @ayanamist 's Pac File)
var METHODS = {
PROXY_METHOD:"PROXY 127.0.0.1:8123",
NO_PROXY_METHOD:"DIRECT"
},
rules = [
".akamai.net",
".akamaihd.net",
".appspot.com",
".bitsnoop.com",
".blogspot.com",
".chinagfw.org",
".dotcloud.com",
".dropbox.com",
".facebook.com",
".fbcdn.net",
".fc2.com",
".flickr.com",
".getfoxyproxy.com",
".gist.github.com",
".google.com",
".google.co.jp",
".googleapis.com",
".googleusercontent.com",
".gstatic.com",
".isohunt.com",
".mediafire.com",
".mobypicture.com",
".pastebin.com",
".pixnet.net",
".simplecd.me",
"t.co",
".twitpic.com",
".twitter.com",
".twimg.com",
".wordpress.com",
".waigaobu.com",
".yfrog.com",
".youtube.com",
".ytimg.com"
],
global = (function(){return this || (1,eval)('this');})();
function FindProxyForURL(url, host) {
var METHODS=global.METHODS;
function dnsDomainIs(domain) {
var host_length, domain_length;
return ((domain[0] === '.') ? (host === domain.slice(1) || ((host_length = host.length) >= (domain_length = domain.length) && host.slice(host_length - domain_length) === domain)) : (host === domain));
}
function rule_filter(callback) {
var rules=global.rules, i=rules.length;
do {
if (callback(rules[--i]) === true) {
return true;
}
} while(i !== 0);
return false;
}
if (isPlainHostName(host) === true) {
return METHODS.NO_PROXY_METHOD;
} else {
if (rule_filter(dnsDomainIs) === true) {
return METHODS.PROXY_METHOD;
} else {
return METHODS.NO_PROXY_METHOD;
}
}
}
@JaHIY
Copy link
Author

JaHIY commented Jun 4, 2012

基于 @ayanamist 的自用 PAC 文件 ( https://gist.github.com/1390732 ),仅使用了一个代理配置,重写了部分函数……仅支持域名匹配……咱暂时不需要用正则匹配,所以就没加上、

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment