mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Refactor: Microsoft CDN Hosts
This commit is contained in:
parent
132bdb272a
commit
7e560573a2
@ -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;
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user