Browse Source

Minor fixes

SukkaW 2 years ago
parent
commit
d80ea1ecd8
2 changed files with 11 additions and 3 deletions
  1. 6 1
      Build/build-internal-reverse-chn-cidr.js
  2. 5 2
      Build/build-speedtest-domainset.js

+ 6 - 1
Build/build-internal-reverse-chn-cidr.js

@@ -32,7 +32,12 @@ const buildInternalReverseChnCIDR = task(__filename, async () => {
   ]);
   ]);
 
 
   const reversedCidr = exclude(
   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),
     RESERVED_IPV4_CIDR.concat(cidr),
     true
     true
   );
   );

+ 5 - 2
Build/build-speedtest-domainset.js

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