-
Notifications
You must be signed in to change notification settings - Fork 3
/
cernet.js
77 lines (66 loc) · 1.51 KB
/
cernet.js
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
66
67
68
69
70
71
72
73
74
75
76
77
// reduce a file for mirrorz-302
// adapted from mirrorz-legacy/generator.js
async function cernet() {
let config = require("./config/config/mirrors.cernet.edu.cn.json")
let sites = [];
config.mirrors_legacy.forEach((abbr) => {
try {
sites.push(require(`./data/${abbr}.json`));
} catch (e) {
console.log(`Error: ${abbr} not found`);
}
});
for (const abbr in config.mirrors) {
try {
sites.push(require(`./data/${abbr}.json`));
} catch (e) {
console.log(`Error: ${abbr} not found`);
}
}
// extra
sites.push(require(`./data/nano.json`));
sites.push(require(`./data/neo.json`));
cnames = []
note = []
cnames_noredir = [
"AOSP",
"CocoaPods",
"homebrew",
"pybombs",
"anaconda",
"gentoo",
]
for (const site of sites) {
if (!("extension" in site && site.extension.includes("D"))) {
continue;
}
note.push(site.site.abbr);
for (const mirror of site.mirrors) {
if (cnames_noredir.includes(mirror.cname)) {
continue;
}
if (!cnames.includes(mirror.cname)) {
cnames.push(mirror.cname);
}
}
}
cernet = {
site: {
abbr: "CERNET",
url: config.url,
name: "校园网联合镜像站(mirrorz-302 智能选择)",
note: note.toString(),
},
info: [],
mirrors: [],
};
for (const cname of cnames) {
cernet.mirrors.push({
cname,
url: "/" + cname,
status: "U",
})
}
return cernet;
}
module.exports = { cernet };