mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-21 13:50:29 +08:00
84 lines
3.6 KiB
JavaScript
84 lines
3.6 KiB
JavaScript
'use strict';const index=require('./index.B8Uk9n3v.cjs'),fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),trie=require('./trie.Vu1FNyv-.cjs'),base=require('./base.C13YY5P3.cjs'),memoPromise=require('./memo-promise.BbOsVeGo.cjs'),parseDnsmasq=require('./parse-dnsmasq.CiH7YJVY.cjs'),ruleset=require('./ruleset.iYH0XOC1.cjs');var buildMicrosoftCdn = {exports: {}};var hasRequiredBuildMicrosoftCdn;
|
|
|
|
function requireBuildMicrosoftCdn () {
|
|
if (hasRequiredBuildMicrosoftCdn) return buildMicrosoftCdn.exports;
|
|
hasRequiredBuildMicrosoftCdn = 1;
|
|
(function (module, exports) {
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
function _export(target, all) {
|
|
for(var name in all)Object.defineProperty(target, name, {
|
|
enumerable: true,
|
|
get: all[name]
|
|
});
|
|
}
|
|
_export(exports, {
|
|
buildMicrosoftCdn: function() {
|
|
return buildMicrosoftCdn;
|
|
},
|
|
getMicrosoftCdnRulesetPromise: function() {
|
|
return getMicrosoftCdnRulesetPromise;
|
|
}
|
|
});
|
|
const _trace = /*@__PURE__*/ index.r();
|
|
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
|
const _trie = /*@__PURE__*/ trie.r();
|
|
const _description = /*@__PURE__*/ base.r();
|
|
const _memopromise = /*@__PURE__*/ memoPromise.r();
|
|
const _parsednsmasq = /*@__PURE__*/ parseDnsmasq.r();
|
|
const _ruleset = /*@__PURE__*/ ruleset.r();
|
|
const _appendarrayinplace = /*@__PURE__*/ base.a();
|
|
const PROBE_DOMAINS = [
|
|
'.microsoft.com',
|
|
'.windows.net',
|
|
'.windows.com',
|
|
'.windowsupdate.com',
|
|
'.windowssearch.com',
|
|
'.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',
|
|
'windowsupdate.com'
|
|
];
|
|
const getMicrosoftCdnRulesetPromise = (0, _memopromise.createMemoizedPromise)(async ()=>{
|
|
// First trie is to find the microsoft domains that matches probe domains
|
|
const trie = new _trie.HostnameSmolTrie();
|
|
for await (const line of (await (0, _fetchtextbyline.fetchRemoteTextByLine)('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf'))){
|
|
const domain = (0, _parsednsmasq.extractDomainsFromFelixDnsmasq)(line);
|
|
if (domain) {
|
|
trie.add(domain);
|
|
}
|
|
}
|
|
// remove blacklist domain from trie, to prevent them from being included in the later dump
|
|
BLACKLIST.forEach((black)=>trie.whitelist(black));
|
|
const domains = DOMAINS;
|
|
const domainSuffixes = (0, _appendarrayinplace.appendArrayInPlace)(PROBE_DOMAINS.flatMap((domain)=>trie.find(domain)), DOMAIN_SUFFIXES);
|
|
return [
|
|
domains,
|
|
domainSuffixes
|
|
];
|
|
});
|
|
const buildMicrosoftCdn = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
|
const description = [
|
|
..._description.SHARED_DESCRIPTION,
|
|
'',
|
|
'This file contains Microsoft\'s domains using their China mainland CDN servers.',
|
|
'',
|
|
'Data from:',
|
|
' - https://github.com/felixonmars/dnsmasq-china-list'
|
|
];
|
|
const [domains, domainSuffixes] = await span.traceChildPromise('get microsoft cdn domains', getMicrosoftCdnRulesetPromise());
|
|
return new _ruleset.RulesetOutput(span, 'microsoft_cdn', 'non_ip').withTitle('Sukka\'s Ruleset - Microsoft CDN').withDescription(description).bulkAddDomain(domains).bulkAddDomainSuffix(domainSuffixes).write();
|
|
});
|
|
} (buildMicrosoftCdn, buildMicrosoftCdn.exports));
|
|
return buildMicrosoftCdn.exports;
|
|
}exports.r=requireBuildMicrosoftCdn; |