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