mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Update Microsoft CDN
This commit is contained in:
parent
eeeadbc86b
commit
d56cf0e5e3
@ -5,13 +5,16 @@ import { SHARED_DESCRIPTION } from './lib/constants';
|
||||
import { createMemoizedPromise } from './lib/memo-promise';
|
||||
import { extractDomainsFromFelixDnsmasq } from './lib/parse-dnsmasq';
|
||||
import { RulesetOutput } from './lib/create-file';
|
||||
import { appendArrayInPlace } from './lib/append-array-in-place';
|
||||
|
||||
const PROBE_DOMAINS = ['.microsoft.com', '.windows.net', '.windows.com', '.windowsupdate.com', '.windowssearch.com', '.office.net'];
|
||||
|
||||
const WHITELIST = [
|
||||
'DOMAIN-SUFFIX,download.prss.microsoft.com',
|
||||
'DOMAIN,res.cdn.office.net'
|
||||
const DOMAINS = [
|
||||
'res.cdn.office.net',
|
||||
'res-1.cdn.office.net',
|
||||
'statics.teams.cdn.office.net'
|
||||
];
|
||||
const DOMAIN_SUFFIXES = ['download.prss.microsoft.com'];
|
||||
|
||||
const BLACKLIST = [
|
||||
'www.microsoft.com',
|
||||
@ -22,7 +25,7 @@ const BLACKLIST = [
|
||||
'windowsupdate.com'
|
||||
];
|
||||
|
||||
export const getMicrosoftCdnRulesetPromise = createMemoizedPromise(async () => {
|
||||
export const getMicrosoftCdnRulesetPromise = createMemoizedPromise<[domains: string[], domainSuffixes: string[]]>(async () => {
|
||||
// First trie is to find the microsoft domains that matches probe domains
|
||||
const trie = createTrie(null, false);
|
||||
for await (const line of await fetchRemoteTextByLine('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf')) {
|
||||
@ -37,9 +40,12 @@ export const getMicrosoftCdnRulesetPromise = createMemoizedPromise(async () => {
|
||||
const trie2 = createTrie(foundMicrosoftCdnDomains, true);
|
||||
BLACKLIST.forEach(trie2.whitelist);
|
||||
|
||||
return trie2.dump()
|
||||
.map(d => `DOMAIN-SUFFIX,${d}`)
|
||||
.concat(WHITELIST);
|
||||
const domains: string[] = DOMAINS;
|
||||
const domainSuffixes: string[] = DOMAIN_SUFFIXES;
|
||||
|
||||
appendArrayInPlace(domainSuffixes, trie2.dump());
|
||||
|
||||
return [domains, domainSuffixes] as const;
|
||||
});
|
||||
|
||||
export const buildMicrosoftCdn = task(require.main === module, __filename)(async (span) => {
|
||||
@ -52,11 +58,12 @@ export const buildMicrosoftCdn = task(require.main === module, __filename)(async
|
||||
' - https://github.com/felixonmars/dnsmasq-china-list'
|
||||
];
|
||||
|
||||
const res: string[] = await span.traceChildPromise('get microsoft cdn domains', getMicrosoftCdnRulesetPromise());
|
||||
const [domains, domainSuffixes] = await span.traceChildPromise('get microsoft cdn domains', getMicrosoftCdnRulesetPromise());
|
||||
|
||||
return new RulesetOutput(span, 'microsoft_cdn', 'non_ip')
|
||||
.withTitle('Sukka\'s Ruleset - Microsoft CDN')
|
||||
.withDescription(description)
|
||||
.addFromRuleset(res)
|
||||
.bulkAddDomain(domains)
|
||||
.bulkAddDomainSuffix(domainSuffixes)
|
||||
.write();
|
||||
});
|
||||
|
||||
@ -129,8 +129,18 @@ export const buildRejectDomainSet = task(require.main === module, __filename)(as
|
||||
}
|
||||
});
|
||||
|
||||
rejectOutput.calcDomainMap();
|
||||
rejectExtraOutput.calcDomainMap();
|
||||
await Promise.all([
|
||||
rejectOutput.done(),
|
||||
rejectExtraOutput.done()
|
||||
]);
|
||||
|
||||
span.traceChildSync(
|
||||
'build domain map for sort & collect stat',
|
||||
() => {
|
||||
rejectOutput.calcDomainMap();
|
||||
rejectExtraOutput.calcDomainMap();
|
||||
}
|
||||
);
|
||||
|
||||
// Create reject stats
|
||||
const rejectDomainsStats: string[] = span
|
||||
|
||||
@ -30,7 +30,7 @@ export const buildSSPanelUIMAppProfile = task(require.main === module, __filenam
|
||||
const [
|
||||
[domesticRules, directRules, lanRules],
|
||||
appleCdnDomains,
|
||||
microsoftCdnRules,
|
||||
[microsoftCdnDomains, microsoftCdnDomainSuffixes],
|
||||
appleCnRules,
|
||||
neteaseMusicRules,
|
||||
microsoftRules,
|
||||
@ -79,7 +79,8 @@ export const buildSSPanelUIMAppProfile = task(require.main === module, __filenam
|
||||
const domestic = new RulesetOutput(span, '_', 'non_ip')
|
||||
.addFromRuleset(domesticRules)
|
||||
.bulkAddDomainSuffix(appleCdnDomains)
|
||||
.addFromRuleset(microsoftCdnRules)
|
||||
.bulkAddDomain(microsoftCdnDomains)
|
||||
.bulkAddDomainSuffix(microsoftCdnDomainSuffixes)
|
||||
.addFromRuleset(appleCnRules)
|
||||
.addFromRuleset(neteaseMusicRules);
|
||||
|
||||
|
||||
@ -95,6 +95,13 @@ export abstract class RuleOutput {
|
||||
return this;
|
||||
}
|
||||
|
||||
bulkAddDomain(domains: string[]) {
|
||||
for (let i = 0, len = domains.length; i < len; i++) {
|
||||
this.addDomain(domains[i]);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
addDomainSuffix(domain: string) {
|
||||
this.domainTrie.add(domain[0] === '.' ? domain : '.' + domain);
|
||||
return this;
|
||||
|
||||
@ -443,10 +443,10 @@ shell.cdn.office.net
|
||||
cdn.forms.office.net
|
||||
cdn.graph.office.net
|
||||
.res.office365.com
|
||||
res.cdn.office.net
|
||||
res-1.cdn.office.net
|
||||
# res.cdn.office.net # china mainland cdn
|
||||
# res-1.cdn.office.net # china mainland cdn
|
||||
res-geo.cdn.office.net
|
||||
statics.teams.cdn.office.net
|
||||
# statics.teams.cdn.office.net # china mainland cdn
|
||||
static2.sharepointonline.com
|
||||
prod.msocdn.com
|
||||
spoprod-a.akamaihd.net
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user