Last active
December 14, 2022 02:19
-
-
Save amosbird/4da9eab5f3ea9322bfb1a69cd5aa57ec 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
var direct = 'DIRECT'; | |
var http_proxy = 'PROXY 127.0.0.1:12639'; | |
var gfwed_list = [ | |
"oa.com", | |
"woa.com", | |
"oa.tencent.com", | |
]; | |
var gfwed = {}; | |
for (var i = 0; i < gfwed_list.length; i += 1) { | |
gfwed[gfwed_list[i]] = true; | |
} | |
function host2domain(host) { | |
var dotpos = host.lastIndexOf("."); | |
if (dotpos === -1) | |
return host; | |
// Find the second last dot | |
dotpos = host.lastIndexOf(".", dotpos - 1); | |
if (dotpos === -1) | |
return host; | |
return host.substring(dotpos + 1); | |
}; | |
function FindProxyForURL(url, host) { | |
return gfwed[host2domain(host)] ? http_proxy : direct; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment