Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 67 additions & 64 deletions whitelist.pac
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ var white_domains = {"am":{
"mzsky":1,
"n21":1,
"nandagang":1,
"ngacn":1,
"pingyin":1,
"pinjie":1,
"pp":1,
Expand Down Expand Up @@ -6485,6 +6486,7 @@ var white_domains = {"am":{
"staticsdo":1,
"stcn":1,
"stdaily":1,
"steampowered":1,
"steelphone":1,
"stnts":1,
"stockstar":1,
Expand Down Expand Up @@ -8793,6 +8795,7 @@ var white_domains = {"am":{
"importfood":1,
"indexedu":1,
"inhe":1,
"ipip":1,
"irs01":1,
"ishang":1,
"itcpn":1,
Expand Down Expand Up @@ -9572,6 +9575,7 @@ var white_domains = {"am":{
"9928":1,
"9998":1,
"acg":1,
"acfun":1,
"bilibili":1,
"caoxian":1,
"cnnl":1,
Expand Down Expand Up @@ -9612,86 +9616,85 @@ var white_domains = {"am":{

var subnetIpRangeList = [
0,1,
167772160,184549376, //10.0.0.0/8
2886729728,2887778304, //172.16.0.0/12
3232235520,3232301056, //192.168.0.0/16
2130706432,2130706688 //127.0.0.0/24
167772160,184549376, //10.0.0.0/8
2886729728,2887778304, //172.16.0.0/12
3232235520,3232301056, //192.168.0.0/16
2130706432,2130706688 //127.0.0.0/24
];

var hasOwnProperty = Object.hasOwnProperty;

function check_ipv4(host) {
// check if the ipv4 format (TODO: ipv6)
// http://home.deds.nl/~aeron/regex/
var re_ipv4 = /^\d+\.\d+\.\d+\.\d+$/g;
if (re_ipv4.test(host)) {
// in theory, we can add chnroutes test here.
// but that is probably too much an overkill.
return true;
}
// check if the ipv4 format (TODO: ipv6)
// http://home.deds.nl/~aeron/regex/
var re_ipv4 = /^\d+\.\d+\.\d+\.\d+$/g;
if (re_ipv4.test(host)) {
// in theory, we can add chnroutes test here.
// but that is probably too much an overkill.
return true;
}
}
function convertAddress(ipchars) {
var bytes = ipchars.split('.');
var result = (bytes[0] << 24) |
(bytes[1] << 16) |
(bytes[2] << 8) |
(bytes[3]);
return result >>> 0;
var bytes = ipchars.split('.');
var result = (bytes[0] << 24) |
(bytes[1] << 16) |
(bytes[2] << 8) |
(bytes[3]);
return result >>> 0;
}
function isInSubnetRange(ipRange, intIp) {
for ( var i = 0; i < 10; i += 2 ) {
if ( ipRange[i] <= intIp && intIp < ipRange[i+1] )
return true;
}
for ( var i = 0; i < 10; i += 2 ) {
if ( ipRange[i] <= intIp && intIp < ipRange[i+1] )
return true;
}
}
function getProxyFromDirectIP(strIp) {
var intIp = convertAddress(strIp);
if ( isInSubnetRange(subnetIpRangeList, intIp) ) {
return direct;
}
return ip_proxy;
var intIp = convertAddress(strIp);
if ( isInSubnetRange(subnetIpRangeList, intIp) ) {
return direct;
}
return ip_proxy;
}
function isInDomains(domain_dict, host) {
var suffix;
var pos1 = host.lastIndexOf('.');
var suffix;
var pos1 = host.lastIndexOf('.');

suffix = host.substring(pos1 + 1);
if (suffix == "cn") {
return true;
}
suffix = host.substring(pos1 + 1);
if (suffix == "cn") {
return true;
}

var domains = domain_dict[suffix];
if ( domains === undefined ) {
return false;
}
host = host.substring(0, pos1);
var pos = host.lastIndexOf('.');
var domains = domain_dict[suffix];
if ( domains === undefined ) {
return false;
}
host = host.substring(0, pos1);
var pos = host.lastIndexOf('.');

while(1) {
if (pos <= 0) {
if (hasOwnProperty.call(domains, host)) {
return true;
} else {
return false;
}
}
suffix = host.substring(pos + 1);
if (hasOwnProperty.call(domains, suffix)) {
return true;
}
pos = host.lastIndexOf('.', pos - 1);
}
while(1) {
if (pos <= 0) {
if (hasOwnProperty.call(domains, host)) {
return true;
} else {
return false;
}
}
suffix = host.substring(pos + 1);
if (hasOwnProperty.call(domains, suffix)) {
return true;
}
pos = host.lastIndexOf('.', pos - 1);
}
}
function FindProxyForURL(url, host) {
if ( isPlainHostName(host) === true ) {
return direct;
}
if ( check_ipv4(host) === true ) {
return getProxyFromDirectIP(host);
}
if ( isInDomains(white_domains, host) === true ) {
return nowall_proxy;
}
return wall_proxy;
if ( isPlainHostName(host) === true ) {
return direct;
}
if ( check_ipv4(host) === true ) {
return getProxyFromDirectIP(host);
}
if ( isInDomains(white_domains, host) === true ) {
return nowall_proxy;
}
return wall_proxy;
}