Minor fixes

This commit is contained in:
SukkaW 2023-11-03 11:51:35 +08:00
parent 31d021dd23
commit d80ea1ecd8
2 changed files with 11 additions and 3 deletions

View File

@ -32,7 +32,12 @@ const buildInternalReverseChnCIDR = task(__filename, async () => {
]);
const reversedCidr = exclude(
['0.0.0.0/0'],
[
'0.0.0.0/0',
// https://github.com/misakaio/chnroutes2/issues/25
'223.118.0.0/15',
'223.120.0.0/15'
],
RESERVED_IPV4_CIDR.concat(cidr),
true
);

View File

@ -5,6 +5,7 @@ const { createRuleset } = require('./lib/create-file');
const domainSorter = require('./lib/stable-sort-domain');
const { Sema } = require('async-sema');
const tldts = require('tldts');
const { task } = require('./lib/trace-runner');
const s = new Sema(2);
@ -39,7 +40,7 @@ const querySpeedtestApi = async (keyword) => {
/** @type {{ url: string }[]} */
const json = await res.json();
s.release();
return json.map(({ url }) => new URL(url).hostname);
return json.map(({ url }) => tldts.getHostname(url, { detectIp: false }));
} catch (e) {
s.release();
console.log(e);
@ -114,10 +115,12 @@ const buildSpeedtestDomainSet = task(__filename, async () => {
for (const hostnames of hostnameGroups) {
if (Array.isArray(hostnames)) {
for (const hostname of hostnames) {
if (hostname) {
domains.add(hostname);
}
}
}
}
const deduped = domainDeduper(Array.from(domains)).sort(domainSorter);
const description = [