mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Build reject hosts stats
This commit is contained in:
parent
814cb741e5
commit
2cec0789b1
@ -198,6 +198,9 @@ const domainSuffixSet = new Set();
|
|||||||
|
|
||||||
console.time('* Write reject.conf');
|
console.time('* Write reject.conf');
|
||||||
|
|
||||||
|
/** @type {Record<string, number>} */
|
||||||
|
const rejectDomainsStats = {};
|
||||||
|
|
||||||
const sorter = (a, b) => {
|
const sorter = (a, b) => {
|
||||||
if (a.domain > b.domain) {
|
if (a.domain > b.domain) {
|
||||||
return 1;
|
return 1;
|
||||||
@ -209,7 +212,9 @@ const domainSuffixSet = new Set();
|
|||||||
};
|
};
|
||||||
const sortedDomainSets = dudupedDominArray
|
const sortedDomainSets = dudupedDominArray
|
||||||
.map((v) => {
|
.map((v) => {
|
||||||
return { v, domain: getDomain(v.charCodeAt(0) === 46 ? v.slice(1) : v) || v };
|
const domain = getDomain(v.charCodeAt(0) === 46 ? v.slice(1) : v) || v;
|
||||||
|
rejectDomainsStats[domain] = (rejectDomainsStats[domain] || 0) + 1;
|
||||||
|
return { v, domain };
|
||||||
})
|
})
|
||||||
.sort(sorter)
|
.sort(sorter)
|
||||||
.map((i) => i.v);
|
.map((i) => i.v);
|
||||||
@ -234,6 +239,14 @@ const domainSuffixSet = new Set();
|
|||||||
pathResolve(__dirname, '../List/domainset/reject.conf')
|
pathResolve(__dirname, '../List/domainset/reject.conf')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await fs.promises.writeFile(
|
||||||
|
pathResolve(__dirname, '../List/internal/reject-stats.txt'),
|
||||||
|
Object.entries(rejectDomainsStats)
|
||||||
|
.sort((a, b) => b[1] - a[1])
|
||||||
|
.map(([domain, count]) => `${domain}${' '.repeat(100 - domain.length)}${count}`)
|
||||||
|
.join('\n')
|
||||||
|
);
|
||||||
|
|
||||||
// Copy reject_sukka.conf for backward compatibility
|
// Copy reject_sukka.conf for backward compatibility
|
||||||
await fse.copy(pathResolve(__dirname, '../Source/domainset/reject_sukka.conf'), pathResolve(__dirname, '../List/domainset/reject_sukka.conf'));
|
await fse.copy(pathResolve(__dirname, '../Source/domainset/reject_sukka.conf'), pathResolve(__dirname, '../List/domainset/reject_sukka.conf'));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user