-
Notifications
You must be signed in to change notification settings - Fork 3
/
proxy.pac
66 lines (61 loc) · 1.61 KB
/
proxy.pac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function r(tmp) {
return function(url, host) {
var tests = []
if (! tests instanceof Array) {
tests = [tmp]
} else {
tests = tmp
}
for (var i = 0; i < tests.length; i++) {
var test = tests[i]
if (test instanceof RegExp) {
if (test.test(host)) {
return true;
}
}
if (typeof test == 'string') {
if (new RegExp('.*' + test + '.*').test(host)) {
return true;
}
}
if (test instanceof Function) {
if (test(url, host)) {
return true
}
}
}
return false
}
};
function checkProxy(nets) {
return function(url, host) {
for (var i = 0; i < nets.length; i++) {
if (isInNet(dnsResolve(host), nets[i][0], nets[i][1])) {
return true;
}
}
}
}
var FindProxyForURL = function(config) {
return function(url, host) {
if (host === "[::1]" || host === "localhost" || host === "127.0.0.1")
return "DIRECT";
var scheme = url.substr(0, url.indexOf(":"));
for (var i = 0; i < config.length; i++) {
proxy = config[i][0]
tests = config[i][1]
if (r(tests)(url, host)) {
return proxy
}
}
return "DIRECT";
};
}([
// [
// "SOCKS5 localhost:1235",
// [
// /(ut1\.omniture\.com|or1.omniture.com|mcps\.adobe\.net|lon\.omniture\.com)$/
// ]
// ],
["DIRECT", [ new RegExp("") ] ],
])