瀏覽代碼

Perf: only acquire limited data from parse

SukkaW 3 年之前
父節點
當前提交
cd5525b560
共有 2 個文件被更改,包括 4 次插入8 次删除
  1. 2 6
      Build/build-phishing-domainset.js
  2. 2 2
      Build/validate-cdn-conf.js

+ 2 - 6
Build/build-phishing-domainset.js

@@ -54,13 +54,9 @@ const BLACK_TLD = Array.from(new Set([
 
 
     const domain = line.charCodeAt(0) === 46 ? line.slice(1) : line;
     const domain = line.charCodeAt(0) === 46 ? line.slice(1) : line;
 
 
-    if (line.length > 25) {
-      const parsed = tldts.parse(domain, { allowPrivateDomains: true });
+    if (domain.length > 25) {
+      const apexDomain = tldts.getDomain(domain, { allowPrivateDomains: true });
 
 
-      if (parsed.isIp || domain === parsed.publicSuffix) {
-        continue;
-      }
-      const apexDomain = parsed.domain;
       if (apexDomain) {
       if (apexDomain) {
         if (WHITELIST_DOMAIN.has(apexDomain)) {
         if (WHITELIST_DOMAIN.has(apexDomain)) {
           continue;
           continue;

+ 2 - 2
Build/validate-cdn-conf.js

@@ -28,7 +28,7 @@ const SPECIAL_SUFFIXES = new Set([
     }
     }
 
 
     const domain = line.charCodeAt(0) === 46 ? line.slice(1) : line;
     const domain = line.charCodeAt(0) === 46 ? line.slice(1) : line;
-    const parsed = tldts.parse(domain, { allowPrivateDomains: true });
+    const parsed = tldts.parse(domain, { allowPrivateDomains: true, detectIp: false });
 
 
     if (
     if (
       (
       (
@@ -58,7 +58,7 @@ const SPECIAL_SUFFIXES = new Set([
 
 
     if (line.startsWith('DOMAIN-SUFFIX')) {
     if (line.startsWith('DOMAIN-SUFFIX')) {
       const domain = line.slice(14);
       const domain = line.slice(14);
-      const parsed = tldts.parse(domain, { allowPrivateDomains: true });
+      const parsed = tldts.parse(domain, { allowPrivateDomains: true, detectIp: false });
 
 
       if (domain !== parsed.publicSuffix) {
       if (domain !== parsed.publicSuffix) {
         if (!SPECIAL_SUFFIXES.has(domain)) {
         if (!SPECIAL_SUFFIXES.has(domain)) {