mirror of
https://gitlab.com/SukkaW/ruleset.skk.moe.git
synced 2026-01-02 02:20:24 +00:00
deploy: 02e1cb00e0210b23132c676c7310ed4f5aa90d58
This commit is contained in:
@@ -12,6 +12,7 @@ const threads = isCI ? cpuCount : cpuCount / 2;
|
||||
/** @type Set<string> */
|
||||
const domainSets = new Set();
|
||||
|
||||
console.log('Downloading hosts file...');
|
||||
console.time('* Download and process Hosts');
|
||||
|
||||
// Parse from remote hosts & domain lists
|
||||
@@ -230,7 +231,10 @@ const threads = isCI ? cpuCount : cpuCount / 2;
|
||||
|
||||
const piscina = new Piscina({
|
||||
filename: pathResolve(__dirname, 'worker/build-reject-domainset-worker.js'),
|
||||
workerData: [...domainSets]
|
||||
workerData: [...domainSets],
|
||||
idleTimeout: 50,
|
||||
minThreads: threads,
|
||||
maxThreads: threads
|
||||
});
|
||||
|
||||
console.log(`Launching ${threads} threads...`)
|
||||
@@ -244,19 +248,18 @@ const threads = isCI ? cpuCount : cpuCount / 2;
|
||||
return result;
|
||||
}, []);
|
||||
|
||||
(await Promise.all(
|
||||
Array.from(domainSets)
|
||||
.reduce((result, element, index) => {
|
||||
const chunk = index % threads;
|
||||
result[chunk] ??= [];
|
||||
|
||||
result[chunk].push(element);
|
||||
return result;
|
||||
}, [])
|
||||
.map(chunk => piscina.run(
|
||||
{ chunk }
|
||||
))
|
||||
)).forEach((result, taskIndex) => {
|
||||
(
|
||||
await Promise.all(
|
||||
Array.from(domainSets)
|
||||
.reduce((result, element, index) => {
|
||||
const chunk = index % threads;
|
||||
result[chunk] ??= [];
|
||||
result[chunk].push(element);
|
||||
return result;
|
||||
}, [])
|
||||
.map(chunk => piscina.run({ chunk }, { name: 'dedupe' }))
|
||||
)
|
||||
).forEach((result, taskIndex) => {
|
||||
const chunk = tasksArray[taskIndex];
|
||||
result.forEach((value, index) => {
|
||||
if (value === 1) {
|
||||
@@ -275,7 +278,10 @@ const threads = isCI ? cpuCount : cpuCount / 2;
|
||||
{ encoding: 'utf-8' }
|
||||
),
|
||||
piscina.destroy()
|
||||
])
|
||||
]);
|
||||
|
||||
console.timeEnd('Total Time - build-reject-domain-set');
|
||||
if (piscina.queueSize === 0) {
|
||||
process.exit(0);
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -55,6 +55,8 @@ async function processDomainLists (domainListsUrl) {
|
||||
* @param {string | URL} hostsUrl
|
||||
*/
|
||||
async function processHosts (hostsUrl, includeAllSubDomain = false) {
|
||||
console.time(` - processHosts: ${hostsUrl}`);
|
||||
|
||||
if (typeof hostsUrl === 'string') {
|
||||
hostsUrl = new URL(hostsUrl);
|
||||
}
|
||||
@@ -87,6 +89,8 @@ async function processHosts (hostsUrl, includeAllSubDomain = false) {
|
||||
}
|
||||
});
|
||||
|
||||
console.timeEnd(` - processHosts: ${hostsUrl}`);
|
||||
|
||||
return [...domainSets];
|
||||
}
|
||||
|
||||
@@ -98,10 +102,6 @@ async function processHosts (hostsUrl, includeAllSubDomain = false) {
|
||||
async function processFilterRules (filterRulesUrl, fallbackUrls) {
|
||||
console.time(` - processFilterRules: ${filterRulesUrl}`);
|
||||
|
||||
if (typeof filterRulesUrl === 'string') {
|
||||
filterRulesUrl = new URL(filterRulesUrl);
|
||||
}
|
||||
|
||||
/** @type Set<string> */
|
||||
const whitelistDomainSets = new Set();
|
||||
/** @type Set<string> */
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
const { workerData, move } = require('piscina');
|
||||
const Piscina = require('piscina');
|
||||
// pre check if fullset domain is starts with a "."
|
||||
// This avoid calling chatCodeAt repeatedly
|
||||
|
||||
module.exports = ({ chunk }) => {
|
||||
// pre check if fullset domain is starts with a "."
|
||||
// This avoid calling chatCodeAt repeatedly
|
||||
|
||||
// workerData is an array of string. Sort it by length, short first:
|
||||
const fullsetDomainStartsWithADot = workerData.filter(domain => (
|
||||
domain.charCodeAt(0) === 46
|
||||
&& !canExcludeFromDedupe(domain)
|
||||
));
|
||||
const totalLen = fullsetDomainStartsWithADot.length;
|
||||
// workerData is an array of string. Sort it by length, short first:
|
||||
const fullsetDomainStartsWithADot = Piscina.workerData.filter(domain => (
|
||||
domain.charCodeAt(0) === 46
|
||||
&& !canExcludeFromDedupe(domain)
|
||||
));
|
||||
const totalLen = fullsetDomainStartsWithADot.length;
|
||||
|
||||
module.exports.dedupe = ({ chunk }) => {
|
||||
const chunkLength = chunk.length;
|
||||
const outputToBeRemoved = new Int8Array(chunkLength);
|
||||
|
||||
@@ -61,7 +60,7 @@ module.exports = ({ chunk }) => {
|
||||
}
|
||||
}
|
||||
|
||||
return move(outputToBeRemoved);
|
||||
return outputToBeRemoved;
|
||||
};
|
||||
|
||||
// duckdns.org domain will not overlap and doesn't need dedupe
|
||||
|
||||
@@ -61445,6 +61445,8 @@ delivery.maihehd.com
|
||||
.dota.sykty.com
|
||||
.cdnny.com
|
||||
.adblock.sina.cn
|
||||
.cmci5cape.icu
|
||||
.1wkg.cn
|
||||
.micpn.com
|
||||
.tw.cx
|
||||
.zenaps.com
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<main class="container">
|
||||
<h1>Sukka Surge Ruleset Server</h1>
|
||||
<p>Made by <a href="https://skk.moe">Sukka</a> | <a href="https://github.com/SukkaW/Surge/">Source @ GitHub</a> | Licensed under <a href="https://github.com/SukkaW/Surge/blob/master/LICENSE" target="_blank">AGPL-3.0</a></p>
|
||||
<p>Last Updated: 2022-09-25T12:47:00.776Z</p>
|
||||
<p>Last Updated: 2022-09-25T14:25:11.675Z</p>
|
||||
<hr>
|
||||
<br>
|
||||
<ul>
|
||||
|
||||
Reference in New Issue
Block a user