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