瀏覽代碼

Refactor: Microsoft CDN Hosts

SukkaW 1 年之前
父節點
當前提交
7e560573a2
共有 1 個文件被更改,包括 4 次插入11 次删除
  1. 4 11
      Build/build-microsoft-cdn.ts

+ 4 - 11
Build/build-microsoft-cdn.ts

@@ -18,32 +18,25 @@ const DOMAIN_SUFFIXES = ['download.prss.microsoft.com'];
 
 const BLACKLIST = [
   'www.microsoft.com',
-  'learn.microsoft.com',
-  'devblogs.microsoft.com',
-  'docs.microsoft.com',
-  'developer.microsoft.com',
   'windowsupdate.com'
 ];
 
 export const getMicrosoftCdnRulesetPromise = createMemoizedPromise<[domains: string[], domainSuffixes: string[]]>(async () => {
   // First trie is to find the microsoft domains that matches probe domains
   const trie = new HostnameSmolTrie();
+
   for await (const line of await fetchRemoteTextByLine('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf')) {
     const domain = extractDomainsFromFelixDnsmasq(line);
     if (domain) {
       trie.add(domain);
     }
   }
-  const foundMicrosoftCdnDomains = PROBE_DOMAINS.flatMap(domain => trie.find(domain));
 
-  // Second trie is to remove blacklisted domains
-  const trie2 = new HostnameSmolTrie(foundMicrosoftCdnDomains);
-  BLACKLIST.forEach(black => trie2.whitelist(black));
+  // remove blacklist domain from trie, to prevent them from being included in the later dump
+  BLACKLIST.forEach(black => trie.whitelist(black));
 
   const domains: string[] = DOMAINS;
-  const domainSuffixes: string[] = DOMAIN_SUFFIXES;
-
-  appendArrayInPlace(domainSuffixes, trie2.dump());
+  const domainSuffixes = appendArrayInPlace(PROBE_DOMAINS.flatMap(domain => trie.find(domain)), DOMAIN_SUFFIXES);
 
   return [domains, domainSuffixes] as const;
 });