mirror of
https://github.com/SukkaW/Surge.git
synced 2026-03-17 08:26:52 +08:00
Chore: maintainance
This commit is contained in:
1145
Dist/chunks/base.C13YY5P3.cjs
Normal file
1145
Dist/chunks/base.C13YY5P3.cjs
Normal file
File diff suppressed because it is too large
Load Diff
45
Dist/chunks/build-apple-cdn.CNsnkTO_.cjs
Normal file
45
Dist/chunks/build-apple-cdn.CNsnkTO_.cjs
Normal file
@@ -0,0 +1,45 @@
|
||||
'use strict';const parseDnsmasq=require('./parse-dnsmasq.CiH7YJVY.cjs'),index=require('./index.B8Uk9n3v.cjs'),base=require('./base.C13YY5P3.cjs'),memoPromise=require('./memo-promise.BbOsVeGo.cjs'),domainset=require('./domainset.CSQfKAtf.cjs'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs');var buildAppleCdn = {exports: {}};var hasRequiredBuildAppleCdn;
|
||||
|
||||
function requireBuildAppleCdn () {
|
||||
if (hasRequiredBuildAppleCdn) return buildAppleCdn.exports;
|
||||
hasRequiredBuildAppleCdn = 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, {
|
||||
buildAppleCdn: function() {
|
||||
return buildAppleCdn;
|
||||
},
|
||||
getAppleCdnDomainsPromise: function() {
|
||||
return getAppleCdnDomainsPromise;
|
||||
}
|
||||
});
|
||||
const _parsednsmasq = /*@__PURE__*/ parseDnsmasq.r();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _memopromise = /*@__PURE__*/ memoPromise.r();
|
||||
const _domainset = /*@__PURE__*/ domainset.r();
|
||||
const _fetchretry = /*@__PURE__*/ fetchRetry.r();
|
||||
const getAppleCdnDomainsPromise = (0, _memopromise.createMemoizedPromise)(()=>(0, _fetchretry.$$fetch)('https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/apple.china.conf').then(_parsednsmasq.parseFelixDnsmasqFromResp));
|
||||
console.log({ module, main: require.main });
|
||||
const buildAppleCdn = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const res = await span.traceChildPromise('get apple cdn domains', getAppleCdnDomainsPromise());
|
||||
return new _domainset.DomainsetOutput(span, 'apple_cdn').withTitle('Sukka\'s Ruleset - Apple CDN').withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'This file contains Apple\'s domains using their China mainland CDN servers.',
|
||||
'',
|
||||
'Data from:',
|
||||
' - https://github.com/felixonmars/dnsmasq-china-list'
|
||||
]).bulkAddDomainSuffix(res).write();
|
||||
});
|
||||
} (buildAppleCdn, buildAppleCdn.exports));
|
||||
return buildAppleCdn.exports;
|
||||
}exports.r=requireBuildAppleCdn;
|
||||
86
Dist/chunks/build-cdn-download-conf.Dj0KZ2lm.cjs
Normal file
86
Dist/chunks/build-cdn-download-conf.Dj0KZ2lm.cjs
Normal file
@@ -0,0 +1,86 @@
|
||||
'use strict';const require$$0$1=require('node:path'),fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),trie=require('./trie.Vu1FNyv-.cjs'),index=require('./index.B8Uk9n3v.cjs'),base=require('./base.C13YY5P3.cjs'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),domainset=require('./domainset.CSQfKAtf.cjs'),rejectDataSource=require('./reject-data-source.DaKwvNlG.cjs'),require$$0=require('foxts/append-set-elements-to-array');var buildCdnDownloadConf = {exports: {}};var hasRequiredBuildCdnDownloadConf;
|
||||
|
||||
function requireBuildCdnDownloadConf () {
|
||||
if (hasRequiredBuildCdnDownloadConf) return buildCdnDownloadConf.exports;
|
||||
hasRequiredBuildCdnDownloadConf = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildCdnDownloadConf", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildCdnDownloadConf;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0$1);
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _trie = /*@__PURE__*/ trie.r();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _appendarrayinplace = /*@__PURE__*/ base.a();
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _domainset = /*@__PURE__*/ domainset.r();
|
||||
const _rejectdatasource = /*@__PURE__*/ rejectDataSource.r();
|
||||
const _appendsetelementstoarray = require$$0;
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const getS3OSSDomainsPromise = (async ()=>{
|
||||
const trie = new _trie.HostnameTrie();
|
||||
for await (const line of (await (0, _fetchtextbyline.fetchRemoteTextByLine)('https://publicsuffix.org/list/public_suffix_list.dat', true))){
|
||||
trie.add(line);
|
||||
}
|
||||
/**
|
||||
* Extract OSS domain from publicsuffix list
|
||||
*/ const S3OSSDomains = new Set();
|
||||
trie.find('.amazonaws.com').forEach((line)=>{
|
||||
if ((line.startsWith('s3-') || line.startsWith('s3.')) && !line.includes('cn-')) {
|
||||
S3OSSDomains.add('.' + line);
|
||||
}
|
||||
});
|
||||
trie.find('.scw.cloud').forEach((line)=>{
|
||||
if ((line.startsWith('s3-') || line.startsWith('s3.')) && !line.includes('cn-')) {
|
||||
S3OSSDomains.add('.' + line);
|
||||
}
|
||||
});
|
||||
trie.find('sakurastorage.jp').forEach((line)=>{
|
||||
if (line.startsWith('s3-') || line.startsWith('s3.')) {
|
||||
S3OSSDomains.add('.' + line);
|
||||
}
|
||||
});
|
||||
return S3OSSDomains;
|
||||
})();
|
||||
const cdnDomainsListPromise = (0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.SOURCE_DIR, 'domainset/cdn.conf'));
|
||||
const downloadDomainSetPromise = (0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.SOURCE_DIR, 'domainset/download.conf'));
|
||||
const steamDomainSetPromise = (0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.SOURCE_DIR, 'domainset/game-download.conf'));
|
||||
const buildCdnDownloadConf = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const [S3OSSDomains, cdnDomainsList, downloadDomainSet, steamDomainSet] = await Promise.all([
|
||||
getS3OSSDomainsPromise,
|
||||
cdnDomainsListPromise,
|
||||
downloadDomainSetPromise,
|
||||
steamDomainSetPromise
|
||||
]);
|
||||
// Move S3 domains to download domain set, since S3 files may be large
|
||||
(0, _appendsetelementstoarray.appendSetElementsToArray)(downloadDomainSet, S3OSSDomains);
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(downloadDomainSet, steamDomainSet);
|
||||
// we have whitelisted the crashlytics domain, and we also want to put it in CDN policy
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(cdnDomainsList, _rejectdatasource.CRASHLYTICS_WHITELIST);
|
||||
return Promise.all([
|
||||
new _domainset.DomainsetOutput(span, 'cdn').withTitle('Sukka\'s Ruleset - CDN Domains').withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'This file contains object storage and static assets CDN domains.'
|
||||
]).addFromDomainset(cdnDomainsList).write(),
|
||||
new _domainset.DomainsetOutput(span, 'download').withTitle('Sukka\'s Ruleset - Large Files Hosting Domains').withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'This file contains domains for software updating & large file hosting.'
|
||||
]).addFromDomainset(downloadDomainSet).write()
|
||||
]);
|
||||
});
|
||||
} (buildCdnDownloadConf, buildCdnDownloadConf.exports));
|
||||
return buildCdnDownloadConf.exports;
|
||||
}exports.r=requireBuildCdnDownloadConf;
|
||||
201
Dist/chunks/build-chn-cidr.BjyqKcvm.cjs
Normal file
201
Dist/chunks/build-chn-cidr.BjyqKcvm.cjs
Normal file
@@ -0,0 +1,201 @@
|
||||
'use strict';const fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),index=require('./index.B8Uk9n3v.cjs'),require$$2=require('fast-cidr-tools'),memoPromise=require('./memo-promise.BbOsVeGo.cjs'),base=require('./base.C13YY5P3.cjs'),fsMemo=require('./fs-memo.Dw823m02.cjs');var buildChnCidr = {exports: {}};var cidr = {};var hasRequiredCidr;
|
||||
|
||||
function requireCidr () {
|
||||
if (hasRequiredCidr) return cidr;
|
||||
hasRequiredCidr = 1;
|
||||
(function (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, {
|
||||
CN_CIDR_MISSING_IN_CHNROUTE: function() {
|
||||
return CN_CIDR_MISSING_IN_CHNROUTE;
|
||||
},
|
||||
NON_CN_CIDR_INCLUDED_IN_CHNROUTE: function() {
|
||||
return NON_CN_CIDR_INCLUDED_IN_CHNROUTE;
|
||||
},
|
||||
RESERVED_IPV4_CIDR: function() {
|
||||
return RESERVED_IPV4_CIDR;
|
||||
}
|
||||
});
|
||||
const RESERVED_IPV4_CIDR = [
|
||||
'0.0.0.0/8',
|
||||
'10.0.0.0/8',
|
||||
'100.64.0.0/10',
|
||||
'127.0.0.0/8',
|
||||
'169.254.0.0/16',
|
||||
'172.16.0.0/12',
|
||||
'192.0.0.0/24',
|
||||
'192.0.2.0/24',
|
||||
// 192.88.99.0 // is currently being broadcast by HE and Comcast
|
||||
'192.168.0.0/16',
|
||||
'198.18.0.0/15',
|
||||
'198.51.100.0/24',
|
||||
'203.0.113.0/24',
|
||||
'224.0.0.0/4',
|
||||
'233.252.0.0/24',
|
||||
'240.0.0.0/4'
|
||||
];
|
||||
const NON_CN_CIDR_INCLUDED_IN_CHNROUTE = [
|
||||
'223.118.0.0/15',
|
||||
'223.120.0.0/15'
|
||||
];
|
||||
const CN_CIDR_MISSING_IN_CHNROUTE = [
|
||||
// Baidu Public DNS
|
||||
'180.76.76.0/24',
|
||||
// Ali Public DNS
|
||||
'223.5.5.0/24',
|
||||
'223.6.6.0/24',
|
||||
// Tencent DNSPod Public DNS
|
||||
'119.29.29.0/24',
|
||||
'119.28.28.0/24',
|
||||
'120.53.53.0/24',
|
||||
'1.12.12.0/24',
|
||||
'1.12.34.0/24',
|
||||
// ByteDance Public DNS
|
||||
'180.184.1.0/24',
|
||||
'180.184.2.0/24',
|
||||
// 360 Public DNS
|
||||
'101.198.198.0/24',
|
||||
'101.198.199.0/24',
|
||||
// ChinaTelecom
|
||||
'103.7.141.0/24',
|
||||
// Aliyun Shenzhen
|
||||
'120.78.0.0/16',
|
||||
// wy.com.cn
|
||||
'211.99.96.0/19',
|
||||
// AS58593, Azure China
|
||||
'40.72.0.0/15',
|
||||
'42.159.0.0/16',
|
||||
'52.130.0.0/17',
|
||||
'52.131.0.0/16',
|
||||
'103.9.8.0/22',
|
||||
'139.217.0.0/16',
|
||||
'139.219.0.0/16',
|
||||
'143.64.0.0/16',
|
||||
'159.27.0.0/16',
|
||||
'163.228.0.0/16',
|
||||
// NetEase
|
||||
'223.252.194.0/24',
|
||||
'223.252.196.0/24',
|
||||
// Xiamen Kuaikuai
|
||||
'180.188.36.0/22' // no route globally
|
||||
];
|
||||
} (cidr));
|
||||
return cidr;
|
||||
}var ip = {};var hasRequiredIp;
|
||||
|
||||
function requireIp () {
|
||||
if (hasRequiredIp) return ip;
|
||||
hasRequiredIp = 1;
|
||||
(function (exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "IPListOutput", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return IPListOutput;
|
||||
}
|
||||
});
|
||||
const _clash = /*@__PURE__*/ base.c();
|
||||
const _singbox = /*@__PURE__*/ base.f();
|
||||
const _surge = /*@__PURE__*/ base.e();
|
||||
const _base = /*@__PURE__*/ base.b();
|
||||
class IPListOutput extends _base.FileOutput {
|
||||
clashUseRule;
|
||||
strategies;
|
||||
constructor(span, id, clashUseRule = true){
|
||||
super(span, id), this.clashUseRule = clashUseRule;
|
||||
this.strategies = [
|
||||
new _surge.SurgeRuleSet('ip'),
|
||||
this.clashUseRule ? new _clash.ClashClassicRuleSet('ip') : new _clash.ClashIPSet(),
|
||||
new _singbox.SingboxSource('ip')
|
||||
];
|
||||
}
|
||||
}
|
||||
} (ip));
|
||||
return ip;
|
||||
}var hasRequiredBuildChnCidr;
|
||||
|
||||
function requireBuildChnCidr () {
|
||||
if (hasRequiredBuildChnCidr) return buildChnCidr.exports;
|
||||
hasRequiredBuildChnCidr = 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, {
|
||||
buildChnCidr: function() {
|
||||
return buildChnCidr;
|
||||
},
|
||||
getChnCidrPromise: function() {
|
||||
return getChnCidrPromise;
|
||||
}
|
||||
});
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _fastcidrtools = require$$2;
|
||||
const _memopromise = /*@__PURE__*/ memoPromise.r();
|
||||
const _cidr = /*@__PURE__*/ requireCidr();
|
||||
const _appendarrayinplace = /*@__PURE__*/ base.a();
|
||||
const _ip = /*@__PURE__*/ requireIp();
|
||||
const _fsmemo = /*@__PURE__*/ fsMemo.r();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const PROBE_CHN_CIDR_V4 = [
|
||||
// NetEase Hangzhou
|
||||
'223.252.196.38',
|
||||
// Aliyun ShenZhen
|
||||
'120.78.92.171'
|
||||
];
|
||||
const getChnCidrPromise = (0, _memopromise.createMemoizedPromise)((0, _fsmemo.cachedOnlyFail)(async function getChnCidr() {
|
||||
const [_cidr4, cidr6] = await Promise.all([
|
||||
(0, _fetchtextbyline.fetchRemoteTextByLine)('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt', true).then(Array.fromAsync),
|
||||
(0, _fetchtextbyline.fetchRemoteTextByLine)('https://gaoyifan.github.io/china-operator-ip/china6.txt', true).then(Array.fromAsync)
|
||||
]);
|
||||
const cidr4 = (0, _fastcidrtools.exclude)((0, _appendarrayinplace.appendArrayInPlace)(_cidr4, _cidr.CN_CIDR_MISSING_IN_CHNROUTE), _cidr.NON_CN_CIDR_INCLUDED_IN_CHNROUTE, true);
|
||||
for (const probeIp of PROBE_CHN_CIDR_V4){
|
||||
if (!(0, _fastcidrtools.contains)(cidr4, PROBE_CHN_CIDR_V4)) {
|
||||
const err = new TypeError('chnroutes missing probe IP');
|
||||
err.cause = probeIp;
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
return [
|
||||
cidr4,
|
||||
cidr6
|
||||
];
|
||||
}, {
|
||||
serializer: JSON.stringify,
|
||||
deserializer: JSON.parse
|
||||
}));
|
||||
const buildChnCidr = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const [filteredCidr4, cidr6] = await span.traceChildAsync('download chnroutes2', getChnCidrPromise);
|
||||
// Can not use SHARED_DESCRIPTION here as different license
|
||||
const description = (0, _description.createFileDescription)('CC BY-SA 2.0');
|
||||
return Promise.all([
|
||||
new _ip.IPListOutput(span, 'china_ip', false).withTitle('Sukka\'s Ruleset - Mainland China IPv4 CIDR').withDescription([
|
||||
...description,
|
||||
'Data from https://misaka.io (misakaio @ GitHub)'
|
||||
]).bulkAddCIDR4(filteredCidr4).write(),
|
||||
new _ip.IPListOutput(span, 'china_ip_ipv6', false).withTitle('Sukka\'s Ruleset - Mainland China IPv6 CIDR').withDescription([
|
||||
...description,
|
||||
'Data from https://github.com/gaoyifan/china-operator-ip'
|
||||
]).bulkAddCIDR6(cidr6).write()
|
||||
]);
|
||||
});
|
||||
} (buildChnCidr, buildChnCidr.exports));
|
||||
return buildChnCidr.exports;
|
||||
}exports.r=requireBuildChnCidr;
|
||||
74
Dist/chunks/build-cloudmounter-rules.RMp-w3JV.cjs
Normal file
74
Dist/chunks/build-cloudmounter-rules.RMp-w3JV.cjs
Normal file
@@ -0,0 +1,74 @@
|
||||
'use strict';const base=require('./base.C13YY5P3.cjs'),index=require('./index.B8Uk9n3v.cjs'),ruleset=require('./ruleset.iYH0XOC1.cjs');var buildCloudmounterRules = {exports: {}};var cloudmounter = {};var hasRequiredCloudmounter;
|
||||
|
||||
function requireCloudmounter () {
|
||||
if (hasRequiredCloudmounter) return cloudmounter;
|
||||
hasRequiredCloudmounter = 1;
|
||||
(function (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, {
|
||||
DOMAINS: function() {
|
||||
return DOMAINS;
|
||||
},
|
||||
PROCESS_NAMES: function() {
|
||||
return PROCESS_NAMES;
|
||||
}
|
||||
});
|
||||
const DOMAINS = [
|
||||
'DOMAIN-SUFFIX,sharepoint.com',
|
||||
'DOMAIN-SUFFIX,graph.microsoft.com',
|
||||
'DOMAIN,www.googleapis.com',
|
||||
'DOMAIN,api.onedrive.com',
|
||||
'DOMAIN-SUFFIX,storage.live.com',
|
||||
'DOMAIN-SUFFIX,files.1drv.com',
|
||||
'DOMAIN-SUFFIX,my.microsoftpersonalcontent.com',
|
||||
'DOMAIN-WILDCARD,*-medi*.svc.ms'
|
||||
];
|
||||
const PROCESS_NAMES = [
|
||||
'*CloudMounter'
|
||||
];
|
||||
} (cloudmounter));
|
||||
return cloudmounter;
|
||||
}var hasRequiredBuildCloudmounterRules;
|
||||
|
||||
function requireBuildCloudmounterRules () {
|
||||
if (hasRequiredBuildCloudmounterRules) return buildCloudmounterRules.exports;
|
||||
hasRequiredBuildCloudmounterRules = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildCloudMounterRules", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildCloudMounterRules;
|
||||
}
|
||||
});
|
||||
const _cloudmounter = /*@__PURE__*/ requireCloudmounter();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _ruleset = /*@__PURE__*/ ruleset.r();
|
||||
const buildCloudMounterRules = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
// AND,((SRC-IP,192.168.1.110), (DOMAIN, example.com))
|
||||
const results = _cloudmounter.DOMAINS.flatMap((domain)=>_cloudmounter.PROCESS_NAMES.flatMap((process)=>[
|
||||
`AND,((${domain}),(PROCESS-NAME,${process}))`,
|
||||
...[
|
||||
'10.0.0.0/8',
|
||||
// '127.0.0.0/8',
|
||||
'172.16.0.0/12',
|
||||
'192.168.0.0/16'
|
||||
].map((cidr)=>`AND,((${domain}),(SRC-IP,${cidr}))`)
|
||||
]));
|
||||
const description = _description.SHARED_DESCRIPTION;
|
||||
return new _ruleset.RulesetOutput(span, 'cloudmounter', 'non_ip').withTitle('Sukka\'s Ruleset - CloudMounter / RaiDrive').withDescription(description).addFromRuleset(results).write();
|
||||
});
|
||||
} (buildCloudmounterRules, buildCloudmounterRules.exports));
|
||||
return buildCloudmounterRules.exports;
|
||||
}exports.r=requireBuildCloudmounterRules;
|
||||
161
Dist/chunks/build-common.DBhs-fKR.cjs
Normal file
161
Dist/chunks/build-common.DBhs-fKR.cjs
Normal file
@@ -0,0 +1,161 @@
|
||||
'use strict';const require$$0=require('node:path'),fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),index=require('./index.B8Uk9n3v.cjs'),base=require('./base.C13YY5P3.cjs'),require$$5=require('fdir'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),domainset=require('./domainset.CSQfKAtf.cjs'),ruleset=require('./ruleset.iYH0XOC1.cjs');var buildCommon = {exports: {}};var hasRequiredBuildCommon;
|
||||
|
||||
function requireBuildCommon () {
|
||||
if (hasRequiredBuildCommon) return buildCommon.exports;
|
||||
hasRequiredBuildCommon = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildCommon", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildCommon;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require$$0);
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _processline = /*@__PURE__*/ fetchTextByLine.r();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _fdir = require$$5;
|
||||
const _appendarrayinplace = /*@__PURE__*/ base.a();
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _domainset = /*@__PURE__*/ domainset.r();
|
||||
const _ruleset = /*@__PURE__*/ ruleset.r();
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function(nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interop_require_wildcard(obj, nodeInterop) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {
|
||||
__proto__: null
|
||||
};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
const MAGIC_COMMAND_SKIP = '# $ custom_build_script';
|
||||
const MAGIC_COMMAND_TITLE = '# $ meta_title ';
|
||||
const MAGIC_COMMAND_DESCRIPTION = '# $ meta_description ';
|
||||
const MAGIC_COMMAND_SGMODULE_MITM_HOSTNAMES = '# $ sgmodule_mitm_hostnames ';
|
||||
const clawSourceDirPromise = new _fdir.fdir().withRelativePaths().filter((filepath, isDirectory)=>{
|
||||
if (isDirectory) return true;
|
||||
const extname = _nodepath.extname(filepath);
|
||||
return !(extname === '.js' || extname === '.ts');
|
||||
}).crawl(_dir.SOURCE_DIR).withPromise();
|
||||
const buildCommon = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const promises = [];
|
||||
const paths = await clawSourceDirPromise;
|
||||
for(let i = 0, len = paths.length; i < len; i++){
|
||||
const relativePath = paths[i];
|
||||
const fullPath = _dir.SOURCE_DIR + _nodepath.sep + relativePath;
|
||||
// if (
|
||||
// relativePath.startsWith('ip/')
|
||||
// || relativePath.startsWith('non_ip/')
|
||||
// ) {
|
||||
promises.push(transform(span, fullPath, relativePath));
|
||||
// continue;
|
||||
// }
|
||||
// console.error(picocolors.red(`[build-comman] Unknown file: ${relativePath}`));
|
||||
}
|
||||
return Promise.all(promises);
|
||||
});
|
||||
const $skip = Symbol('skip');
|
||||
function processFile(span, sourcePath) {
|
||||
return span.traceChildAsync(`process file: ${sourcePath}`, async ()=>{
|
||||
const lines = [];
|
||||
let title = '';
|
||||
const descriptions = [];
|
||||
let sgmodulePathname = null;
|
||||
try {
|
||||
for await (const line of (0, _fetchtextbyline.readFileByLine)(sourcePath)){
|
||||
if (line.startsWith(MAGIC_COMMAND_SKIP)) {
|
||||
return $skip;
|
||||
}
|
||||
if (line.startsWith(MAGIC_COMMAND_TITLE)) {
|
||||
title = line.slice(MAGIC_COMMAND_TITLE.length).trim();
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith(MAGIC_COMMAND_DESCRIPTION)) {
|
||||
descriptions.push(line.slice(MAGIC_COMMAND_DESCRIPTION.length).trim());
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith(MAGIC_COMMAND_SGMODULE_MITM_HOSTNAMES)) {
|
||||
sgmodulePathname = line.slice(MAGIC_COMMAND_SGMODULE_MITM_HOSTNAMES.length).trim();
|
||||
continue;
|
||||
}
|
||||
const l = (0, _processline.processLine)(line);
|
||||
if (l) {
|
||||
lines.push(l);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error processing', sourcePath);
|
||||
console.trace(e);
|
||||
}
|
||||
return [
|
||||
title,
|
||||
descriptions,
|
||||
lines,
|
||||
sgmodulePathname
|
||||
];
|
||||
});
|
||||
}
|
||||
async function transform(parentSpan, sourcePath, relativePath) {
|
||||
const extname = _nodepath.extname(sourcePath);
|
||||
const id = _nodepath.basename(sourcePath, extname);
|
||||
return parentSpan.traceChild(`transform ruleset: ${id}`).traceAsyncFn(async (span)=>{
|
||||
const type = relativePath.split(_nodepath.sep)[0];
|
||||
if (type !== 'ip' && type !== 'non_ip' && type !== 'domainset') {
|
||||
throw new TypeError(`Invalid type: ${type}`);
|
||||
}
|
||||
const res = await processFile(span, sourcePath);
|
||||
if (res === $skip) return;
|
||||
const [title, descriptions, lines, sgmoduleName] = res;
|
||||
let finalDescriptions;
|
||||
if (descriptions.length) {
|
||||
finalDescriptions = _description.SHARED_DESCRIPTION.slice();
|
||||
finalDescriptions.push('');
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(finalDescriptions, descriptions);
|
||||
} else {
|
||||
finalDescriptions = _description.SHARED_DESCRIPTION;
|
||||
}
|
||||
if (type === 'domainset') {
|
||||
return new _domainset.DomainsetOutput(span, id).withTitle(title).withDescription(finalDescriptions).addFromDomainset(lines).write();
|
||||
}
|
||||
return new _ruleset.RulesetOutput(span, id, type).withTitle(title).withDescription(finalDescriptions).withMitmSgmodulePath(sgmoduleName).addFromRuleset(lines).write();
|
||||
});
|
||||
}
|
||||
} (buildCommon, buildCommon.exports));
|
||||
return buildCommon.exports;
|
||||
}exports.r=requireBuildCommon;
|
||||
67
Dist/chunks/build-deprecate-files.BeL0QUfk.cjs
Normal file
67
Dist/chunks/build-deprecate-files.BeL0QUfk.cjs
Normal file
@@ -0,0 +1,67 @@
|
||||
'use strict';const fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),createFile=require('./create-file.loOMbJEN.cjs'),index=require('./index.B8Uk9n3v.cjs'),require$$0=require('node:path'),require$$2=require('node:fs/promises');var buildDeprecateFiles = {exports: {}};var hasRequiredBuildDeprecateFiles;
|
||||
|
||||
function requireBuildDeprecateFiles () {
|
||||
if (hasRequiredBuildDeprecateFiles) return buildDeprecateFiles.exports;
|
||||
hasRequiredBuildDeprecateFiles = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildDeprecateFiles", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildDeprecateFiles;
|
||||
}
|
||||
});
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _createfile = /*@__PURE__*/ createFile.r();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _promises = /*#__PURE__*/ _interop_require_default(require$$2);
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const DEPRECATED_FILES = [
|
||||
[
|
||||
'non_ip/global_plus',
|
||||
'This file has been merged with non_ip/global'
|
||||
],
|
||||
[
|
||||
'domainset/reject_sukka',
|
||||
'This file has been merged with domainset/reject'
|
||||
],
|
||||
[
|
||||
'domainset/reject_phishing',
|
||||
'This file has been merged with domainset/reject'
|
||||
]
|
||||
];
|
||||
const REMOVED_FILES = [
|
||||
'Internal/cdn.txt',
|
||||
'List/internal/appprofile.php',
|
||||
'Clash/domainset/steam.txt',
|
||||
'Clash/non_ip/clash_fake_ip_filter.txt',
|
||||
'sing-box/domainset/steam.json',
|
||||
'Modules/sukka_unlock_abema.sgmodule',
|
||||
'Modules/sukka_exclude_reservered_ip.sgmodule'
|
||||
];
|
||||
const buildDeprecateFiles = (0, _trace.task)(require.main === module, __filename)((span)=>span.traceChildAsync('create deprecated files', async (childSpan)=>{
|
||||
const promises = REMOVED_FILES.map((f)=>_promises.default.rm(_nodepath.default.join(_dir.PUBLIC_DIR, f), {
|
||||
force: true,
|
||||
recursive: true
|
||||
}));
|
||||
for (const [filePath, description] of DEPRECATED_FILES){
|
||||
const content = [
|
||||
'#########################################',
|
||||
'# Sukka\'s Ruleset - Deprecated',
|
||||
`# ${description}`,
|
||||
'################## EOF ##################'
|
||||
];
|
||||
promises.push((0, _createfile.compareAndWriteFile)(childSpan, content, _nodepath.default.resolve(_dir.OUTPUT_SURGE_DIR, `${filePath}.conf`)), (0, _createfile.compareAndWriteFile)(childSpan, content, _nodepath.default.resolve(_dir.OUTPUT_CLASH_DIR, `${filePath}.txt`)));
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}));
|
||||
} (buildDeprecateFiles, buildDeprecateFiles.exports));
|
||||
return buildDeprecateFiles.exports;
|
||||
}exports.r=requireBuildDeprecateFiles;
|
||||
@@ -0,0 +1,887 @@
|
||||
'use strict';const require$$0=require('node:path'),fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),createFile=require('./create-file.loOMbJEN.cjs'),index=require('./index.B8Uk9n3v.cjs'),base=require('./base.C13YY5P3.cjs'),memoPromise=require('./memo-promise.BbOsVeGo.cjs'),require$$8=require('yaml'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),ruleset=require('./ruleset.iYH0XOC1.cjs');var buildDomesticDirectLanRulesetDnsMappingModule = {exports: {}};var domestic = {};var hasRequiredDomestic;
|
||||
|
||||
function requireDomestic () {
|
||||
if (hasRequiredDomestic) return domestic;
|
||||
hasRequiredDomestic = 1;
|
||||
(function (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, {
|
||||
AdGuardHomeDNSMapping: function() {
|
||||
return AdGuardHomeDNSMapping;
|
||||
},
|
||||
DOH_BOOTSTRAP: function() {
|
||||
return DOH_BOOTSTRAP;
|
||||
},
|
||||
DOMESTICS: function() {
|
||||
return DOMESTICS;
|
||||
}
|
||||
});
|
||||
const DOMESTICS = {
|
||||
ALIBABA: {
|
||||
hosts: {},
|
||||
dns: 'quic://dns.alidns.com:853',
|
||||
realip: false,
|
||||
ruleset: true,
|
||||
domains: [
|
||||
'uc.cn',
|
||||
// 'ucweb.com', // UC International
|
||||
'alibaba.com',
|
||||
'+alicdn.com',
|
||||
'+ialicdn.com',
|
||||
'+myalicdn.com',
|
||||
'+alidns.com',
|
||||
'+aliimg.com',
|
||||
'aliyun.com',
|
||||
'+aliyuncs.com',
|
||||
'+alikunlun.com',
|
||||
'+alikunlun.net',
|
||||
'+cdngslb.com',
|
||||
'alipay.com',
|
||||
'alipay.cn',
|
||||
'alipay.com.cn',
|
||||
'+alipayobjects.com',
|
||||
'alibaba-inc.com',
|
||||
'+alibabausercontent.com',
|
||||
'+alibabadns.com',
|
||||
'alibabachengdun.com',
|
||||
'alicloudccp.com',
|
||||
'alipan.com',
|
||||
'aliyundrive.com',
|
||||
'aliyundrive.net',
|
||||
'cainiao.com',
|
||||
'cainiao.com.cn',
|
||||
'cainiaoyizhan.com',
|
||||
'guoguo-app.com',
|
||||
'etao.com',
|
||||
'yitao.com',
|
||||
'1688.com',
|
||||
'amap.com',
|
||||
'gaode.com',
|
||||
'autonavi.com',
|
||||
'dingtalk.com',
|
||||
'mxhichina.com',
|
||||
'soku.com',
|
||||
'tb.cn',
|
||||
'taobao.com',
|
||||
'+taobaocdn.com',
|
||||
'+tbcache.com',
|
||||
'tmall.com',
|
||||
// 'tmall.hk',
|
||||
'goofish.com',
|
||||
'xiami.com',
|
||||
'xiami.net',
|
||||
'+ykimg.com',
|
||||
'youku.com',
|
||||
'tudou.com',
|
||||
'+cibntv.net',
|
||||
'ele.me',
|
||||
'+elemecdn.com',
|
||||
'feizhu.com',
|
||||
'taopiaopiao.com',
|
||||
'fliggy.com',
|
||||
'koubei.com',
|
||||
'mybank.cn',
|
||||
'mmstat.com',
|
||||
'uczzd.cn',
|
||||
'iconfont.cn',
|
||||
'freshhema.com',
|
||||
'hemamax.com',
|
||||
'hemaos.com',
|
||||
'hemashare.cn',
|
||||
'shyhhema.com',
|
||||
'sm.cn',
|
||||
'npmmirror.com',
|
||||
'alios.cn',
|
||||
'wandoujia.com',
|
||||
'aligames.com',
|
||||
'25pp.com',
|
||||
'+aliapp.org',
|
||||
'tanx.com',
|
||||
'hellobike.com',
|
||||
'+hichina.com',
|
||||
'+yunos.com',
|
||||
// Bilibili Aliyun CDN
|
||||
'$upos-sz-mirrorali.bilivideo.com',
|
||||
'$upos-sz-estgoss.bilivideo.com'
|
||||
]
|
||||
},
|
||||
TENCENT: {
|
||||
hosts: {},
|
||||
dns: 'https://doh.pub/dns-query',
|
||||
realip: false,
|
||||
ruleset: true,
|
||||
domains: [
|
||||
// 'dns.pub',
|
||||
// 'doh.pub',
|
||||
// 'dot.pub',
|
||||
'+qcloud.com',
|
||||
'+gtimg.cn',
|
||||
'+gtimg.com',
|
||||
'+gtimg.com.cn',
|
||||
'+gdtimg.com',
|
||||
'+idqqimg.com',
|
||||
'+udqqimg.com',
|
||||
'+igamecj.com',
|
||||
'myapp.com',
|
||||
'+myqcloud.com',
|
||||
'dnspod.com',
|
||||
'+qpic.cn',
|
||||
'+qlogo.cn',
|
||||
'qq.com',
|
||||
'qq.com.cn',
|
||||
// 'qq.wang',
|
||||
// 'qqmail.cn', // not owned by QQ, is sold on hichina.com
|
||||
'+qqmail.com',
|
||||
'qzone.com',
|
||||
'+tencent-cloud.net',
|
||||
'+tencent-cloud.com',
|
||||
'tencent.com',
|
||||
'tencent.com.cn',
|
||||
'tencentmusic.com',
|
||||
'weixinbridge.com',
|
||||
'weixin.com',
|
||||
// 'wechat.com', exclude `sgshort.wechat.com`
|
||||
'weiyun.com',
|
||||
'soso.com',
|
||||
'sogo.com',
|
||||
'sogou.com',
|
||||
'+sogoucdn.com',
|
||||
'+roblox.cn',
|
||||
'robloxdev.cn',
|
||||
'wegame.com',
|
||||
'wegame.com.cn',
|
||||
'wegameplus.com',
|
||||
'cdn-go.cn',
|
||||
'+tencentcs.cn',
|
||||
'+qcloudimg.com',
|
||||
'dnspod.cn',
|
||||
'anticheatexpert.com',
|
||||
'$url.cn',
|
||||
'+qlivecdn.com',
|
||||
'+tcdnlive.com',
|
||||
'+dnsv1.com',
|
||||
'+smtcdns.net',
|
||||
'coding.net',
|
||||
'+codehub.cn'
|
||||
]
|
||||
},
|
||||
BILIBILI: {
|
||||
dns: 'https://doh.pub/dns-query',
|
||||
hosts: {},
|
||||
realip: false,
|
||||
ruleset: true,
|
||||
domains: [
|
||||
// '$upos-sz-mirrorcoso1.bilivideo.com', // already included in bilivideo.com
|
||||
// '$upos-sz-estgcos.bilivideo.com', // already included in bilivideo.com, tencent cloud cdn
|
||||
'$acg.tv',
|
||||
'$b23.tv',
|
||||
'bilibili.cn',
|
||||
'bilibili.com',
|
||||
// 'bilibili.tv',
|
||||
'+acgvideo.com',
|
||||
'+bilivideo.com',
|
||||
'+bilivideo.cn',
|
||||
'+bilivideo.net',
|
||||
'+hdslb.com',
|
||||
'+biliimg.com',
|
||||
'+biliapi.com',
|
||||
'+biliapi.net',
|
||||
// 'biligame.cn', // not owned by bilibili, was put on sale by ename
|
||||
'biligame.com',
|
||||
'+biligame.net',
|
||||
'bilicomic.com',
|
||||
'bilicomics.com',
|
||||
// 'bilibilipay.cn', // not owned by bilibili
|
||||
// 'bilibilipay.com', // not owned by bilibili
|
||||
'+bilicdn1.com'
|
||||
]
|
||||
},
|
||||
XIAOMI: {
|
||||
dns: 'https://doh.pub/dns-query',
|
||||
hosts: {},
|
||||
realip: false,
|
||||
ruleset: true,
|
||||
domains: [
|
||||
'mi.com',
|
||||
'duokan.com',
|
||||
'+mi-img.com',
|
||||
'+mi-idc.com',
|
||||
'+xiaoaisound.com',
|
||||
'+xiaomixiaoai.com',
|
||||
'+mi-fds.com',
|
||||
'+mifile.cn',
|
||||
'+mijia.tech',
|
||||
'miui.com',
|
||||
'xiaomi.com',
|
||||
'xiaomi.cn',
|
||||
'xiaomi.net',
|
||||
'xiaomiev.com',
|
||||
'xiaomiyoupin.com'
|
||||
]
|
||||
},
|
||||
BYTEDANCE: {
|
||||
dns: '180.184.2.2',
|
||||
hosts: {},
|
||||
realip: false,
|
||||
ruleset: true,
|
||||
domains: [
|
||||
'bytedance.com',
|
||||
'+bytecdn.cn',
|
||||
'+volccdn.com',
|
||||
'+toutiaoimg.com',
|
||||
'+toutiaoimg.cn',
|
||||
'+toutiaostatic.com',
|
||||
'+toutiaovod.com',
|
||||
'+toutiaocloud.com',
|
||||
'toutiaopage.com',
|
||||
'feiliao.com',
|
||||
'iesdouyin.com',
|
||||
'+pstatp.com',
|
||||
'snssdk.com',
|
||||
'+bytegoofy.com',
|
||||
'toutiao.com',
|
||||
'feishu.cn',
|
||||
'feishu.net',
|
||||
'+feishucdn.com',
|
||||
'+feishupkg.com',
|
||||
'douyin.com',
|
||||
'+douyinpic.com',
|
||||
'+douyinstatic.com',
|
||||
'+douyincdn.com',
|
||||
'+douyinliving.com',
|
||||
'+douyinvod.com',
|
||||
'huoshan.com',
|
||||
'+huoshanstatic.com',
|
||||
'huoshanzhibo.com',
|
||||
'ixigua.com',
|
||||
'+ixiguavideo.com',
|
||||
'+ixgvideo.com',
|
||||
'+volccdn.com',
|
||||
'+byted-static.com',
|
||||
'volces.com',
|
||||
'baike.com',
|
||||
'+zjcdn.com',
|
||||
'+zijieapi.com',
|
||||
'feelgood.cn',
|
||||
'+bytetcc.com',
|
||||
'+bytednsdoc.com',
|
||||
'+byteimg.com',
|
||||
'+byteacctimg.com',
|
||||
'+ibytedapm.com',
|
||||
'oceanengine.com',
|
||||
'+edge-byted.com',
|
||||
'+volcvideo.com'
|
||||
]
|
||||
},
|
||||
BAIDU: {
|
||||
dns: '180.76.76.76',
|
||||
hosts: {},
|
||||
realip: false,
|
||||
ruleset: true,
|
||||
domains: [
|
||||
'91.com',
|
||||
'hao123.com',
|
||||
'baidu.cn',
|
||||
'baidu.com',
|
||||
'iqiyi.com',
|
||||
'+iqiyipic.com',
|
||||
'+baidubce.com',
|
||||
'+bcelive.com',
|
||||
'+baiducontent.com',
|
||||
'+baidustatic.com',
|
||||
'+bdstatic.com',
|
||||
'+bdimg.com',
|
||||
'+bcebos.com',
|
||||
'+baidupcs.com',
|
||||
'+baidubcr.com',
|
||||
'+yunjiasu-cdn.net',
|
||||
'tieba.com',
|
||||
'xiaodutv.com',
|
||||
'+shifen.com',
|
||||
'+jomodns.com',
|
||||
'+bdydns.com',
|
||||
'+jomoxc.com',
|
||||
'+duapp.com',
|
||||
'+antpcdn.com',
|
||||
// Bilibili Baidu CDN
|
||||
'$upos-sz-mirrorbd.bilivideo.com',
|
||||
'$upos-sz-mirrorbos.bilivideo.com'
|
||||
]
|
||||
},
|
||||
QIHOO360: {
|
||||
hosts: {},
|
||||
dns: 'https://doh.360.cn/dns-query',
|
||||
realip: false,
|
||||
ruleset: true,
|
||||
domains: [
|
||||
'+qhimg.com',
|
||||
'+qhimgs.com',
|
||||
'+qhimgs?.com',
|
||||
// '+qhimgs0.com',
|
||||
// '+qhimgs1.com',
|
||||
// '+qhimgs2.com',
|
||||
// '+qhimgs3.com',
|
||||
// '+qhimgs4.com',
|
||||
// '+qhimgs5.com',
|
||||
// '+qhimgs6.com',
|
||||
'+qhres.com',
|
||||
'+qhres2.com',
|
||||
'+qhmsg.com',
|
||||
'+qhstatic.com',
|
||||
'+qhupdate.com',
|
||||
'+qihucdn.com',
|
||||
'360.com',
|
||||
'360.cn',
|
||||
'360.net',
|
||||
'360safe.com',
|
||||
'+360tpcdn.com',
|
||||
'360os.com',
|
||||
'+360webcache.com',
|
||||
'360kuai.com',
|
||||
'so.com',
|
||||
'haosou.com',
|
||||
'yunpan.cn',
|
||||
'yunpan.com',
|
||||
'yunpan.com.cn',
|
||||
'+qh-cdn.com',
|
||||
'baomitu.com',
|
||||
'qiku.com'
|
||||
]
|
||||
}
|
||||
};
|
||||
const DOH_BOOTSTRAP = {
|
||||
ALIBABA: {
|
||||
hosts: {
|
||||
'dns.alidns.com': [
|
||||
'223.5.5.5',
|
||||
'223.6.6.6',
|
||||
'2400:3200:baba::1',
|
||||
'2400:3200::1'
|
||||
]
|
||||
},
|
||||
realip: false,
|
||||
ruleset: false,
|
||||
dns: 'quic://223.5.5.5:853',
|
||||
domains: [
|
||||
'$dns.alidns.com'
|
||||
]
|
||||
},
|
||||
DNSPOD: {
|
||||
hosts: {
|
||||
// 'dot.pub': ['120.53.53.53', '1.12.12.12'],
|
||||
'doh.pub': [
|
||||
'120.53.53.53',
|
||||
'1.12.12.12'
|
||||
]
|
||||
},
|
||||
realip: false,
|
||||
ruleset: false,
|
||||
dns: 'https://1.12.12.12/dns-query',
|
||||
domains: [
|
||||
// '$dot.pub',
|
||||
'$doh.pub'
|
||||
]
|
||||
},
|
||||
QIHOO360: {
|
||||
hosts: {
|
||||
},
|
||||
realip: false,
|
||||
ruleset: false,
|
||||
// Surge only supports UDP 53 or Hosts as the bootstrap server of domain DoH
|
||||
dns: '101.198.198.198',
|
||||
domains: [
|
||||
// '$dns.360.cn',
|
||||
// '$dot.360.cn',
|
||||
'$doh.360.cn'
|
||||
]
|
||||
}
|
||||
};
|
||||
const AdGuardHomeDNSMapping = {
|
||||
system: [
|
||||
'udp://10.10.1.1:53'
|
||||
],
|
||||
'https://doh.pub/dns-query': [
|
||||
'tls://1.12.12.12',
|
||||
'tls://120.53.53.53',
|
||||
'https://1.12.12.12/dns-query',
|
||||
'https://120.53.53.53/dns-query'
|
||||
],
|
||||
'quic://dns.alidns.com:853': [
|
||||
'quic://223.5.5.5',
|
||||
'quic://223.6.6.6',
|
||||
'h3://223.5.5.5/dns-query',
|
||||
'h3://223.6.6.6/dns-query'
|
||||
],
|
||||
'https://doh.360.cn/dns-query': [
|
||||
'https://doh.360.cn/dns-query',
|
||||
'tls://dot.360.cn'
|
||||
],
|
||||
'180.76.76.76': [
|
||||
'udp://180.76.76.76'
|
||||
],
|
||||
'180.184.2.2': [
|
||||
'udp://180.184.2.2',
|
||||
'udp://180.184.1.1'
|
||||
]
|
||||
};
|
||||
} (domestic));
|
||||
return domestic;
|
||||
}var direct = {};var hasRequiredDirect;
|
||||
|
||||
function requireDirect () {
|
||||
if (hasRequiredDirect) return direct;
|
||||
hasRequiredDirect = 1;
|
||||
(function (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, {
|
||||
DIRECTS: function() {
|
||||
return DIRECTS;
|
||||
},
|
||||
LAN: function() {
|
||||
return LAN;
|
||||
}
|
||||
});
|
||||
const DIRECTS = {
|
||||
HOTSPOT_CAPTIVE_PORTAL: {
|
||||
dns: 'system',
|
||||
hosts: {},
|
||||
realip: false,
|
||||
ruleset: false,
|
||||
domains: [
|
||||
'securelogin.com.cn',
|
||||
'$captive.apple.com',
|
||||
'$hotspot.cslwifi.com'
|
||||
]
|
||||
},
|
||||
SYSTEM: {
|
||||
dns: 'system',
|
||||
hosts: {},
|
||||
realip: true,
|
||||
ruleset: false,
|
||||
domains: [
|
||||
'+m2m',
|
||||
// '+ts.net', // TailScale Magic DNS
|
||||
// AdGuard
|
||||
'$injections.adguard.org',
|
||||
'$local.adguard.org',
|
||||
// Auto Discovery
|
||||
'+bogon'
|
||||
]
|
||||
}
|
||||
};
|
||||
const LAN = {
|
||||
ROUTER: {
|
||||
dns: 'system',
|
||||
hosts: {},
|
||||
realip: false,
|
||||
ruleset: true,
|
||||
domains: [
|
||||
'+home',
|
||||
// 'zte.home', // ZTE CPE
|
||||
// 'airbox.home',
|
||||
// 'bthub.home',
|
||||
// 'bthomehub.home',
|
||||
// 'hitronhub.home',
|
||||
// 'web.setup.home'
|
||||
// Aruba Router
|
||||
'$instant.arubanetworks.com',
|
||||
'$setmeup.arubanetworks.com',
|
||||
// ASUS router
|
||||
'$router.asus.com',
|
||||
'$repeater.asus.com',
|
||||
'asusrouter.com',
|
||||
// NetGear
|
||||
'routerlogin.net',
|
||||
'routerlogin.com',
|
||||
// Tenda WiFi
|
||||
// 'tendawifi.com',
|
||||
// TP-Link Router
|
||||
'tplinkwifi.net',
|
||||
'tplogin.cn',
|
||||
'tplinkap.net',
|
||||
'tplinkmodem.net',
|
||||
'tplinkplclogin.net',
|
||||
'tplinkrepeater.net',
|
||||
// UniFi
|
||||
'+ui.direct',
|
||||
'$unifi',
|
||||
// Other Router
|
||||
// '$router.com',
|
||||
'+huaweimobilewifi.com',
|
||||
'+router',
|
||||
// 'my.router',
|
||||
// 'samsung.router',
|
||||
// '$easy.box', // Vodafone EasyBox
|
||||
'$aterm.me',
|
||||
'$console.gl-inet.com',
|
||||
// '$fritz.box',
|
||||
// '$fritz.repeater',
|
||||
// '$myfritz.box',
|
||||
// '$speedport.ip', // Telekom
|
||||
// '$giga.cube', // Vodafone GigaCube
|
||||
'$homerouter.cpe',
|
||||
'$mobile.hotspot',
|
||||
'$ntt.setup',
|
||||
'$pi.hole',
|
||||
'+plex.direct'
|
||||
]
|
||||
},
|
||||
LAN: {
|
||||
dns: 'system',
|
||||
hosts: {
|
||||
},
|
||||
realip: true,
|
||||
ruleset: true,
|
||||
domains: [
|
||||
'+lan',
|
||||
// 'amplifi.lan',
|
||||
// '$localhost',
|
||||
'+localdomain',
|
||||
'home.arpa',
|
||||
// AS112
|
||||
'10.in-addr.arpa',
|
||||
'16.172.in-addr.arpa',
|
||||
'17.172.in-addr.arpa',
|
||||
'18.172.in-addr.arpa',
|
||||
'19.172.in-addr.arpa',
|
||||
// '2?.172.in-addr.arpa',
|
||||
'20.172.in-addr.arpa',
|
||||
'21.172.in-addr.arpa',
|
||||
'22.172.in-addr.arpa',
|
||||
'23.172.in-addr.arpa',
|
||||
'24.172.in-addr.arpa',
|
||||
'25.172.in-addr.arpa',
|
||||
'26.172.in-addr.arpa',
|
||||
'27.172.in-addr.arpa',
|
||||
'28.172.in-addr.arpa',
|
||||
'29.172.in-addr.arpa',
|
||||
'30.172.in-addr.arpa',
|
||||
'31.172.in-addr.arpa',
|
||||
'168.192.in-addr.arpa',
|
||||
'254.169.in-addr.arpa'
|
||||
]
|
||||
}
|
||||
};
|
||||
} (direct));
|
||||
return direct;
|
||||
}var hasRequiredBuildDomesticDirectLanRulesetDnsMappingModule;
|
||||
|
||||
function requireBuildDomesticDirectLanRulesetDnsMappingModule () {
|
||||
if (hasRequiredBuildDomesticDirectLanRulesetDnsMappingModule) return buildDomesticDirectLanRulesetDnsMappingModule.exports;
|
||||
hasRequiredBuildDomesticDirectLanRulesetDnsMappingModule = 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, {
|
||||
buildDomesticRuleset: function() {
|
||||
return buildDomesticRuleset;
|
||||
},
|
||||
createGetDnsMappingRule: function() {
|
||||
return createGetDnsMappingRule;
|
||||
},
|
||||
getDomesticAndDirectDomainsRulesetPromise: function() {
|
||||
return getDomesticAndDirectDomainsRulesetPromise;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _domestic = /*@__PURE__*/ requireDomestic();
|
||||
const _direct = /*@__PURE__*/ requireDirect();
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _createfile = /*@__PURE__*/ createFile.r();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _memopromise = /*@__PURE__*/ memoPromise.r();
|
||||
const _yaml = /*#__PURE__*/ _interop_require_wildcard(require$$8);
|
||||
const _appendarrayinplace = /*@__PURE__*/ base.a();
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _ruleset = /*@__PURE__*/ ruleset.r();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function(nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interop_require_wildcard(obj, nodeInterop) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {
|
||||
__proto__: null
|
||||
};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
function createGetDnsMappingRule(allowWildcard) {
|
||||
const hasWildcard = (domain)=>{
|
||||
if (domain.includes('*') || domain.includes('?')) {
|
||||
if (!allowWildcard) {
|
||||
throw new TypeError(`Wildcard domain is not supported: ${domain}`);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
return (domain)=>{
|
||||
const results = [];
|
||||
if (domain[0] === '$') {
|
||||
const d = domain.slice(1);
|
||||
if (hasWildcard(domain)) {
|
||||
results.push(`DOMAIN-WILDCARD,${d}`);
|
||||
} else {
|
||||
results.push(`DOMAIN,${d}`);
|
||||
}
|
||||
} else if (domain[0] === '+') {
|
||||
const d = domain.slice(1);
|
||||
if (hasWildcard(domain)) {
|
||||
results.push(`DOMAIN-WILDCARD,*.${d}`);
|
||||
} else {
|
||||
results.push(`DOMAIN-SUFFIX,${d}`);
|
||||
}
|
||||
} else if (hasWildcard(domain)) {
|
||||
results.push(`DOMAIN-WILDCARD,${domain}`, `DOMAIN-WILDCARD,*.${domain}`);
|
||||
} else {
|
||||
results.push(`DOMAIN-SUFFIX,${domain}`);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
}
|
||||
const getDomesticAndDirectDomainsRulesetPromise = (0, _memopromise.createMemoizedPromise)(async ()=>{
|
||||
const domestics = await (0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.SOURCE_DIR, 'non_ip/domestic.conf'));
|
||||
const directs = await (0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.resolve(_dir.SOURCE_DIR, 'non_ip/direct.conf'));
|
||||
const lans = [];
|
||||
const getDnsMappingRuleWithWildcard = createGetDnsMappingRule(true);
|
||||
[
|
||||
_domestic.DOH_BOOTSTRAP,
|
||||
_domestic.DOMESTICS
|
||||
].forEach((item)=>{
|
||||
Object.values(item).forEach(({ domains })=>{
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(domestics, domains.flatMap(getDnsMappingRuleWithWildcard));
|
||||
});
|
||||
});
|
||||
Object.values(_direct.DIRECTS).forEach(({ domains })=>{
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(directs, domains.flatMap(getDnsMappingRuleWithWildcard));
|
||||
});
|
||||
Object.values(_direct.LAN).forEach(({ domains })=>{
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(directs, domains.flatMap(getDnsMappingRuleWithWildcard));
|
||||
});
|
||||
return [
|
||||
domestics,
|
||||
directs,
|
||||
lans
|
||||
];
|
||||
});
|
||||
const buildDomesticRuleset = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const [domestics, directs, lans] = await getDomesticAndDirectDomainsRulesetPromise();
|
||||
const dataset = [
|
||||
_domestic.DOH_BOOTSTRAP,
|
||||
_domestic.DOMESTICS,
|
||||
_direct.DIRECTS,
|
||||
_direct.LAN
|
||||
].flatMap(Object.entries);
|
||||
return Promise.all([
|
||||
new _ruleset.RulesetOutput(span, 'domestic', 'non_ip').withTitle('Sukka\'s Ruleset - Domestic Domains').withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'This file contains known addresses that are avaliable in the Mainland China.'
|
||||
]).addFromRuleset(domestics).write(),
|
||||
new _ruleset.RulesetOutput(span, 'direct', 'non_ip').withTitle('Sukka\'s Ruleset - Direct Rules').withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'This file contains domains and process that should not be proxied.'
|
||||
]).addFromRuleset(directs).write(),
|
||||
new _ruleset.RulesetOutput(span, 'lan', 'non_ip').withTitle('Sukka\'s Ruleset - LAN').withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'This file includes rules for LAN DOMAIN and reserved TLDs.'
|
||||
]).addFromRuleset(lans).write(),
|
||||
...dataset.map(([name, { ruleset, domains }])=>{
|
||||
if (!ruleset) {
|
||||
return;
|
||||
}
|
||||
const output = new _ruleset.SurgeOnlyRulesetOutput(span, name.toLowerCase(), 'sukka_local_dns_mapping', _dir.OUTPUT_MODULES_RULES_DIR).withTitle(`Sukka's Ruleset - Local DNS Mapping (${name})`).withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'This is an internal rule that is only referenced by sukka_local_dns_mapping.sgmodule',
|
||||
'Do not use this file in your Rule section, all rules are included in non_ip/domestic.conf already.'
|
||||
]);
|
||||
domains.forEach((domain)=>{
|
||||
switch(domain[0]){
|
||||
case '$':
|
||||
output.addDomain(domain.slice(1));
|
||||
break;
|
||||
case '+':
|
||||
output.addDomainSuffix(domain.slice(1));
|
||||
break;
|
||||
default:
|
||||
output.addDomainSuffix(domain);
|
||||
break;
|
||||
}
|
||||
});
|
||||
return output.write();
|
||||
}),
|
||||
(0, _createfile.compareAndWriteFile)(span, [
|
||||
'#!name=[Sukka] Local DNS Mapping',
|
||||
`#!desc=Last Updated: ${new Date().toISOString()}`,
|
||||
'',
|
||||
'[Host]',
|
||||
...Object.entries(// I use an object to deduplicate the domains
|
||||
// Otherwise I could just construct an array directly
|
||||
dataset.reduce((acc, cur)=>{
|
||||
const ruleset_name = cur[0].toLowerCase();
|
||||
const { domains, dns, hosts, ruleset } = cur[1];
|
||||
Object.entries(hosts).forEach(([dns, ips])=>{
|
||||
acc[dns] ||= ips.join(', ');
|
||||
});
|
||||
if (ruleset) {
|
||||
acc[`RULE-SET:https://ruleset.skk.moe/Modules/Rules/sukka_local_dns_mapping/${ruleset_name}.conf`] ||= `server:${dns}`;
|
||||
} else {
|
||||
domains.forEach((domain)=>{
|
||||
switch(domain[0]){
|
||||
case '$':
|
||||
acc[domain.slice(1)] ||= `server:${dns}`;
|
||||
break;
|
||||
case '+':
|
||||
acc[`*.${domain.slice(1)}`] ||= `server:${dns}`;
|
||||
break;
|
||||
default:
|
||||
acc[domain] ||= `server:${dns}`;
|
||||
acc[`*.${domain}`] ||= `server:${dns}`;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
return acc;
|
||||
}, {})).map(([dns, ips])=>`${dns} = ${ips}`)
|
||||
], _nodepath.default.resolve(_dir.OUTPUT_MODULES_DIR, 'sukka_local_dns_mapping.sgmodule')),
|
||||
(0, _createfile.compareAndWriteFile)(span, _yaml.stringify(dataset.reduce((acc, cur)=>{
|
||||
const { domains, dns, ...rest } = cur[1];
|
||||
domains.forEach((domain)=>{
|
||||
switch(domain[0]){
|
||||
case '$':
|
||||
domain = domain.slice(1);
|
||||
break;
|
||||
case '+':
|
||||
domain = `*.${domain.slice(1)}`;
|
||||
break;
|
||||
default:
|
||||
domain = `+.${domain}`;
|
||||
break;
|
||||
}
|
||||
acc.dns['nameserver-policy'][domain] = dns === 'system' ? [
|
||||
'system://',
|
||||
'system',
|
||||
'dhcp://system'
|
||||
] : dns;
|
||||
});
|
||||
if ('hosts' in rest) {
|
||||
Object.assign(acc.hosts, rest.hosts);
|
||||
}
|
||||
return acc;
|
||||
}, {
|
||||
dns: {
|
||||
'nameserver-policy': {}
|
||||
},
|
||||
hosts: {}
|
||||
}), {
|
||||
version: '1.1'
|
||||
}).split('\n'), _nodepath.default.join(_dir.OUTPUT_INTERNAL_DIR, 'clash_nameserver_policy.yaml')),
|
||||
(0, _createfile.compareAndWriteFile)(span, [
|
||||
'# Local DNS Mapping for AdGuard Home',
|
||||
'tls://1.12.12.12',
|
||||
'tls://120.53.53.53',
|
||||
'https://1.12.12.12/dns-query',
|
||||
'https://120.53.53.53/dns-query',
|
||||
'[//]udp://10.10.1.1:53',
|
||||
...[
|
||||
_domestic.DOMESTICS,
|
||||
_direct.DIRECTS,
|
||||
_direct.LAN
|
||||
].flatMap(Object.values).flatMap(({ domains, dns: _dns })=>domains.flatMap((domain)=>{
|
||||
let dns;
|
||||
if (_dns in _domestic.AdGuardHomeDNSMapping) {
|
||||
dns = _domestic.AdGuardHomeDNSMapping[_dns].join(' ');
|
||||
} else {
|
||||
console.warn(`Unknown DNS "${_dns}" not in AdGuardHomeDNSMapping`);
|
||||
dns = _dns;
|
||||
}
|
||||
// if (
|
||||
// // AdGuard Home has built-in AS112 / private PTR handling
|
||||
// domain.endsWith('.arpa')
|
||||
// // Ignore simple hostname
|
||||
// || !domain.includes('.')
|
||||
// ) {
|
||||
// return [];
|
||||
// }
|
||||
if (domain[0] === '$') {
|
||||
return [
|
||||
`[/${domain.slice(1)}/]${dns}`
|
||||
];
|
||||
}
|
||||
if (domain[0] === '+') {
|
||||
return [
|
||||
`[/${domain.slice(1)}/]${dns}`
|
||||
];
|
||||
}
|
||||
return [
|
||||
`[/${domain}/]${dns}`
|
||||
];
|
||||
}))
|
||||
], _nodepath.default.resolve(_dir.OUTPUT_INTERNAL_DIR, 'dns_mapping_adguardhome.conf'))
|
||||
]);
|
||||
});
|
||||
} (buildDomesticDirectLanRulesetDnsMappingModule, buildDomesticDirectLanRulesetDnsMappingModule.exports));
|
||||
return buildDomesticDirectLanRulesetDnsMappingModule.exports;
|
||||
}exports.a=requireDirect;exports.b=requireDomestic;exports.r=requireBuildDomesticDirectLanRulesetDnsMappingModule;
|
||||
77
Dist/chunks/build-internal-reverse-chn-cidr.C6CBihfs.cjs
Normal file
77
Dist/chunks/build-internal-reverse-chn-cidr.C6CBihfs.cjs
Normal file
@@ -0,0 +1,77 @@
|
||||
'use strict';const require$$0$1=require('node:path'),index=require('./index.B8Uk9n3v.cjs'),buildChnCidr=require('./build-chn-cidr.BjyqKcvm.cjs'),require$$1=require('node:fs'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),require$$0=require('foxts/async-write-to-stream'),misc=require('./misc.BpcQjda1.cjs'),require$$7=require('worktank'),require$$8=require('url');var buildInternalReverseChnCidr = {exports: {}};var hasRequiredBuildInternalReverseChnCidr;
|
||||
|
||||
function requireBuildInternalReverseChnCidr () {
|
||||
if (hasRequiredBuildInternalReverseChnCidr) return buildInternalReverseChnCidr.exports;
|
||||
hasRequiredBuildInternalReverseChnCidr = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildInternalReverseChnCIDR", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildInternalReverseChnCIDR;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0$1);
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _buildchncidr = buildChnCidr.r();
|
||||
const _nodefs = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _asyncwritetostream = require$$0;
|
||||
const _misc = /*@__PURE__*/ misc.r();
|
||||
const _worktank = /*#__PURE__*/ _interop_require_default(require$$7);
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const pool = new _worktank.default({
|
||||
name: 'build-internal-reverse-chn-cidr',
|
||||
size: 1,
|
||||
timeout: 10000,
|
||||
warmup: true,
|
||||
autoterminate: 30000,
|
||||
env: {},
|
||||
methods: {
|
||||
// eslint-disable-next-line object-shorthand -- workertank
|
||||
getreversedCidr: async function(cidr, importMetaUrl) {
|
||||
// TODO: createRequire is a temporary workaround for https://github.com/nodejs/node/issues/51956
|
||||
const { default: module1 } = await import('node:module');
|
||||
const __require = module1.createRequire(importMetaUrl);
|
||||
const { exclude, merge } = __require('fast-cidr-tools');
|
||||
const { RESERVED_IPV4_CIDR, NON_CN_CIDR_INCLUDED_IN_CHNROUTE } = __require('./constants/cidr');
|
||||
const { appendArrayInPlace } = __require('./lib/append-array-in-place');
|
||||
return merge(appendArrayInPlace(exclude([
|
||||
'0.0.0.0/0'
|
||||
], RESERVED_IPV4_CIDR.concat(cidr), true), // https://github.com/misakaio/chnroutes2/issues/25
|
||||
NON_CN_CIDR_INCLUDED_IN_CHNROUTE), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
const buildInternalReverseChnCIDR = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const [cidr] = await span.traceChildPromise('download chnroutes2', (0, _buildchncidr.getChnCidrPromise)());
|
||||
const reversedCidr = await span.traceChildAsync('build reversed chn cidr', async ()=>{
|
||||
const reversedCidr = await pool.exec('getreversedCidr', [
|
||||
cidr,
|
||||
require$$8.pathToFileURL(__filename).toString()
|
||||
]);
|
||||
pool.terminate();
|
||||
return reversedCidr;
|
||||
});
|
||||
const outputFile = _nodepath.default.join(_dir.OUTPUT_INTERNAL_DIR, 'reversed-chn-cidr.txt');
|
||||
await (0, _misc.mkdirp)(_dir.OUTPUT_INTERNAL_DIR);
|
||||
const writeStream = _nodefs.default.createWriteStream(outputFile);
|
||||
for (const line of reversedCidr){
|
||||
const p = (0, _asyncwritetostream.asyncWriteToStream)(writeStream, line + '\n');
|
||||
if (p) {
|
||||
// eslint-disable-next-line no-await-in-loop -- stream high water mark
|
||||
await p;
|
||||
}
|
||||
}
|
||||
await (0, _asyncwritetostream.asyncWriteToStream)(writeStream, '\n');
|
||||
writeStream.end();
|
||||
});
|
||||
} (buildInternalReverseChnCidr, buildInternalReverseChnCidr.exports));
|
||||
return buildInternalReverseChnCidr.exports;
|
||||
}exports.r=requireBuildInternalReverseChnCidr;
|
||||
84
Dist/chunks/build-microsoft-cdn.CCw86frc.cjs
Normal file
84
Dist/chunks/build-microsoft-cdn.CCw86frc.cjs
Normal file
@@ -0,0 +1,84 @@
|
||||
'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;
|
||||
232
Dist/chunks/build-public.8-AWnl05.cjs
Normal file
232
Dist/chunks/build-public.8-AWnl05.cjs
Normal file
@@ -0,0 +1,232 @@
|
||||
'use strict';const require$$0=require('node:path'),require$$1=require('node:fs'),require$$2=require('node:fs/promises'),index=require('./index.B8Uk9n3v.cjs'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),misc=require('./misc.BpcQjda1.cjs'),require$$0$1=require('picocolors'),require$$8=require('foxts/tagged'),createFile=require('./create-file.loOMbJEN.cjs');var buildPublic = {exports: {}};var treeDir = {};var hasRequiredTreeDir;
|
||||
|
||||
function requireTreeDir () {
|
||||
if (hasRequiredTreeDir) return treeDir;
|
||||
hasRequiredTreeDir = 1;
|
||||
(function (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, {
|
||||
TreeFileType: function() {
|
||||
return TreeFileType;
|
||||
},
|
||||
treeDir: function() {
|
||||
return treeDir;
|
||||
}
|
||||
});
|
||||
const _promises = /*#__PURE__*/ _interop_require_default(require$$2);
|
||||
const _nodepath = require$$0;
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var TreeFileType = /*#__PURE__*/ function(TreeFileType) {
|
||||
TreeFileType[TreeFileType["FILE"] = 1] = "FILE";
|
||||
TreeFileType[TreeFileType["DIRECTORY"] = 2] = "DIRECTORY";
|
||||
return TreeFileType;
|
||||
}({});
|
||||
async function treeDir(rootPath) {
|
||||
const tree = [];
|
||||
const walk = async (dir, node, dirRelativeToRoot = '')=>{
|
||||
const promises = [];
|
||||
for await (const child of (await _promises.default.opendir(dir))){
|
||||
// Ignore hidden files
|
||||
if (child.name[0] === '.' || child.name === 'CNAME') {
|
||||
continue;
|
||||
}
|
||||
const childFullPath = child.parentPath + _nodepath.sep + child.name;
|
||||
const childRelativeToRoot = dirRelativeToRoot + _nodepath.sep + child.name;
|
||||
if (child.isDirectory()) {
|
||||
const newNode = {
|
||||
type: 2,
|
||||
name: child.name,
|
||||
path: childRelativeToRoot,
|
||||
children: []
|
||||
};
|
||||
node.push(newNode);
|
||||
promises.push(walk(childFullPath, newNode.children, childRelativeToRoot));
|
||||
continue;
|
||||
}
|
||||
if (child.isFile()) {
|
||||
const newNode = {
|
||||
type: 1,
|
||||
name: child.name,
|
||||
path: childRelativeToRoot
|
||||
};
|
||||
node.push(newNode);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return Promise.all(promises);
|
||||
};
|
||||
await walk(rootPath, tree);
|
||||
return tree;
|
||||
}
|
||||
} (treeDir));
|
||||
return treeDir;
|
||||
}var hasRequiredBuildPublic;
|
||||
|
||||
function requireBuildPublic () {
|
||||
if (hasRequiredBuildPublic) return buildPublic.exports;
|
||||
hasRequiredBuildPublic = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildPublic", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildPublic;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _nodefs = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
const _promises = /*#__PURE__*/ _interop_require_default(require$$2);
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _treedir = /*@__PURE__*/ requireTreeDir();
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _misc = /*@__PURE__*/ misc.r();
|
||||
const _picocolors = /*#__PURE__*/ _interop_require_default(require$$0$1);
|
||||
const _tagged = require$$8;
|
||||
const _createfile = /*@__PURE__*/ createFile.r();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const mockDir = _nodepath.default.join(_dir.ROOT_DIR, 'Mock');
|
||||
const modulesDir = _nodepath.default.join(_dir.ROOT_DIR, 'Modules');
|
||||
async function copyDirContents(srcDir, destDir) {
|
||||
const promises = [];
|
||||
for await (const entry of (await _promises.default.opendir(srcDir))){
|
||||
const src = _nodepath.default.join(srcDir, entry.name);
|
||||
const dest = _nodepath.default.join(destDir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
console.warn(_picocolors.default.red('[build public] cant copy directory'), src);
|
||||
} else {
|
||||
promises.push(_promises.default.copyFile(src, dest, _nodefs.default.constants.COPYFILE_FICLONE));
|
||||
}
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}
|
||||
const buildPublic = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
await span.traceChildAsync('copy rest of the files', async ()=>{
|
||||
await Promise.all([
|
||||
// mkdirp(OUTPUT_MODULES_DIR),
|
||||
(0, _misc.mkdirp)(_dir.OUTPUT_MODULES_RULES_DIR),
|
||||
(0, _misc.mkdirp)(_dir.OUTPUT_MOCK_DIR)
|
||||
]);
|
||||
await Promise.all([
|
||||
copyDirContents(modulesDir, _dir.OUTPUT_MODULES_DIR),
|
||||
copyDirContents(mockDir, _dir.OUTPUT_MOCK_DIR)
|
||||
]);
|
||||
});
|
||||
const html = await span.traceChild('generate index.html').traceAsyncFn(()=>(0, _treedir.treeDir)(_dir.PUBLIC_DIR).then(generateHtml));
|
||||
await (0, _createfile.compareAndWriteFile)(span, [
|
||||
'/*',
|
||||
' cache-control: public, max-age=240, stale-while-revalidate=60, stale-if-error=15',
|
||||
'https://:project.pages.dev/*',
|
||||
' X-Robots-Tag: noindex',
|
||||
'/Modules/*',
|
||||
' content-type: text/plain; charset=utf-8',
|
||||
'/List/*',
|
||||
' content-type: text/plain; charset=utf-8'
|
||||
], _nodepath.default.join(_dir.PUBLIC_DIR, '_headers'));
|
||||
await (0, _createfile.compareAndWriteFile)(span, [
|
||||
'# <pre>',
|
||||
'#########################################',
|
||||
'# Sukka\'s Ruleset - 404 Not Found',
|
||||
'################## EOF ##################</pre>'
|
||||
], _nodepath.default.join(_dir.PUBLIC_DIR, '404.html'));
|
||||
return (0, _misc.writeFile)(_nodepath.default.join(_dir.PUBLIC_DIR, 'index.html'), html);
|
||||
});
|
||||
const priorityOrder = {
|
||||
domainset: 1,
|
||||
non_ip: 2,
|
||||
ip: 3,
|
||||
List: 10,
|
||||
Surge: 11,
|
||||
Clash: 12,
|
||||
'sing-box': 13,
|
||||
Modules: 20,
|
||||
Script: 30,
|
||||
Mock: 40,
|
||||
Assets: 50,
|
||||
Internal: 60,
|
||||
LICENSE: 70,
|
||||
default: Number.MAX_VALUE
|
||||
};
|
||||
const prioritySorter = (a, b)=>(priorityOrder[a.name] || priorityOrder.default) - (priorityOrder[b.name] || priorityOrder.default) || (0, _misc.fastStringCompare)(a.name, b.name);
|
||||
function walk(tree) {
|
||||
let result = '';
|
||||
tree.sort(prioritySorter);
|
||||
for(let i = 0, len = tree.length; i < len; i++){
|
||||
const entry = tree[i];
|
||||
if (entry.type === _treedir.TreeFileType.DIRECTORY) {
|
||||
result += (0, _tagged.tagged)`
|
||||
<li class="folder">
|
||||
${entry.name}
|
||||
<ul>
|
||||
${walk(entry.children)}
|
||||
</ul>
|
||||
</li>
|
||||
`;
|
||||
} else if (/* entry.type === 'file' && */ entry.name !== 'index.html') {
|
||||
result += (0, _tagged.tagged)`<li><a class="file directory-list-file" href="${entry.path}">${entry.name}</a></li>`;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function generateHtml(tree) {
|
||||
return (0, _tagged.tagged)`
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Surge Ruleset Server | Sukka (@SukkaW)</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
|
||||
<link href="https://cdn.skk.moe/favicon.ico" rel="icon" type="image/ico">
|
||||
<link href="https://cdn.skk.moe/favicon/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180">
|
||||
<link href="https://cdn.skk.moe/favicon/android-chrome-192x192.png" rel="icon" type="image/png" sizes="192x192">
|
||||
<link href="https://cdn.skk.moe/favicon/favicon-32x32.png" rel="icon" type="image/png" sizes="32x32">
|
||||
<link href="https://cdn.skk.moe/favicon/favicon-16x16.png" rel="icon" type="image/png" sizes="16x16">
|
||||
<meta name="description" content="Sukka 自用的 Surge / Clash Premium 规则组">
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.skk.moe/ruleset/css/21d8777a.css" />
|
||||
|
||||
<meta property="og:title" content="Surge Ruleset | Sukka (@SukkaW)">
|
||||
<meta property="og:type" content="Website">
|
||||
<meta property="og:url" content="https://ruleset.skk.moe/">
|
||||
<meta property="og:image" content="https://cdn.skk.moe/favicon/android-chrome-192x192.png">
|
||||
<meta property="og:description" content="Sukka 自用的 Surge / Clash Premium 规则组">
|
||||
<meta name="twitter:card" content="summary">
|
||||
<link rel="canonical" href="https://ruleset.skk.moe/">
|
||||
</head>
|
||||
<body>
|
||||
<main class="container">
|
||||
<h1>Sukka Ruleset Server</h1>
|
||||
<p>
|
||||
Made by <a href="https://skk.moe">Sukka</a> | <a href="https://github.com/SukkaW/Surge/">Source @ GitHub</a> | Licensed under <a href="/LICENSE" target="_blank">AGPL-3.0</a>
|
||||
</p>
|
||||
<p>Last Build: ${new Date().toISOString()}</p>
|
||||
<br>
|
||||
<ul class="directory-list">
|
||||
${walk(tree)}
|
||||
</ul>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
}
|
||||
} (buildPublic, buildPublic.exports));
|
||||
return buildPublic.exports;
|
||||
}exports.r=requireBuildPublic;
|
||||
1073
Dist/chunks/build-reject-domainset.BCoJGSBE.cjs
Normal file
1073
Dist/chunks/build-reject-domainset.BCoJGSBE.cjs
Normal file
File diff suppressed because it is too large
Load Diff
145
Dist/chunks/build-reject-ip-list.D6Cjv0d8.cjs
Normal file
145
Dist/chunks/build-reject-ip-list.D6Cjv0d8.cjs
Normal file
@@ -0,0 +1,145 @@
|
||||
'use strict';const require$$0=require('node:path'),fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),index=require('./index.B8Uk9n3v.cjs'),base=require('./base.C13YY5P3.cjs'),createFile=require('./create-file.loOMbJEN.cjs'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),fetchAssets=require('./fetch-assets.aqw2YOi8.cjs'),misc=require('./misc.BpcQjda1.cjs'),ruleset=require('./ruleset.iYH0XOC1.cjs');var buildRejectIpList = {exports: {}};var badboy_asn = {};var hasRequiredBadboy_asn;
|
||||
|
||||
function requireBadboy_asn () {
|
||||
if (hasRequiredBadboy_asn) return badboy_asn;
|
||||
hasRequiredBadboy_asn = 1;
|
||||
(function (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, {
|
||||
AUGUST_ASN: function() {
|
||||
return AUGUST_ASN;
|
||||
},
|
||||
HUIZE_ASN: function() {
|
||||
return HUIZE_ASN;
|
||||
}
|
||||
});
|
||||
const AUGUST_ASN = [
|
||||
'1012',
|
||||
'945',
|
||||
'401111',
|
||||
'62853',
|
||||
'27523',
|
||||
'7719',
|
||||
'54625',
|
||||
'7257',
|
||||
'18044',
|
||||
'62489',
|
||||
'5111',
|
||||
'14651',
|
||||
'7480' // Friend of August, stealing others' XC at STUIX
|
||||
];
|
||||
const HUIZE_ASN = [
|
||||
'61302',
|
||||
'44324',
|
||||
'53808',
|
||||
'60539',
|
||||
'60842',
|
||||
'140915',
|
||||
'40115' // MoeDove
|
||||
];
|
||||
} (badboy_asn));
|
||||
return badboy_asn;
|
||||
}var hasRequiredBuildRejectIpList;
|
||||
|
||||
function requireBuildRejectIpList () {
|
||||
if (hasRequiredBuildRejectIpList) return buildRejectIpList.exports;
|
||||
hasRequiredBuildRejectIpList = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildRejectIPList", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildRejectIPList;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _createfile = /*@__PURE__*/ createFile.r();
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _fetchretry = /*@__PURE__*/ fetchRetry.r();
|
||||
const _fetchassets = /*@__PURE__*/ fetchAssets.r();
|
||||
const _misc = /*@__PURE__*/ misc.r();
|
||||
const _badboy_asn = /*@__PURE__*/ requireBadboy_asn();
|
||||
const _ruleset = /*@__PURE__*/ ruleset.r();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const BOGUS_NXDOMAIN_URL = 'https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/bogus-nxdomain.china.conf';
|
||||
const getBogusNxDomainIPsPromise = (0, _fetchretry.$$fetch)(BOGUS_NXDOMAIN_URL).then(async (resp)=>{
|
||||
const ipv4 = [];
|
||||
const ipv6 = [];
|
||||
for await (const line of (0, _fetchtextbyline.createReadlineInterfaceFromResponse)(resp, true)){
|
||||
if (line.startsWith('bogus-nxdomain=')) {
|
||||
const ip = line.slice(15).trim();
|
||||
const v = (0, _misc.fastIpVersion)(ip);
|
||||
if (v === 4) {
|
||||
ipv4.push(ip);
|
||||
} else if (v === 6) {
|
||||
ipv6.push(ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
return [
|
||||
ipv4,
|
||||
ipv6
|
||||
];
|
||||
});
|
||||
const BOTNET_FILTER_URL = 'https://malware-filter.pages.dev/botnet-filter-dnscrypt-blocked-ips.txt';
|
||||
const BOTNET_FILTER_MIRROR_URL = [
|
||||
'https://botnet-filter.pages.dev/botnet-filter-dnscrypt-blocked-ips.txt',
|
||||
'https://malware-filter.gitlab.io/malware-filter/botnet-filter-dnscrypt-blocked-ips.txt',
|
||||
'https://malware-filter.gitlab.io/botnet-filter/botnet-filter-dnscrypt-blocked-ips.txt'
|
||||
];
|
||||
const getBotNetFilterIPsPromise = (0, _fetchassets.fetchAssets)(BOTNET_FILTER_URL, BOTNET_FILTER_MIRROR_URL, true).then((arr)=>arr.reduce((acc, ip)=>{
|
||||
const v = (0, _misc.fastIpVersion)(ip);
|
||||
if (v === 4) {
|
||||
acc[0].push(ip);
|
||||
} else if (v === 6) {
|
||||
acc[1].push(ip);
|
||||
}
|
||||
return acc;
|
||||
}, [
|
||||
[],
|
||||
[]
|
||||
]));
|
||||
const readLocalRejectIpListPromise = (0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.resolve(_dir.SOURCE_DIR, 'ip/reject.conf'));
|
||||
const buildRejectIPList = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const [bogusNxDomainIPs, botNetIPs] = await Promise.all([
|
||||
span.traceChildPromise('get bogus nxdomain ips', getBogusNxDomainIPsPromise),
|
||||
span.traceChildPromise('get botnet ips', getBotNetFilterIPsPromise)
|
||||
]);
|
||||
return Promise.all([
|
||||
new _ruleset.RulesetOutput(span, 'reject', 'ip').withTitle('Sukka\'s Ruleset - Anti Bogus Domain').withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'This file contains known addresses that are hijacking NXDOMAIN results returned by DNS servers, and botnet controller IPs.',
|
||||
'',
|
||||
'Data from:',
|
||||
' - https://github.com/felixonmars/dnsmasq-china-list',
|
||||
' - https://github.com/curbengh/botnet-filter'
|
||||
]).addFromRuleset(readLocalRejectIpListPromise).bulkAddCIDR4NoResolve(bogusNxDomainIPs[0]).bulkAddCIDR6NoResolve(bogusNxDomainIPs[1]).bulkAddCIDR4NoResolve(botNetIPs[0]).bulkAddCIDR6NoResolve(botNetIPs[1]).bulkAddIPASN(_badboy_asn.AUGUST_ASN).bulkAddIPASN(_badboy_asn.HUIZE_ASN).write(),
|
||||
(0, _createfile.compareAndWriteFile)(span, [
|
||||
_badboy_asn.AUGUST_ASN.join(' ')
|
||||
], _nodepath.default.join(_dir.OUTPUT_INTERNAL_DIR, 'august_asn.txt')),
|
||||
(0, _createfile.compareAndWriteFile)(span, [
|
||||
_badboy_asn.HUIZE_ASN.join(' ')
|
||||
], _nodepath.default.join(_dir.OUTPUT_INTERNAL_DIR, 'huize_asn.txt'))
|
||||
]);
|
||||
});
|
||||
} (buildRejectIpList, buildRejectIpList.exports));
|
||||
return buildRejectIpList.exports;
|
||||
}exports.r=requireBuildRejectIpList;
|
||||
136
Dist/chunks/build-sgmodule-always-realip.CuBgClIT.cjs
Normal file
136
Dist/chunks/build-sgmodule-always-realip.CuBgClIT.cjs
Normal file
@@ -0,0 +1,136 @@
|
||||
'use strict';const require$$0=require('node:path'),index=require('./index.B8Uk9n3v.cjs'),createFile=require('./create-file.loOMbJEN.cjs'),buildDomesticDirectLanRulesetDnsMappingModule=require('./build-domestic-direct-lan-ruleset-dns-mapping-module.T1tgVza_.cjs'),require$$8=require('yaml'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),base=require('./base.C13YY5P3.cjs');var buildSgmoduleAlwaysRealip = {exports: {}};var hasRequiredBuildSgmoduleAlwaysRealip;
|
||||
|
||||
function requireBuildSgmoduleAlwaysRealip () {
|
||||
if (hasRequiredBuildSgmoduleAlwaysRealip) return buildSgmoduleAlwaysRealip.exports;
|
||||
hasRequiredBuildSgmoduleAlwaysRealip = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildAlwaysRealIPModule", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildAlwaysRealIPModule;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _createfile = /*@__PURE__*/ createFile.r();
|
||||
const _direct = /*@__PURE__*/ buildDomesticDirectLanRulesetDnsMappingModule.a();
|
||||
const _domestic = /*@__PURE__*/ buildDomesticDirectLanRulesetDnsMappingModule.b();
|
||||
const _yaml = /*#__PURE__*/ _interop_require_wildcard(require$$8);
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _appendarrayinplace = /*@__PURE__*/ base.a();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _builddomesticdirectlanrulesetdnsmappingmodule = buildDomesticDirectLanRulesetDnsMappingModule.r();
|
||||
const _clash = /*@__PURE__*/ base.c();
|
||||
const _base = /*@__PURE__*/ base.b();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function(nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interop_require_wildcard(obj, nodeInterop) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {
|
||||
__proto__: null
|
||||
};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
const HOSTNAMES = [
|
||||
// Network Detection, Captive Portal
|
||||
'dns.msftncsi.com',
|
||||
// '*.msftconnecttest.com',
|
||||
// 'network-test.debian.org',
|
||||
// 'detectportal.firefox.com',
|
||||
// Handle SNAT conversation properly
|
||||
'*.srv.nintendo.net',
|
||||
'*.stun.playstation.net',
|
||||
'xbox.*.microsoft.com',
|
||||
'*.xboxlive.com',
|
||||
'*.turn.twilio.com',
|
||||
'*.stun.twilio.com',
|
||||
'stun.syncthing.net',
|
||||
'stun.*'
|
||||
];
|
||||
const buildAlwaysRealIPModule = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const surge = [];
|
||||
const clashFakeIpFilter = new _base.FileOutput(span, 'clash_fake_ip_filter').withTitle('Sukka\'s Ruleset - Always Real IP Plus').withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'Clash.Meta fake-ip-filter as ruleset'
|
||||
]).withStrategies([
|
||||
new _clash.ClashDomainSet('domainset')
|
||||
]);
|
||||
// Intranet, Router Setup, and mant more
|
||||
const dataset = [
|
||||
_direct.DIRECTS,
|
||||
_direct.LAN,
|
||||
_domestic.DOMESTICS,
|
||||
_domestic.DOH_BOOTSTRAP
|
||||
].reduce((acc, item)=>{
|
||||
Object.values(item).forEach((i)=>{
|
||||
if (i.realip) {
|
||||
acc.push(i);
|
||||
}
|
||||
});
|
||||
return acc;
|
||||
}, []);
|
||||
const getDnsMappingRuleWithoutWildcard = (0, _builddomesticdirectlanrulesetdnsmappingmodule.createGetDnsMappingRule)(false);
|
||||
for (const { domains } of dataset){
|
||||
clashFakeIpFilter.addFromRuleset(domains.flatMap(getDnsMappingRuleWithoutWildcard));
|
||||
}
|
||||
return Promise.all([
|
||||
(0, _createfile.compareAndWriteFile)(span, [
|
||||
'#!name=[Sukka] Always Real IP Plus',
|
||||
`#!desc=Last Updated: ${new Date().toISOString()}`,
|
||||
'',
|
||||
'[General]',
|
||||
`always-real-ip = %APPEND% ${HOSTNAMES.concat(surge).join(', ')}`
|
||||
], _nodepath.default.resolve(_dir.OUTPUT_MODULES_DIR, 'sukka_common_always_realip.sgmodule')),
|
||||
(0, _createfile.compareAndWriteFile)(span, _yaml.stringify({
|
||||
dns: {
|
||||
'fake-ip-filter': (0, _appendarrayinplace.appendArrayInPlace)(/** clash */ dataset.flatMap(({ domains })=>domains.map((domain)=>`+.${domain}`)), HOSTNAMES)
|
||||
}
|
||||
}, {
|
||||
version: '1.1'
|
||||
}).split('\n'), _nodepath.default.join(_dir.OUTPUT_INTERNAL_DIR, 'clash_fake_ip_filter.yaml'))
|
||||
]);
|
||||
});
|
||||
} (buildSgmoduleAlwaysRealip, buildSgmoduleAlwaysRealip.exports));
|
||||
return buildSgmoduleAlwaysRealip.exports;
|
||||
}exports.r=requireBuildSgmoduleAlwaysRealip;
|
||||
508
Dist/chunks/build-sgmodule-redirect.iquVSpqW.cjs
Normal file
508
Dist/chunks/build-sgmodule-redirect.iquVSpqW.cjs
Normal file
@@ -0,0 +1,508 @@
|
||||
'use strict';const require$$0=require('node:path'),index=require('./index.B8Uk9n3v.cjs'),createFile=require('./create-file.loOMbJEN.cjs'),require$$5=require('tldts-experimental'),require$$6=require('foxts/guard'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs');var buildSgmoduleRedirect = {exports: {}};var hasRequiredBuildSgmoduleRedirect;
|
||||
|
||||
function requireBuildSgmoduleRedirect () {
|
||||
if (hasRequiredBuildSgmoduleRedirect) return buildSgmoduleRedirect.exports;
|
||||
hasRequiredBuildSgmoduleRedirect = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildRedirectModule", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildRedirectModule;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _createfile = /*@__PURE__*/ createFile.r();
|
||||
const _tldtsexperimental = require$$5;
|
||||
const _guard = require$$6;
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function escapeRegExp(string = '') {
|
||||
const reRegExpChar = /[$()*+.?[\\\]^{|}]/g;
|
||||
const reHasRegExpChar = new RegExp(reRegExpChar.source);
|
||||
return string && reHasRegExpChar.test(string) ? string.replaceAll(reRegExpChar, String.raw`\$&`) : string;
|
||||
}
|
||||
const REDIRECT_MIRROR_HEADER = [
|
||||
// Gravatar
|
||||
[
|
||||
'gravatar.neworld.org/',
|
||||
'https://secure.gravatar.com/'
|
||||
],
|
||||
[
|
||||
'cdn.v2ex.com/gravatar/',
|
||||
'https://secure.gravatar.com/avatar/'
|
||||
],
|
||||
// U.SB
|
||||
[
|
||||
'cdnjs.loli.net/',
|
||||
'https://cdnjs.cloudflare.com/'
|
||||
],
|
||||
[
|
||||
'fonts.loli.net/',
|
||||
'https://fonts.googleapis.com/'
|
||||
],
|
||||
[
|
||||
'gstatic.loli.net/',
|
||||
'https://fonts.gstatic.com/'
|
||||
],
|
||||
[
|
||||
'themes.loli.net/',
|
||||
'https://themes.googleusercontent.com/'
|
||||
],
|
||||
[
|
||||
'ajax.loli.net/',
|
||||
'https://ajax.googleapis.com/'
|
||||
],
|
||||
[
|
||||
'gravatar.loli.net/',
|
||||
'https://secure.gravatar.com/'
|
||||
],
|
||||
// Geekzu
|
||||
[
|
||||
'gapis.geekzu.org/ajax/',
|
||||
'https://ajax.googleapis.com/'
|
||||
],
|
||||
[
|
||||
'fonts.geekzu.org/',
|
||||
'https://fonts.googleapis.com/'
|
||||
],
|
||||
[
|
||||
'gapis.geekzu.org/g-fonts/',
|
||||
'https://fonts.gstatic.com/'
|
||||
],
|
||||
[
|
||||
'gapis.geekzu.org/g-themes/',
|
||||
'https://themes.googleusercontent.com/'
|
||||
],
|
||||
[
|
||||
'sdn.geekzu.org/',
|
||||
'https://secure.gravatar.com/'
|
||||
],
|
||||
// libravatar
|
||||
[
|
||||
'seccdn.libravatar.org/gravatarproxy/',
|
||||
'https://secure.gravatar.com/'
|
||||
],
|
||||
// gh-proxy
|
||||
[
|
||||
'github.moeyy.xyz/',
|
||||
'https://'
|
||||
],
|
||||
// 7ED Services
|
||||
[
|
||||
'use.sevencdn.com/css',
|
||||
'https://fonts.googleapis.com/css'
|
||||
],
|
||||
[
|
||||
'use.sevencdn.com/ajax/libs/',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/'
|
||||
],
|
||||
[
|
||||
'use.sevencdn.com/gajax/',
|
||||
'https://ajax.googleapis.com/ajax/'
|
||||
],
|
||||
[
|
||||
'use.sevencdn.com/chart',
|
||||
'https://chart.googleapis.com/chart'
|
||||
],
|
||||
[
|
||||
'use.sevencdn.com/avatar',
|
||||
'https://secure.gravatar.com/avatar'
|
||||
],
|
||||
[
|
||||
'raw.gitmirror.com/',
|
||||
'https://raw.githubusercontent.com/'
|
||||
],
|
||||
[
|
||||
'gist.gitmirror.com/',
|
||||
'https://gist.githubusercontent.com/'
|
||||
],
|
||||
[
|
||||
'raw.githubusercontents.com/',
|
||||
'https://raw.githubusercontent.com/'
|
||||
],
|
||||
[
|
||||
'gist.githubusercontents.com/',
|
||||
'https://gist.githubusercontent.com/'
|
||||
],
|
||||
[
|
||||
'cdn.gitmirror.com/',
|
||||
'https://cdn.statically.io/'
|
||||
],
|
||||
// FastGit
|
||||
[
|
||||
'raw.fastgit.org/',
|
||||
'https://raw.githubusercontent.com/'
|
||||
],
|
||||
// ['assets.fastgit.org/', 'https://github.githubassets.com/'],
|
||||
// jsDelivr
|
||||
[
|
||||
'fastly.jsdelivr.net/',
|
||||
'https://cdn.jsdelivr.net/'
|
||||
],
|
||||
[
|
||||
'gcore.jsdelivr.net/',
|
||||
'https://cdn.jsdelivr.net/'
|
||||
],
|
||||
[
|
||||
'testingcf.jsdelivr.net/',
|
||||
'https://cdn.jsdelivr.net/'
|
||||
],
|
||||
// JSDMirror
|
||||
[
|
||||
'cdn.jsdmirror.com/',
|
||||
'https://cdn.jsdelivr.net/'
|
||||
],
|
||||
[
|
||||
'cdn.jsdmirror.cn/',
|
||||
'https://cdn.jsdelivr.net/'
|
||||
],
|
||||
// onmicrosoft.cn
|
||||
[
|
||||
'jsd.onmicrosoft.cn/',
|
||||
'https://cdn.jsdelivr.net/'
|
||||
],
|
||||
[
|
||||
'npm.onmicrosoft.cn/',
|
||||
'https://unpkg.com/'
|
||||
],
|
||||
[
|
||||
'cdnjs.onmicrosoft.cn/',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/'
|
||||
],
|
||||
// KGitHub
|
||||
[
|
||||
'raw.kgithub.com/',
|
||||
'https://raw.githubusercontent.com/'
|
||||
],
|
||||
[
|
||||
'raw.kkgithub.com/',
|
||||
'https://raw.githubusercontent.com/'
|
||||
],
|
||||
// cdn.iocdn.cc
|
||||
[
|
||||
'cdn.iocdn.cc/avatar/',
|
||||
'https://secure.gravatar.com/avatar/'
|
||||
],
|
||||
[
|
||||
'cdn.iocdn.cc/css',
|
||||
'https://fonts.googleapis.com/css'
|
||||
],
|
||||
[
|
||||
'cdn.iocdn.cc/icon',
|
||||
'https://fonts.googleapis.com/icon'
|
||||
],
|
||||
[
|
||||
'cdn.iocdn.cc/earlyaccess',
|
||||
'https://fonts.googleapis.com/earlyaccess'
|
||||
],
|
||||
[
|
||||
'cdn.iocdn.cc/s',
|
||||
'fonts.gstatic.com/s'
|
||||
],
|
||||
[
|
||||
'cdn.iocdn.cc/static',
|
||||
'themes.googleusercontent.com/static'
|
||||
],
|
||||
[
|
||||
'cdn.iocdn.cc/ajax',
|
||||
'ajax.googleapis.com/ajax'
|
||||
],
|
||||
[
|
||||
'cdn.iocdn.cc/',
|
||||
'https://cdn.jsdelivr.net/'
|
||||
],
|
||||
// wp-china-yes
|
||||
[
|
||||
'googlefonts.admincdn.com/',
|
||||
'https://fonts.googleapis.com/'
|
||||
],
|
||||
[
|
||||
'googleajax.admincdn.com/',
|
||||
'https://ajax.googleapis.com/'
|
||||
],
|
||||
[
|
||||
'cdnjs.admincdn.com/',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/'
|
||||
],
|
||||
// Polyfill
|
||||
[
|
||||
'polyfill.io/',
|
||||
'https://cdnjs.cloudflare.com/polyfill/'
|
||||
],
|
||||
[
|
||||
'polyfill.top/',
|
||||
'https://cdnjs.cloudflare.com/polyfill/'
|
||||
],
|
||||
[
|
||||
'polyfill-js.cn/',
|
||||
'https://cdnjs.cloudflare.com/polyfill/'
|
||||
],
|
||||
[
|
||||
'cdn.polyfill.io/',
|
||||
'https://cdnjs.cloudflare.com/polyfill/'
|
||||
],
|
||||
[
|
||||
'fastly-polyfill.io/',
|
||||
'https://cdnjs.cloudflare.com/polyfill/'
|
||||
],
|
||||
[
|
||||
'fastly-polyfill.net/',
|
||||
'https://cdnjs.cloudflare.com/polyfill/'
|
||||
],
|
||||
// BootCDN has been controlled by a malicious actor and being used to spread malware
|
||||
[
|
||||
'cdn.bootcss.com/',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/'
|
||||
],
|
||||
[
|
||||
'cdn.bootcdn.net/',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/'
|
||||
],
|
||||
[
|
||||
'cdn.staticfile.net/',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/'
|
||||
],
|
||||
[
|
||||
'cdn.staticfile.org/',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/'
|
||||
],
|
||||
// Misc
|
||||
[
|
||||
'pics.javbus.com/',
|
||||
'https://i0.wp.com/pics.javbus.com/'
|
||||
]
|
||||
];
|
||||
const REDIRECT_MIRROR_307 = [
|
||||
// Redirect Google
|
||||
[
|
||||
'google.cn/',
|
||||
'https://google.com/'
|
||||
],
|
||||
[
|
||||
'www.google.cn/',
|
||||
'https://www.google.com/'
|
||||
],
|
||||
[
|
||||
'g.cn/',
|
||||
'https://google.com/'
|
||||
],
|
||||
[
|
||||
'ditu.google.cn/',
|
||||
'https://maps.google.com/'
|
||||
],
|
||||
[
|
||||
'maps.google.cn/',
|
||||
'https://maps.google.com/'
|
||||
],
|
||||
[
|
||||
'www.g.cn/',
|
||||
'https://www.google.com/'
|
||||
],
|
||||
// avg.tv/sm114514 -> https://www.nicovideo.jp/watch/sm114514
|
||||
[
|
||||
'acg.tv/sm',
|
||||
'https://www.nicovideo.jp/watch/sm'
|
||||
],
|
||||
[
|
||||
'acg.tv/',
|
||||
'https://b23.tv/'
|
||||
],
|
||||
// Minecraft Wiki
|
||||
[
|
||||
'minecraft.fandom.com/wiki/',
|
||||
'https://minecraft.wiki/w/'
|
||||
],
|
||||
[
|
||||
'minecraft.fandom.com/',
|
||||
'https://minecraft.wiki/'
|
||||
],
|
||||
[
|
||||
'missav.com/',
|
||||
'https://missav.ws/'
|
||||
]
|
||||
];
|
||||
const REDIRECT_FAKEWEBSITES = [
|
||||
// IGN China to IGN Global
|
||||
[
|
||||
'ign.xn--fiqs8s',
|
||||
'https://cn.ign.com/ccpref/us'
|
||||
],
|
||||
// Fuck Makeding
|
||||
[
|
||||
'abbyychina.com',
|
||||
'https://www.abbyy.cn'
|
||||
],
|
||||
[
|
||||
'bartender.cc',
|
||||
'https://cn.seagullscientific.com'
|
||||
],
|
||||
[
|
||||
'betterzip.net',
|
||||
'https://macitbetter.com'
|
||||
],
|
||||
[
|
||||
'beyondcompare.cc',
|
||||
'https://www.scootersoftware.com'
|
||||
],
|
||||
[
|
||||
'bingdianhuanyuan.cn',
|
||||
'https://www.faronics.com'
|
||||
],
|
||||
[
|
||||
'chemdraw.com.cn',
|
||||
'https://revvitysignals.com/products/research/chemdraw'
|
||||
],
|
||||
[
|
||||
'codesoftchina.com',
|
||||
'https://www.teklynx.com'
|
||||
],
|
||||
[
|
||||
'coreldrawchina.com',
|
||||
'https://www.coreldraw.com'
|
||||
],
|
||||
[
|
||||
'crossoverchina.com',
|
||||
'https://www.codeweavers.com'
|
||||
],
|
||||
[
|
||||
'easyrecoverychina.com',
|
||||
'https://www.ontrack.com'
|
||||
],
|
||||
[
|
||||
'ediuschina.com',
|
||||
'https://www.grassvalley.com'
|
||||
],
|
||||
[
|
||||
'flstudiochina.com',
|
||||
'https://www.image-line.com/fl-studio'
|
||||
],
|
||||
[
|
||||
'formysql.com',
|
||||
'https://www.navicat.com.cn'
|
||||
],
|
||||
[
|
||||
'guitarpro.cc',
|
||||
'https://www.guitar-pro.com'
|
||||
],
|
||||
[
|
||||
'huishenghuiying.com.cn',
|
||||
'https://www.corel.com'
|
||||
],
|
||||
[
|
||||
'iconworkshop.cn',
|
||||
'https://www.axialis.com/iconworkshop'
|
||||
],
|
||||
[
|
||||
'imindmap.cc',
|
||||
'https://imindmap.com/zh-cn'
|
||||
],
|
||||
[
|
||||
'jihehuaban.com.cn',
|
||||
'https://sketch.io'
|
||||
],
|
||||
[
|
||||
'keyshot.cc',
|
||||
'https://www.keyshot.com'
|
||||
],
|
||||
[
|
||||
'mathtype.cn',
|
||||
'https://www.wiris.com/en/mathtype'
|
||||
],
|
||||
[
|
||||
'mindmanager.cc',
|
||||
'https://www.mindjet.com'
|
||||
],
|
||||
[
|
||||
'mindmapper.cc',
|
||||
'https://mindmapper.com'
|
||||
],
|
||||
[
|
||||
'mycleanmymac.com',
|
||||
'https://macpaw.com/cleanmymac'
|
||||
],
|
||||
[
|
||||
'nicelabel.cc',
|
||||
'https://www.nicelabel.com'
|
||||
],
|
||||
[
|
||||
'ntfsformac.cc',
|
||||
'https://www.tuxera.com/products/tuxera-ntfs-for-mac-cn'
|
||||
],
|
||||
[
|
||||
'ntfsformac.cn',
|
||||
'https://www.paragon-software.com/ufsdhome/zh/ntfs-mac'
|
||||
],
|
||||
[
|
||||
'overturechina.com',
|
||||
'https://sonicscores.com/overture'
|
||||
],
|
||||
[
|
||||
'passwordrecovery.cn',
|
||||
'https://cn.elcomsoft.com/aopr.html'
|
||||
],
|
||||
[
|
||||
'pdfexpert.cc',
|
||||
'https://pdfexpert.com/zh'
|
||||
],
|
||||
[
|
||||
'ultraiso.net',
|
||||
'https://cn.ezbsystems.com/ultraiso'
|
||||
],
|
||||
[
|
||||
'vegaschina.cn',
|
||||
'https://www.vegas.com'
|
||||
],
|
||||
[
|
||||
'xmindchina.net',
|
||||
'https://www.xmind.cn'
|
||||
],
|
||||
[
|
||||
'xshellcn.com',
|
||||
'https://www.netsarang.com/products/xsh_overview.html'
|
||||
],
|
||||
[
|
||||
'yuanchengxiezuo.com',
|
||||
'https://www.teamviewer.com/zhcn'
|
||||
],
|
||||
[
|
||||
'zbrushcn.com',
|
||||
'https://www.maxon.net/en/zbrush'
|
||||
]
|
||||
];
|
||||
const buildRedirectModule = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const domains = Array.from(new Set([
|
||||
...REDIRECT_MIRROR_HEADER.map(([from])=>(0, _tldtsexperimental.getHostname)(from, {
|
||||
detectIp: false
|
||||
})),
|
||||
...REDIRECT_FAKEWEBSITES.flatMap(([from])=>[
|
||||
from,
|
||||
`*.${from}`
|
||||
]),
|
||||
...REDIRECT_MIRROR_307.map(([from])=>(0, _tldtsexperimental.getHostname)(from, {
|
||||
detectIp: false
|
||||
}))
|
||||
])).filter(_guard.isTruthy);
|
||||
return (0, _createfile.compareAndWriteFile)(span, [
|
||||
'#!name=[Sukka] URL Redirect',
|
||||
`#!desc=Last Updated: ${new Date().toISOString()} Size: ${domains.length}`,
|
||||
'',
|
||||
'[MITM]',
|
||||
`hostname = %APPEND% ${domains.join(', ')}`,
|
||||
'',
|
||||
'[URL Rewrite]',
|
||||
...REDIRECT_MIRROR_HEADER.map(([from, to])=>`^https?://${escapeRegExp(from)}(.*) ${to}$1 header`),
|
||||
...REDIRECT_FAKEWEBSITES.map(([from, to])=>`^https?://(www.)?${escapeRegExp(from)} ${to} 307`),
|
||||
...REDIRECT_MIRROR_307.map(([from, to])=>`^https?://${escapeRegExp(from)}(.*) ${to}$1 307`)
|
||||
], _nodepath.default.join(_dir.OUTPUT_MODULES_DIR, 'sukka_url_redirect.sgmodule'));
|
||||
});
|
||||
} (buildSgmoduleRedirect, buildSgmoduleRedirect.exports));
|
||||
return buildSgmoduleRedirect.exports;
|
||||
}exports.r=requireBuildSgmoduleRedirect;
|
||||
113
Dist/chunks/build-speedtest-domainset.D2jYMvWN.cjs
Normal file
113
Dist/chunks/build-speedtest-domainset.D2jYMvWN.cjs
Normal file
@@ -0,0 +1,113 @@
|
||||
'use strict';const require$$0=require('node:path'),require$$5=require('tldts-experimental'),index=require('./index.B8Uk9n3v.cjs'),base=require('./base.C13YY5P3.cjs'),fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),domainset=require('./domainset.CSQfKAtf.cjs'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),require$$7=require('@henrygd/queue');var buildSpeedtestDomainset = {exports: {}};var hasRequiredBuildSpeedtestDomainset;
|
||||
|
||||
function requireBuildSpeedtestDomainset () {
|
||||
if (hasRequiredBuildSpeedtestDomainset) return buildSpeedtestDomainset.exports;
|
||||
hasRequiredBuildSpeedtestDomainset = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildSpeedtestDomainSet", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildSpeedtestDomainSet;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _tldtsexperimental = /*#__PURE__*/ _interop_require_default(require$$5);
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _domainset = /*@__PURE__*/ domainset.r();
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _queue = require$$7;
|
||||
const _fetchretry = /*@__PURE__*/ fetchRetry.r();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const KEYWORDS = [
|
||||
'Hong Kong',
|
||||
'Taiwan',
|
||||
'China Telecom',
|
||||
'China Mobile',
|
||||
'China Unicom',
|
||||
'Japan',
|
||||
'Tokyo',
|
||||
'Singapore',
|
||||
'Korea',
|
||||
'Seoul',
|
||||
'Canada',
|
||||
'Toronto',
|
||||
'Montreal',
|
||||
'Los Ang',
|
||||
'San Jos',
|
||||
'Seattle',
|
||||
'New York',
|
||||
'Dallas',
|
||||
'Miami',
|
||||
'Berlin',
|
||||
'Frankfurt',
|
||||
'London',
|
||||
'Paris',
|
||||
'Amsterdam',
|
||||
'Moscow',
|
||||
'Australia',
|
||||
'Sydney',
|
||||
'Brazil',
|
||||
'Turkey'
|
||||
];
|
||||
const s = (0, _queue.newQueue)(2);
|
||||
const latestTopUserAgentsPromise = (0, _fetchretry.$$fetch)('https://raw.githubusercontent.com/microlinkhq/top-user-agents/master/src/desktop.json').then((res)=>res.json()).then((userAgents)=>userAgents.filter((ua)=>ua.startsWith('Mozilla/5.0 ')));
|
||||
const getSpeedtestHostsGroupsPromise = Promise.all(KEYWORDS.flatMap(querySpeedtestApi));
|
||||
const buildSpeedtestDomainSet = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const output = new _domainset.DomainsetOutput(span, 'speedtest').withTitle('Sukka\'s Ruleset - Speedtest Domains').withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
'This file contains common speedtest endpoints.'
|
||||
]).addFromDomainset((0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.resolve(_dir.SOURCE_DIR, 'domainset/speedtest.conf'))).addFromDomainset((0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.resolve(_dir.OUTPUT_SURGE_DIR, 'domainset/speedtest.conf')));
|
||||
const hostnameGroup = await span.traceChildPromise('get speedtest hosts groups', getSpeedtestHostsGroupsPromise);
|
||||
hostnameGroup.forEach(output.bulkAddDomain.bind(output));
|
||||
return output.write();
|
||||
});
|
||||
async function querySpeedtestApi(keyword) {
|
||||
const topUserAgents = await latestTopUserAgentsPromise;
|
||||
const url = `https://www.speedtest.net/api/js/servers?engine=js&search=${keyword}&limit=100`;
|
||||
try {
|
||||
const randomUserAgent = topUserAgents[Math.floor(Math.random() * topUserAgents.length)];
|
||||
const data = await s.add(()=>(0, _fetchretry.$$fetch)(url, {
|
||||
headers: {
|
||||
dnt: '1',
|
||||
Referer: 'https://www.speedtest.net/',
|
||||
accept: 'application/json, text/plain, */*',
|
||||
'User-Agent': randomUserAgent,
|
||||
'Accept-Language': 'en-US,en;q=0.9',
|
||||
...randomUserAgent.includes('Chrome') ? {
|
||||
'Sec-Ch-Ua-Mobile': '?0',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'Sec-Gpc': '1'
|
||||
} : {}
|
||||
},
|
||||
signal: AbortSignal.timeout(1000 * 60)
|
||||
}).then((res)=>res.json()));
|
||||
return data.reduce((prev, cur)=>{
|
||||
const hn = _tldtsexperimental.default.getHostname(cur.host || cur.url, {
|
||||
detectIp: false,
|
||||
validateHostname: true
|
||||
});
|
||||
if (hn) {
|
||||
prev.push(hn);
|
||||
}
|
||||
return prev;
|
||||
}, []);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
} (buildSpeedtestDomainset, buildSpeedtestDomainset.exports));
|
||||
return buildSpeedtestDomainset.exports;
|
||||
}exports.r=requireBuildSpeedtestDomainset;
|
||||
217
Dist/chunks/build-sspanel-appprofile.DbsFXAyN.cjs
Normal file
217
Dist/chunks/build-sspanel-appprofile.DbsFXAyN.cjs
Normal file
@@ -0,0 +1,217 @@
|
||||
'use strict';const buildAppleCdn=require('./build-apple-cdn.CNsnkTO_.cjs'),buildDomesticDirectLanRulesetDnsMappingModule=require('./build-domestic-direct-lan-ruleset-dns-mapping-module.T1tgVza_.cjs'),fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),index=require('./index.B8Uk9n3v.cjs'),require$$0=require('node:path'),stream=require('./stream.C9eZuk9f.cjs'),buildChnCidr=require('./build-chn-cidr.BjyqKcvm.cjs'),buildTelegramCidr=require('./build-telegram-cidr.05NmRbUx.cjs'),createFile=require('./create-file.loOMbJEN.cjs'),buildMicrosoftCdn=require('./build-microsoft-cdn.CCw86frc.cjs'),require$$6=require('foxts/guard'),base=require('./base.C13YY5P3.cjs'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),ruleset=require('./ruleset.iYH0XOC1.cjs');var buildSspanelAppprofile = {exports: {}};var hasRequiredBuildSspanelAppprofile;
|
||||
|
||||
function requireBuildSspanelAppprofile () {
|
||||
if (hasRequiredBuildSspanelAppprofile) return buildSspanelAppprofile.exports;
|
||||
hasRequiredBuildSspanelAppprofile = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildSSPanelUIMAppProfile", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildSSPanelUIMAppProfile;
|
||||
}
|
||||
});
|
||||
const _buildapplecdn = buildAppleCdn.r();
|
||||
const _builddomesticdirectlanrulesetdnsmappingmodule = buildDomesticDirectLanRulesetDnsMappingModule.r();
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _stream = /*@__PURE__*/ stream.r();
|
||||
const _buildchncidr = buildChnCidr.r();
|
||||
const _buildtelegramcidr = buildTelegramCidr.r();
|
||||
const _createfile = /*@__PURE__*/ createFile.r();
|
||||
const _buildmicrosoftcdn = buildMicrosoftCdn.r();
|
||||
const _guard = require$$6;
|
||||
const _appendarrayinplace = /*@__PURE__*/ base.a();
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _ruleset = /*@__PURE__*/ ruleset.r();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const POLICY_GROUPS = [
|
||||
[
|
||||
'Default Proxy',
|
||||
true,
|
||||
false
|
||||
],
|
||||
[
|
||||
'Global',
|
||||
true,
|
||||
true
|
||||
],
|
||||
[
|
||||
'Microsoft & Apple',
|
||||
true,
|
||||
true
|
||||
],
|
||||
[
|
||||
'Stream',
|
||||
true,
|
||||
false
|
||||
],
|
||||
[
|
||||
'Steam Download',
|
||||
true,
|
||||
true
|
||||
],
|
||||
[
|
||||
'Domestic',
|
||||
false,
|
||||
true
|
||||
],
|
||||
[
|
||||
'Final Match',
|
||||
true,
|
||||
true
|
||||
]
|
||||
];
|
||||
const steamDomainsPromise = (0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.SOURCE_DIR, 'domainset/game-download.conf'));
|
||||
const buildSSPanelUIMAppProfile = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const [[domesticRules, directRules, lanRules], appleCdnDomains, [microsoftCdnDomains, microsoftCdnDomainSuffixes], appleCnRules, neteaseMusicRules, microsoftRules, appleRules, streamRules, steamDomainset, globalRules, telegramRules, [domesticCidrs4, domesticCidrs6], [streamCidrs4, streamCidrs6], { ipcidr: telegramCidrs4, ipcidr6: telegramCidrs6 }, rawLanCidrs] = await Promise.all([
|
||||
// domestic - domains
|
||||
(0, _builddomesticdirectlanrulesetdnsmappingmodule.getDomesticAndDirectDomainsRulesetPromise)(),
|
||||
(0, _buildapplecdn.getAppleCdnDomainsPromise)(),
|
||||
(0, _buildmicrosoftcdn.getMicrosoftCdnRulesetPromise)(),
|
||||
(0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.OUTPUT_SURGE_DIR, 'non_ip/apple_cn.conf')),
|
||||
(0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.OUTPUT_SURGE_DIR, 'non_ip/neteasemusic.conf')),
|
||||
// microsoft & apple - domains
|
||||
(0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.OUTPUT_SURGE_DIR, 'non_ip/microsoft.conf')),
|
||||
(0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.OUTPUT_SURGE_DIR, 'non_ip/apple_services.conf')),
|
||||
// stream - domains
|
||||
_stream.ALL.flatMap((i)=>i.rules),
|
||||
// steam - domains
|
||||
steamDomainsPromise,
|
||||
// global - domains
|
||||
(0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.OUTPUT_SURGE_DIR, 'non_ip/global.conf')),
|
||||
(0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.OUTPUT_SURGE_DIR, 'non_ip/telegram.conf')),
|
||||
// domestic - ip cidr
|
||||
(0, _buildchncidr.getChnCidrPromise)(),
|
||||
_stream.ALL.reduce((acc, i)=>{
|
||||
if (i.ip) {
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(acc[0], i.ip.v4);
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(acc[1], i.ip.v6);
|
||||
}
|
||||
return acc;
|
||||
}, [
|
||||
[],
|
||||
[]
|
||||
]),
|
||||
// global - ip cidr
|
||||
(0, _buildtelegramcidr.getTelegramCIDRPromise)(),
|
||||
// lan - ip cidr
|
||||
(0, _fetchtextbyline.readFileIntoProcessedArray)(_nodepath.default.join(_dir.OUTPUT_SURGE_DIR, 'ip/lan.conf'))
|
||||
]);
|
||||
const domestic = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'non_ip').addFromRuleset(domesticRules).bulkAddDomainSuffix(appleCdnDomains).bulkAddDomain(microsoftCdnDomains).bulkAddDomainSuffix(microsoftCdnDomainSuffixes).addFromRuleset(appleCnRules).addFromRuleset(neteaseMusicRules);
|
||||
const microsoftApple = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'non_ip').addFromRuleset(microsoftRules).addFromRuleset(appleRules);
|
||||
const stream = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'non_ip').addFromRuleset(streamRules);
|
||||
const steam = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'non_ip').addFromDomainset(steamDomainset);
|
||||
const global = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'non_ip').addFromRuleset(globalRules).addFromRuleset(telegramRules);
|
||||
const direct = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'non_ip').addFromRuleset(directRules).addFromRuleset(lanRules);
|
||||
const domesticCidr = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'ip').bulkAddCIDR4(domesticCidrs4).bulkAddCIDR6(domesticCidrs6);
|
||||
const streamCidr = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'ip').bulkAddCIDR4(streamCidrs4).bulkAddCIDR6(streamCidrs6);
|
||||
const telegramCidr = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'ip').bulkAddCIDR4(telegramCidrs4).bulkAddCIDR6(telegramCidrs6);
|
||||
const lanCidrs = new _ruleset.ClashOnlyRulesetOutput(span, '_', 'ip').addFromRuleset(rawLanCidrs);
|
||||
const output = generateAppProfile(...(await Promise.all([
|
||||
domestic.compile(),
|
||||
microsoftApple.compile(),
|
||||
stream.compile(),
|
||||
steam.compile(),
|
||||
global.compile(),
|
||||
direct.compile(),
|
||||
domesticCidr.compile(),
|
||||
streamCidr.compile(),
|
||||
telegramCidr.compile(),
|
||||
lanCidrs.compile()
|
||||
])).map((output)=>(0, _guard.nullthrow)(output[0])));
|
||||
await (0, _createfile.compareAndWriteFile)(span, output, _nodepath.default.resolve(_dir.OUTPUT_INTERNAL_DIR, 'appprofile.php'));
|
||||
});
|
||||
function generateAppProfile(directDomains, microsoftAppleDomains, streamDomains, steamDomains, globalDomains, lanDomains, directCidrs, streamCidrs, globalCidrs, lanCidrs) {
|
||||
const redults = [
|
||||
'<?php',
|
||||
'',
|
||||
`// # Build ${new Date().toISOString()}`,
|
||||
'',
|
||||
'declare(strict_types=1);',
|
||||
'',
|
||||
'$_ENV[\'Clash_Config\'] = [',
|
||||
' \'port\' => 7890,',
|
||||
' \'socks-port\' => 7891,',
|
||||
' \'allow-lan\' => false,',
|
||||
' \'mode\' => \'Rule\',',
|
||||
' \'ipv6\' => true,',
|
||||
' \'log-level\' => \'error\',',
|
||||
' \'external-controller\' => \'0.0.0.0:9090\',',
|
||||
' \'tun\' => [',
|
||||
' \'enable\' => true,',
|
||||
' \'stack\' => \'system\',',
|
||||
' \'auto-route\' => true,',
|
||||
' \'auto-redir\' => true,',
|
||||
' \'auto-detect-interface\' => true,',
|
||||
' \'dns-hijack\' => [',
|
||||
' \'8.8.8.8:53\',',
|
||||
' \'any:53\',',
|
||||
' \'tcp://8.8.8.8:53\',',
|
||||
' \'tcp://any:53\',',
|
||||
' ]',
|
||||
' ]',
|
||||
'];',
|
||||
'',
|
||||
`$_ENV['Clash_Group_Indexes'] = [${JSON.stringify(POLICY_GROUPS.reduce((acc, [, insertProxy], index)=>{
|
||||
if (insertProxy) {
|
||||
acc.push(index);
|
||||
}
|
||||
return acc;
|
||||
}, [])).slice(1, -1)}];`,
|
||||
'$_ENV[\'Clash_Group_Config\'] = [',
|
||||
' \'proxy-groups\' => ['
|
||||
];
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, POLICY_GROUPS.flatMap(([name, insertProxy, insertDirect])=>[
|
||||
' [',
|
||||
` 'name' => '${name}',`,
|
||||
' \'type\' => \'select\',',
|
||||
' \'proxies\' => [',
|
||||
insertProxy && name !== 'Default Proxy' && ' \'Default Proxy\',',
|
||||
insertDirect && ' \'DIRECT\',',
|
||||
' ],',
|
||||
' ],'
|
||||
].filter(_guard.isTruthy)));
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, [
|
||||
' ],',
|
||||
' \'rules\' => ['
|
||||
]);
|
||||
// domestic - domains
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, directDomains.map((line)=>` '${line},Domestic',`));
|
||||
// microsoft & apple - domains
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, microsoftAppleDomains.map((line)=>` '${line},Microsoft & Apple',`));
|
||||
// stream - domains
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, streamDomains.map((line)=>` '${line},Stream',`));
|
||||
// steam download - domains
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, steamDomains.map((line)=>` '${line},Steam Download',`));
|
||||
// global - domains
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, globalDomains.map((line)=>` '${line},Global',`));
|
||||
// microsoft & apple - ip cidr (nope)
|
||||
// lan - domains
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, lanDomains.map((line)=>` '${line},DIRECT',`));
|
||||
// stream - ip cidr
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, streamCidrs.map((line)=>` '${line},Stream',`));
|
||||
// global - ip cidr
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, globalCidrs.map((line)=>` '${line},Global',`));
|
||||
// domestic - ip cidr
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, directCidrs.map((line)=>` '${line},Domestic',`));
|
||||
// lan - ip cidr
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, lanCidrs.map((line)=>` '${line},DIRECT',`));
|
||||
// match
|
||||
(0, _appendarrayinplace.appendArrayInPlace)(redults, [
|
||||
' \'MATCH,Final Match\',',
|
||||
' ],',
|
||||
'];'
|
||||
]);
|
||||
return redults;
|
||||
}
|
||||
} (buildSspanelAppprofile, buildSspanelAppprofile.exports));
|
||||
return buildSspanelAppprofile.exports;
|
||||
}exports.r=requireBuildSspanelAppprofile;
|
||||
48
Dist/chunks/build-stream-service.BKBKJK6i.cjs
Normal file
48
Dist/chunks/build-stream-service.BKBKJK6i.cjs
Normal file
@@ -0,0 +1,48 @@
|
||||
'use strict';const index=require('./index.B8Uk9n3v.cjs'),stream=require('./stream.C9eZuk9f.cjs'),base=require('./base.C13YY5P3.cjs'),ruleset=require('./ruleset.iYH0XOC1.cjs');var buildStreamService = {exports: {}};var hasRequiredBuildStreamService;
|
||||
|
||||
function requireBuildStreamService () {
|
||||
if (hasRequiredBuildStreamService) return buildStreamService.exports;
|
||||
hasRequiredBuildStreamService = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "buildStreamService", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return buildStreamService;
|
||||
}
|
||||
});
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _stream = /*@__PURE__*/ stream.r();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _ruleset = /*@__PURE__*/ ruleset.r();
|
||||
function createRulesetForStreamService(span, fileId, title, streamServices) {
|
||||
return [
|
||||
// Domains
|
||||
new _ruleset.RulesetOutput(span, fileId, 'non_ip').withTitle(`Sukka's Ruleset - Stream Services: ${title}`).withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
...streamServices.map((i)=>`- ${i.name}`)
|
||||
]).addFromRuleset(streamServices.flatMap((i)=>i.rules)).write(),
|
||||
// IP
|
||||
new _ruleset.RulesetOutput(span, fileId, 'ip').withTitle(`Sukka's Ruleset - Stream Services IPs: ${title}`).withDescription([
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'',
|
||||
...streamServices.map((i)=>`- ${i.name}`)
|
||||
]).bulkAddCIDR4NoResolve(streamServices.flatMap((i)=>i.ip?.v4 ?? [])).bulkAddCIDR6NoResolve(streamServices.flatMap((i)=>i.ip?.v6 ?? [])).write()
|
||||
];
|
||||
}
|
||||
const buildStreamService = (0, _trace.task)(require.main === module, __filename)(async (span)=>Promise.all([
|
||||
createRulesetForStreamService(span, 'stream', 'All', _stream.ALL),
|
||||
createRulesetForStreamService(span, 'stream_us', 'North America', _stream.NORTH_AMERICA),
|
||||
createRulesetForStreamService(span, 'stream_eu', 'Europe', _stream.EU),
|
||||
createRulesetForStreamService(span, 'stream_hk', 'Hong Kong', _stream.HK),
|
||||
createRulesetForStreamService(span, 'stream_tw', 'Taiwan', _stream.TW),
|
||||
createRulesetForStreamService(span, 'stream_jp', 'Japan', _stream.JP),
|
||||
// createRulesetForStreamService('stream_au', 'Oceania', AU),
|
||||
createRulesetForStreamService(span, 'stream_kr', 'Korean', _stream.KR)
|
||||
].flat()));
|
||||
} (buildStreamService, buildStreamService.exports));
|
||||
return buildStreamService.exports;
|
||||
}exports.r=requireBuildStreamService;
|
||||
69
Dist/chunks/build-telegram-cidr.05NmRbUx.cjs
Normal file
69
Dist/chunks/build-telegram-cidr.05NmRbUx.cjs
Normal file
@@ -0,0 +1,69 @@
|
||||
'use strict';const fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),index=require('./index.B8Uk9n3v.cjs'),base=require('./base.C13YY5P3.cjs'),memoPromise=require('./memo-promise.BbOsVeGo.cjs'),ruleset=require('./ruleset.iYH0XOC1.cjs'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),misc=require('./misc.BpcQjda1.cjs');var buildTelegramCidr = {exports: {}};var hasRequiredBuildTelegramCidr;
|
||||
|
||||
function requireBuildTelegramCidr () {
|
||||
if (hasRequiredBuildTelegramCidr) return buildTelegramCidr.exports;
|
||||
hasRequiredBuildTelegramCidr = 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, {
|
||||
buildTelegramCIDR: function() {
|
||||
return buildTelegramCIDR;
|
||||
},
|
||||
getTelegramCIDRPromise: function() {
|
||||
return getTelegramCIDRPromise;
|
||||
}
|
||||
});
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _description = /*@__PURE__*/ base.r();
|
||||
const _memopromise = /*@__PURE__*/ memoPromise.r();
|
||||
const _ruleset = /*@__PURE__*/ ruleset.r();
|
||||
const _fetchretry = /*@__PURE__*/ fetchRetry.r();
|
||||
const _misc = /*@__PURE__*/ misc.r();
|
||||
const getTelegramCIDRPromise = (0, _memopromise.createMemoizedPromise)(async ()=>{
|
||||
const resp = await (0, _fetchretry.$$fetch)('https://core.telegram.org/resources/cidr.txt');
|
||||
const lastModified = resp.headers.get('last-modified');
|
||||
const date = lastModified ? new Date(lastModified) : new Date();
|
||||
const ipcidr = [
|
||||
// Telegram secret backup CIDR, announced by AS62041
|
||||
// see also https://github.com/Telegram-FOSS-Team/Telegram-FOSS/blob/10da5406ed92d30c6add3b25d40b2b3b6995d873/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java#L1157
|
||||
'95.161.64.0/20'
|
||||
];
|
||||
const ipcidr6 = [];
|
||||
for await (const cidr of (0, _fetchtextbyline.createReadlineInterfaceFromResponse)(resp, true)){
|
||||
const v = (0, _misc.fastIpVersion)(cidr);
|
||||
if (v === 4) {
|
||||
ipcidr.push(cidr);
|
||||
} else if (v === 6) {
|
||||
ipcidr6.push(cidr);
|
||||
}
|
||||
}
|
||||
return {
|
||||
date,
|
||||
ipcidr,
|
||||
ipcidr6
|
||||
};
|
||||
});
|
||||
const buildTelegramCIDR = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const { date, ipcidr, ipcidr6 } = await span.traceChildAsync('get telegram cidr', getTelegramCIDRPromise);
|
||||
if (ipcidr.length + ipcidr6.length === 0) {
|
||||
throw new Error('Failed to fetch data!');
|
||||
}
|
||||
const description = [
|
||||
..._description.SHARED_DESCRIPTION,
|
||||
'Data from:',
|
||||
' - https://core.telegram.org/resources/cidr.txt'
|
||||
];
|
||||
return new _ruleset.RulesetOutput(span, 'telegram', 'ip').withTitle('Sukka\'s Ruleset - Telegram IP CIDR').withDescription(description).withDate(date).bulkAddCIDR4NoResolve(ipcidr).bulkAddCIDR6NoResolve(ipcidr6).write();
|
||||
});
|
||||
} (buildTelegramCidr, buildTelegramCidr.exports));
|
||||
return buildTelegramCidr.exports;
|
||||
}exports.r=requireBuildTelegramCidr;
|
||||
114
Dist/chunks/create-file.loOMbJEN.cjs
Normal file
114
Dist/chunks/create-file.loOMbJEN.cjs
Normal file
@@ -0,0 +1,114 @@
|
||||
'use strict';const require$$0=require('foxts/async-write-to-stream'),require$$3=require('foxts/fast-string-array-join'),require$$1=require('node:fs'),require$$0$1=require('picocolors'),fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),misc=require('./misc.BpcQjda1.cjs');var createFile = {};var hasRequiredCreateFile;
|
||||
|
||||
function requireCreateFile () {
|
||||
if (hasRequiredCreateFile) return createFile;
|
||||
hasRequiredCreateFile = 1;
|
||||
(function (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, {
|
||||
compareAndWriteFile: function() {
|
||||
return compareAndWriteFile;
|
||||
},
|
||||
fileEqual: function() {
|
||||
return fileEqual;
|
||||
}
|
||||
});
|
||||
const _asyncwritetostream = require$$0;
|
||||
const _faststringarrayjoin = require$$3;
|
||||
const _nodefs = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
const _picocolors = /*#__PURE__*/ _interop_require_default(require$$0$1);
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _misc = /*@__PURE__*/ misc.r();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
async function fileEqual(linesA, source) {
|
||||
if (linesA.length === 0) {
|
||||
return false;
|
||||
}
|
||||
const linesABound = linesA.length - 1;
|
||||
let index = -1;
|
||||
for await (const lineB of source){
|
||||
index++;
|
||||
if (index > linesABound) {
|
||||
return index === linesA.length && lineB.length === 0;
|
||||
}
|
||||
const lineA = linesA[index];
|
||||
if (lineA.length === 0) {
|
||||
if (lineB.length === 0) {
|
||||
continue;
|
||||
}
|
||||
// lineA is empty but lineB is not
|
||||
return false;
|
||||
}
|
||||
// now lineA can not be empty
|
||||
if (lineB.length === 0) {
|
||||
// lineB is empty but lineA is not
|
||||
return false;
|
||||
}
|
||||
// now both lines can not be empty
|
||||
const firstCharA = lineA.charCodeAt(0);
|
||||
const firstCharB = lineB.charCodeAt(0);
|
||||
if (firstCharA !== firstCharB) {
|
||||
return false;
|
||||
}
|
||||
// now firstCharA is equal to firstCharB, we only need to check the first char
|
||||
if (firstCharA === 35 /* # */ ) {
|
||||
continue;
|
||||
}
|
||||
// adguard conf
|
||||
if (firstCharA === 33 /* ! */ ) {
|
||||
continue;
|
||||
}
|
||||
if (firstCharA === 47 /* / */ && lineA[1] === '/' && lineB[1] === '/' && lineA[3] === '#' && lineB[3] === '#') {
|
||||
continue;
|
||||
}
|
||||
if (lineA !== lineB) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// The file becomes larger
|
||||
return !(index < linesABound);
|
||||
}
|
||||
async function compareAndWriteFile(span, linesA, filePath) {
|
||||
const linesALen = linesA.length;
|
||||
const isEqual = await span.traceChildAsync(`compare ${filePath}`, async ()=>{
|
||||
if (_nodefs.default.existsSync(filePath)) {
|
||||
return fileEqual(linesA, (0, _fetchtextbyline.readFileByLine)(filePath));
|
||||
}
|
||||
console.log(`${filePath} does not exists, writing...`);
|
||||
return false;
|
||||
});
|
||||
if (isEqual) {
|
||||
console.log(_picocolors.default.gray(_picocolors.default.dim(`same content, bail out writing: ${filePath}`)));
|
||||
return;
|
||||
}
|
||||
await span.traceChildAsync(`writing ${filePath}`, async ()=>{
|
||||
// The default highwater mark is normally 16384,
|
||||
// So we make sure direct write to file if the content is
|
||||
// most likely less than 500 lines
|
||||
if (linesALen < 500) {
|
||||
return (0, _misc.writeFile)(filePath, (0, _faststringarrayjoin.fastStringArrayJoin)(linesA, '\n') + '\n');
|
||||
}
|
||||
const writeStream = _nodefs.default.createWriteStream(filePath);
|
||||
for(let i = 0; i < linesALen; i++){
|
||||
const p = (0, _asyncwritetostream.asyncWriteToStream)(writeStream, linesA[i] + '\n');
|
||||
// eslint-disable-next-line no-await-in-loop -- stream high water mark
|
||||
if (p) await p;
|
||||
}
|
||||
writeStream.end();
|
||||
});
|
||||
}
|
||||
} (createFile));
|
||||
return createFile;
|
||||
}exports.r=requireCreateFile;
|
||||
159
Dist/chunks/domainset.CSQfKAtf.cjs
Normal file
159
Dist/chunks/domainset.CSQfKAtf.cjs
Normal file
@@ -0,0 +1,159 @@
|
||||
'use strict';const require$$0=require('foxts/escape-string-regexp'),base=require('./base.C13YY5P3.cjs'),require$$2=require('foxts/noop'),misc=require('./misc.BpcQjda1.cjs');var domainset = {};var adguardhome = {};var hasRequiredAdguardhome;
|
||||
|
||||
function requireAdguardhome () {
|
||||
if (hasRequiredAdguardhome) return adguardhome;
|
||||
hasRequiredAdguardhome = 1;
|
||||
(function (exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "AdGuardHome", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return AdGuardHome;
|
||||
}
|
||||
});
|
||||
const _escapestringregexp = require$$0;
|
||||
const _base = /*@__PURE__*/ base.d();
|
||||
const _noop = require$$2;
|
||||
const _misc = /*@__PURE__*/ misc.r();
|
||||
class AdGuardHome extends _base.BaseWriteStrategy {
|
||||
// readonly type = 'domainset';
|
||||
fileExtension = 'txt';
|
||||
type = '';
|
||||
result = [];
|
||||
// eslint-disable-next-line @typescript-eslint/class-methods-use-this -- abstract method
|
||||
withPadding(title, description, date, content) {
|
||||
return [
|
||||
`! Title: ${title}`,
|
||||
'! Last modified: ' + date.toUTCString(),
|
||||
'! Expires: 6 hours',
|
||||
'! License: https://github.com/SukkaW/Surge/blob/master/LICENSE',
|
||||
'! Homepage: https://github.com/SukkaW/Surge',
|
||||
`! Description: ${description.join(' ')}`,
|
||||
'!',
|
||||
...content,
|
||||
'! EOF'
|
||||
];
|
||||
}
|
||||
writeDomain(domain) {
|
||||
this.result.push(`|${domain}^`);
|
||||
}
|
||||
// const whitelistArray = sortDomains(Array.from(whitelist));
|
||||
// for (let i = 0, len = whitelistArray.length; i < len; i++) {
|
||||
// const domain = whitelistArray[i];
|
||||
// if (domain[0] === '.') {
|
||||
// results.push(`@@||${domain.slice(1)}^`);
|
||||
// } else {
|
||||
// results.push(`@@|${domain}^`);
|
||||
// }
|
||||
// }
|
||||
writeDomainSuffix(domain) {
|
||||
this.result.push(`||${domain}^`);
|
||||
}
|
||||
writeDomainKeywords(keywords) {
|
||||
for (const keyword of keywords){
|
||||
// Use regex to match keyword
|
||||
this.result.push(`/${(0, _escapestringregexp.escapeStringRegexp)(keyword)}/`);
|
||||
}
|
||||
}
|
||||
writeDomainWildcards(wildcards) {
|
||||
for (const wildcard of wildcards){
|
||||
const processed = wildcard.replaceAll('?', '*');
|
||||
if (processed.startsWith('*.')) {
|
||||
this.result.push(`||${processed.slice(2)}^`);
|
||||
} else {
|
||||
this.result.push(`|${processed}^`);
|
||||
}
|
||||
}
|
||||
}
|
||||
writeUserAgents = _noop.noop;
|
||||
writeProcessNames = _noop.noop;
|
||||
writeProcessPaths = _noop.noop;
|
||||
writeUrlRegexes = _noop.noop;
|
||||
writeIpCidrs(ipGroup, noResolve) {
|
||||
if (noResolve) {
|
||||
// When IP is provided to AdGuardHome, any domain resolve to those IP will be blocked
|
||||
// So we can't do noResolve
|
||||
return;
|
||||
}
|
||||
for (const ipcidr of ipGroup){
|
||||
if (ipcidr.endsWith('/32')) {
|
||||
this.result.push(`||${ipcidr.slice(0, -3)}`);
|
||||
/* else if (ipcidr.endsWith('.0/24')) {
|
||||
results.push(`||${ipcidr.slice(0, -6)}.*`);
|
||||
} */ } else {
|
||||
this.result.push(`||${ipcidr}^`);
|
||||
}
|
||||
}
|
||||
}
|
||||
writeIpCidr6s(ipGroup, noResolve) {
|
||||
if (noResolve) {
|
||||
// When IP is provided to AdGuardHome, any domain resolve to those IP will be blocked
|
||||
// So we can't do noResolve
|
||||
return;
|
||||
}
|
||||
for (const ipcidr of ipGroup){
|
||||
if (ipcidr.endsWith('/128')) {
|
||||
this.result.push(`||${ipcidr.slice(0, -4)}`);
|
||||
} else {
|
||||
this.result.push(`||${ipcidr}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
writeGeoip = (0, _misc.notSupported)('writeGeoip');
|
||||
writeIpAsns = (0, _misc.notSupported)('writeIpAsns');
|
||||
writeSourceIpCidrs = (0, _misc.notSupported)('writeSourceIpCidrs');
|
||||
writeSourcePorts = (0, _misc.notSupported)('writeSourcePorts');
|
||||
writeDestinationPorts = _noop.noop;
|
||||
writeOtherRules = _noop.noop;
|
||||
}
|
||||
} (adguardhome));
|
||||
return adguardhome;
|
||||
}var hasRequiredDomainset;
|
||||
|
||||
function requireDomainset () {
|
||||
if (hasRequiredDomainset) return domainset;
|
||||
hasRequiredDomainset = 1;
|
||||
(function (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, {
|
||||
AdGuardHomeOutput: function() {
|
||||
return AdGuardHomeOutput;
|
||||
},
|
||||
DomainsetOutput: function() {
|
||||
return DomainsetOutput;
|
||||
}
|
||||
});
|
||||
const _adguardhome = /*@__PURE__*/ requireAdguardhome();
|
||||
const _clash = /*@__PURE__*/ base.c();
|
||||
const _singbox = /*@__PURE__*/ base.f();
|
||||
const _surge = /*@__PURE__*/ base.e();
|
||||
const _base = /*@__PURE__*/ base.b();
|
||||
class DomainsetOutput extends _base.FileOutput {
|
||||
strategies = [
|
||||
new _surge.SurgeDomainSet(),
|
||||
new _clash.ClashDomainSet(),
|
||||
new _singbox.SingboxSource('domainset')
|
||||
];
|
||||
}
|
||||
class AdGuardHomeOutput extends _base.FileOutput {
|
||||
strategies;
|
||||
constructor(span, id, outputDir){
|
||||
super(span, id);
|
||||
this.strategies = [
|
||||
new _adguardhome.AdGuardHome(outputDir)
|
||||
];
|
||||
}
|
||||
}
|
||||
} (domainset));
|
||||
return domainset;
|
||||
}exports.r=requireDomainset;
|
||||
58
Dist/chunks/download-mock-assets.Dk5F6scb.cjs
Normal file
58
Dist/chunks/download-mock-assets.Dk5F6scb.cjs
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';const index=require('./index.B8Uk9n3v.cjs'),require$$0=require('node:path'),require$$1=require('node:fs'),require$$2=require('node:stream/promises'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),misc=require('./misc.BpcQjda1.cjs');var downloadMockAssets = {exports: {}};var hasRequiredDownloadMockAssets;
|
||||
|
||||
function requireDownloadMockAssets () {
|
||||
if (hasRequiredDownloadMockAssets) return downloadMockAssets.exports;
|
||||
hasRequiredDownloadMockAssets = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "downloadMockAssets", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return downloadMockAssets;
|
||||
}
|
||||
});
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _nodefs = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
const _promises = require$$2;
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _misc = /*@__PURE__*/ misc.r();
|
||||
const _fetchretry = /*@__PURE__*/ fetchRetry.r();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const ASSETS_LIST = {
|
||||
'www-google-analytics-com_ga.js': 'https://unpkg.com/@adguard/scriptlets@latest/dist/redirect-files/google-analytics-ga.js',
|
||||
'www-googletagservices-com_gpt.js': 'https://unpkg.com/@adguard/scriptlets@latest/dist/redirect-files/googletagservices-gpt.js',
|
||||
'www-google-analytics-com_analytics.js': 'https://unpkg.com/@adguard/scriptlets@latest/dist/redirect-files/google-analytics.js',
|
||||
'www-googlesyndication-com_adsbygoogle.js': 'https://unpkg.com/@adguard/scriptlets@latest/dist/redirect-files/googlesyndication-adsbygoogle.js',
|
||||
'amazon-adsystem-com_amazon-apstag.js': 'https://unpkg.com/@adguard/scriptlets@latest/dist/redirect-files/amazon-apstag.js'
|
||||
};
|
||||
const downloadMockAssets = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
const p = (0, _misc.mkdirp)(_dir.OUTPUT_MOCK_DIR);
|
||||
if (p) {
|
||||
await p;
|
||||
}
|
||||
return Promise.all(Object.entries(ASSETS_LIST).map(([filename, url])=>span.traceChildAsync(url, async ()=>{
|
||||
const res = await (0, _fetchretry.$$fetch)(url);
|
||||
if (!res.ok) {
|
||||
console.error(`Failed to download ${url}`);
|
||||
// we can safely skip this since we can always use previous version
|
||||
return;
|
||||
}
|
||||
if (!res.body) {
|
||||
console.error(`Empty body from ${url}`);
|
||||
// we can safely skip this since we can always use previous version
|
||||
return;
|
||||
}
|
||||
const src = _nodepath.default.join(_dir.OUTPUT_MOCK_DIR, filename);
|
||||
return (0, _promises.pipeline)(res.body, _nodefs.default.createWriteStream(src, 'utf-8'));
|
||||
})));
|
||||
});
|
||||
} (downloadMockAssets, downloadMockAssets.exports));
|
||||
return downloadMockAssets.exports;
|
||||
}exports.r=requireDownloadMockAssets;
|
||||
99
Dist/chunks/download-previous-build.-XKJmEYz.cjs
Normal file
99
Dist/chunks/download-previous-build.-XKJmEYz.cjs
Normal file
@@ -0,0 +1,99 @@
|
||||
'use strict';const require$$0$1=require('node:path'),require$$1$1=require('node:fs'),require$$2=require('node:stream/promises'),index=require('./index.B8Uk9n3v.cjs'),require$$4=require('tar-fs'),require$$5=require('node:zlib'),require$$1=require('undici'),require$$0=require('picocolors'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),misc=require('./misc.BpcQjda1.cjs'),require$$11=require('ci-info');var downloadPreviousBuild = {exports: {}};var hasRequiredDownloadPreviousBuild;
|
||||
|
||||
function requireDownloadPreviousBuild () {
|
||||
if (hasRequiredDownloadPreviousBuild) return downloadPreviousBuild.exports;
|
||||
hasRequiredDownloadPreviousBuild = 1;
|
||||
(function (module, exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "downloadPreviousBuild", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return downloadPreviousBuild;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0$1);
|
||||
const _nodefs = /*#__PURE__*/ _interop_require_default(require$$1$1);
|
||||
const _promises = require$$2;
|
||||
const _trace = /*@__PURE__*/ index.r();
|
||||
const _tarfs = require$$4;
|
||||
const _nodezlib = /*#__PURE__*/ _interop_require_default(require$$5);
|
||||
const _undici = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
const _picocolors = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
const _fetchretry = /*@__PURE__*/ fetchRetry.r();
|
||||
const _misc = /*@__PURE__*/ misc.r();
|
||||
const _ciinfo = require$$11;
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const GITHUB_CODELOAD_URL = 'https://codeload.github.com/sukkalab/ruleset.skk.moe/tar.gz/master';
|
||||
const GITLAB_CODELOAD_URL = 'https://gitlab.com/SukkaW/ruleset.skk.moe/-/archive/master/ruleset.skk.moe-master.tar.gz';
|
||||
const downloadPreviousBuild = (0, _trace.task)(require.main === module, __filename)(async (span)=>{
|
||||
if (_nodefs.default.existsSync(_dir.PUBLIC_DIR) && !(0, _misc.isDirectoryEmptySync)(_dir.PUBLIC_DIR)) {
|
||||
console.log(_picocolors.default.blue('Public directory exists, skip downloading previous build'));
|
||||
return;
|
||||
}
|
||||
// we uses actions/checkout to download the previous build now, so we should throw if the directory is empty
|
||||
if (_ciinfo.isCI) {
|
||||
throw new Error('CI environment detected, but public directory is empty');
|
||||
}
|
||||
const tarGzUrl = await span.traceChildAsync('get tar.gz url', async ()=>{
|
||||
const resp = await (0, _fetchretry.requestWithLog)(GITHUB_CODELOAD_URL, {
|
||||
method: 'HEAD'
|
||||
});
|
||||
if (resp.statusCode !== 200) {
|
||||
console.warn('Download previous build from GitHub failed! Status:', resp.statusCode);
|
||||
console.warn('Switch to GitLab');
|
||||
return GITLAB_CODELOAD_URL;
|
||||
}
|
||||
return GITHUB_CODELOAD_URL;
|
||||
});
|
||||
return span.traceChildAsync('download & extract previoud build', async ()=>{
|
||||
const respBody = _undici.default.pipeline(tarGzUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'User-Agent': 'curl/8.9.1',
|
||||
// https://github.com/unjs/giget/issues/97
|
||||
// https://gitlab.com/gitlab-org/gitlab/-/commit/50c11f278d18fe1f3fb12eb595067216bb58ade2
|
||||
'sec-fetch-mode': 'same-origin'
|
||||
},
|
||||
// Allow redirects by default
|
||||
maxRedirections: 5
|
||||
}, ({ statusCode, body })=>{
|
||||
if (statusCode !== 200) {
|
||||
console.warn('Download previous build failed! Status:', statusCode);
|
||||
if (statusCode === 404) {
|
||||
throw new Error('Download previous build failed! 404');
|
||||
}
|
||||
}
|
||||
return body;
|
||||
}).end();
|
||||
const pathPrefix = 'ruleset.skk.moe-master/';
|
||||
const gunzip = _nodezlib.default.createGunzip();
|
||||
const extract = (0, _tarfs.extract)(_dir.PUBLIC_DIR, {
|
||||
ignore (_, header) {
|
||||
if (header) {
|
||||
if (header.type !== 'file' && header.type !== 'directory') {
|
||||
return true;
|
||||
}
|
||||
if (header.type === 'file' && _nodepath.default.extname(header.name) === '.ts') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
map (header) {
|
||||
header.name = header.name.replace(pathPrefix, '');
|
||||
return header;
|
||||
}
|
||||
});
|
||||
return (0, _promises.pipeline)(respBody, gunzip, extract);
|
||||
});
|
||||
});
|
||||
} (downloadPreviousBuild, downloadPreviousBuild.exports));
|
||||
return downloadPreviousBuild.exports;
|
||||
}exports.r=requireDownloadPreviousBuild;
|
||||
81
Dist/chunks/fetch-assets.aqw2YOi8.cjs
Normal file
81
Dist/chunks/fetch-assets.aqw2YOi8.cjs
Normal file
@@ -0,0 +1,81 @@
|
||||
'use strict';const require$$0=require('picocolors'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),require$$2=require('foxts/wait'),require$$6=require('foxts/guard'),fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs');var fetchAssets = {};var hasRequiredFetchAssets;
|
||||
|
||||
function requireFetchAssets () {
|
||||
if (hasRequiredFetchAssets) return fetchAssets;
|
||||
hasRequiredFetchAssets = 1;
|
||||
(function (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, {
|
||||
CustomAbortError: function() {
|
||||
return CustomAbortError;
|
||||
},
|
||||
fetchAssets: function() {
|
||||
return fetchAssets;
|
||||
}
|
||||
});
|
||||
const _picocolors = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _fetchretry = /*@__PURE__*/ fetchRetry.r();
|
||||
const _wait = require$$2;
|
||||
const _guard = require$$6;
|
||||
const _textlinetransformstream = /*@__PURE__*/ fetchTextByLine.b();
|
||||
const _processline = /*@__PURE__*/ fetchTextByLine.r();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
class CustomAbortError extends Error {
|
||||
name = 'AbortError';
|
||||
digest = 'AbortError';
|
||||
}
|
||||
const reusedCustomAbortError = new CustomAbortError();
|
||||
async function fetchAssets(url, fallbackUrls, processLine = false) {
|
||||
const controller = new AbortController();
|
||||
const createFetchFallbackPromise = async (url, index)=>{
|
||||
if (index >= 0) {
|
||||
// Most assets can be downloaded within 250ms. To avoid wasting bandwidth, we will wait for 500ms before downloading from the fallback URL.
|
||||
try {
|
||||
await (0, _wait.waitWithAbort)(50 + (index + 1) * 100, controller.signal);
|
||||
} catch {
|
||||
console.log(_picocolors.default.gray('[fetch cancelled early]'), _picocolors.default.gray(url));
|
||||
throw reusedCustomAbortError;
|
||||
}
|
||||
}
|
||||
if (controller.signal.aborted) {
|
||||
console.log(_picocolors.default.gray('[fetch cancelled]'), _picocolors.default.gray(url));
|
||||
throw reusedCustomAbortError;
|
||||
}
|
||||
const res = await (0, _fetchretry.$$fetch)(url, {
|
||||
signal: controller.signal,
|
||||
..._fetchretry.defaultRequestInit
|
||||
});
|
||||
let stream = (0, _guard.nullthrow)(res.body).pipeThrough(new TextDecoderStream()).pipeThrough(new _textlinetransformstream.TextLineStream());
|
||||
if (processLine) {
|
||||
stream = stream.pipeThrough(new _processline.ProcessLineStream());
|
||||
}
|
||||
const arr = await Array.fromAsync(stream);
|
||||
if (arr.length < 1) {
|
||||
throw new _fetchretry.ResponseError(res, url, 'empty response w/o 304');
|
||||
}
|
||||
controller.abort();
|
||||
return arr;
|
||||
};
|
||||
if (!fallbackUrls || fallbackUrls.length === 0) {
|
||||
return createFetchFallbackPromise(url, -1);
|
||||
}
|
||||
return Promise.any([
|
||||
createFetchFallbackPromise(url, -1),
|
||||
...fallbackUrls.map(createFetchFallbackPromise)
|
||||
]);
|
||||
}
|
||||
} (fetchAssets));
|
||||
return fetchAssets;
|
||||
}exports.r=requireFetchAssets;
|
||||
307
Dist/chunks/fetch-retry.D06uBUaW.cjs
Normal file
307
Dist/chunks/fetch-retry.D06uBUaW.cjs
Normal file
@@ -0,0 +1,307 @@
|
||||
'use strict';const require$$0$1=require('picocolors'),require$$1$1=require('undici'),require$$2=require('undici-cache-store-better-sqlite3'),require$$1$3=require('node:util'),require$$0=require('node:path'),require$$1$2=require('node:fs'),require$$1=require('node:process');function getDefaultExportFromCjs (x) {
|
||||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
||||
}var fetchRetry = {};var dir = {};var hasRequiredDir;
|
||||
|
||||
function requireDir () {
|
||||
if (hasRequiredDir) return dir;
|
||||
hasRequiredDir = 1;
|
||||
(function (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, {
|
||||
CACHE_DIR: function() {
|
||||
return CACHE_DIR;
|
||||
},
|
||||
OUTPUT_CLASH_DIR: function() {
|
||||
return OUTPUT_CLASH_DIR;
|
||||
},
|
||||
OUTPUT_INTERNAL_DIR: function() {
|
||||
return OUTPUT_INTERNAL_DIR;
|
||||
},
|
||||
OUTPUT_MOCK_DIR: function() {
|
||||
return OUTPUT_MOCK_DIR;
|
||||
},
|
||||
OUTPUT_MODULES_DIR: function() {
|
||||
return OUTPUT_MODULES_DIR;
|
||||
},
|
||||
OUTPUT_MODULES_RULES_DIR: function() {
|
||||
return OUTPUT_MODULES_RULES_DIR;
|
||||
},
|
||||
OUTPUT_SINGBOX_DIR: function() {
|
||||
return OUTPUT_SINGBOX_DIR;
|
||||
},
|
||||
OUTPUT_SURGE_DIR: function() {
|
||||
return OUTPUT_SURGE_DIR;
|
||||
},
|
||||
PUBLIC_DIR: function() {
|
||||
return PUBLIC_DIR;
|
||||
},
|
||||
ROOT_DIR: function() {
|
||||
return ROOT_DIR;
|
||||
},
|
||||
SOURCE_DIR: function() {
|
||||
return SOURCE_DIR;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _nodeprocess = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const ROOT_DIR = _nodepath.default.resolve(__dirname, '../..');
|
||||
const CACHE_DIR = _nodepath.default.resolve(ROOT_DIR, '.cache');
|
||||
const SOURCE_DIR = _nodepath.default.join(ROOT_DIR, 'Source');
|
||||
const PUBLIC_DIR = _nodeprocess.default.env.PUBLIC_DIR || _nodepath.default.resolve(ROOT_DIR, 'public');
|
||||
const OUTPUT_SURGE_DIR = _nodepath.default.join(PUBLIC_DIR, 'List');
|
||||
const OUTPUT_CLASH_DIR = _nodepath.default.resolve(PUBLIC_DIR, 'Clash');
|
||||
const OUTPUT_SINGBOX_DIR = _nodepath.default.resolve(PUBLIC_DIR, 'sing-box');
|
||||
const OUTPUT_MODULES_DIR = _nodepath.default.resolve(PUBLIC_DIR, 'Modules');
|
||||
const OUTPUT_MODULES_RULES_DIR = _nodepath.default.resolve(OUTPUT_MODULES_DIR, 'Rules');
|
||||
const OUTPUT_INTERNAL_DIR = _nodepath.default.resolve(PUBLIC_DIR, 'Internal');
|
||||
const OUTPUT_MOCK_DIR = _nodepath.default.resolve(PUBLIC_DIR, 'Mock');
|
||||
} (dir));
|
||||
return dir;
|
||||
}var hasRequiredFetchRetry;
|
||||
|
||||
function requireFetchRetry () {
|
||||
if (hasRequiredFetchRetry) return fetchRetry;
|
||||
hasRequiredFetchRetry = 1;
|
||||
(function (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, {
|
||||
$$fetch: function() {
|
||||
return $$fetch;
|
||||
},
|
||||
ResponseError: function() {
|
||||
return ResponseError;
|
||||
},
|
||||
defaultRequestInit: function() {
|
||||
return defaultRequestInit;
|
||||
},
|
||||
requestWithLog: function() {
|
||||
return requestWithLog;
|
||||
}
|
||||
});
|
||||
const _picocolors = /*#__PURE__*/ _interop_require_default(require$$0$1);
|
||||
const _undici = /*#__PURE__*/ _interop_require_wildcard(require$$1$1);
|
||||
const _undicicachestorebettersqlite3 = require$$2;
|
||||
const _nodeutil = require$$1$3;
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _nodefs = /*#__PURE__*/ _interop_require_default(require$$1$2);
|
||||
const _dir = /*@__PURE__*/ requireDir();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function _getRequireWildcardCache(nodeInterop) {
|
||||
if (typeof WeakMap !== "function") return null;
|
||||
var cacheBabelInterop = new WeakMap();
|
||||
var cacheNodeInterop = new WeakMap();
|
||||
return (_getRequireWildcardCache = function(nodeInterop) {
|
||||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
||||
})(nodeInterop);
|
||||
}
|
||||
function _interop_require_wildcard(obj, nodeInterop) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
||||
return {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var cache = _getRequireWildcardCache(nodeInterop);
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {
|
||||
__proto__: null
|
||||
};
|
||||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for(var key in obj){
|
||||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
if (!_nodefs.default.existsSync(_dir.CACHE_DIR)) {
|
||||
_nodefs.default.mkdirSync(_dir.CACHE_DIR, {
|
||||
recursive: true
|
||||
});
|
||||
}
|
||||
const agent = new _undici.Agent({
|
||||
allowH2: true
|
||||
});
|
||||
(0, _undici.setGlobalDispatcher)(agent.compose(_undici.interceptors.dns({
|
||||
// disable IPv6
|
||||
dualStack: false,
|
||||
affinity: 4
|
||||
}), _undici.interceptors.retry({
|
||||
maxRetries: 5,
|
||||
minTimeout: 500,
|
||||
maxTimeout: 10 * 1000,
|
||||
// TODO: this part of code is only for allow more errors to be retried by default
|
||||
// This should be removed once https://github.com/nodejs/undici/issues/3728 is implemented
|
||||
retry (err, { state, opts }, cb) {
|
||||
const errorCode = 'code' in err ? err.code : undefined;
|
||||
// Any code that is not a Undici's originated and allowed to retry
|
||||
if (errorCode === 'ERR_UNESCAPED_CHARACTERS' || err.message === 'Request path contains unescaped characters' || err.name === 'AbortError') {
|
||||
return cb(err);
|
||||
}
|
||||
const statusCode = 'statusCode' in err && typeof err.statusCode === 'number' ? err.statusCode : null;
|
||||
// bail out if the status code matches one of the following
|
||||
if (statusCode != null && (statusCode === 401 // Unauthorized, should check credentials instead of retrying
|
||||
|| statusCode === 403 // Forbidden, should check permissions instead of retrying
|
||||
|| statusCode === 404 // Not Found, should check URL instead of retrying
|
||||
|| statusCode === 405 // Method Not Allowed, should check method instead of retrying
|
||||
)) {
|
||||
return cb(err);
|
||||
}
|
||||
// if (errorCode === 'UND_ERR_REQ_RETRY') {
|
||||
// return cb(err);
|
||||
// }
|
||||
const { maxRetries = 5, minTimeout = 500, maxTimeout = 10 * 1000, timeoutFactor = 2, methods = [
|
||||
'GET',
|
||||
'HEAD',
|
||||
'OPTIONS',
|
||||
'PUT',
|
||||
'DELETE',
|
||||
'TRACE'
|
||||
] } = opts.retryOptions || {};
|
||||
// If we reached the max number of retries
|
||||
if (state.counter > maxRetries) {
|
||||
return cb(err);
|
||||
}
|
||||
// If a set of method are provided and the current method is not in the list
|
||||
if (Array.isArray(methods) && !methods.includes(opts.method)) {
|
||||
return cb(err);
|
||||
}
|
||||
const headers = 'headers' in err && typeof err.headers === 'object' ? err.headers : undefined;
|
||||
const retryAfterHeader = headers?.['retry-after'];
|
||||
let retryAfter = -1;
|
||||
if (retryAfterHeader) {
|
||||
retryAfter = Number(retryAfterHeader);
|
||||
retryAfter = Number.isNaN(retryAfter) ? calculateRetryAfterHeader(retryAfterHeader) : retryAfter * 1e3; // Retry-After is in seconds
|
||||
}
|
||||
const retryTimeout = retryAfter > 0 ? Math.min(retryAfter, maxTimeout) : Math.min(minTimeout * timeoutFactor ** (state.counter - 1), maxTimeout);
|
||||
console.log('[fetch retry]', 'schedule retry', {
|
||||
statusCode,
|
||||
retryTimeout,
|
||||
errorCode,
|
||||
url: opts.origin
|
||||
});
|
||||
// eslint-disable-next-line sukka/prefer-timer-id -- won't leak
|
||||
setTimeout(()=>cb(null), retryTimeout);
|
||||
}
|
||||
}), _undici.interceptors.redirect({
|
||||
maxRedirections: 5
|
||||
}), _undici.interceptors.cache({
|
||||
store: new _undicicachestorebettersqlite3.BetterSqlite3CacheStore({
|
||||
location: _nodepath.default.join(_dir.CACHE_DIR, 'undici-better-sqlite3-cache-store.db'),
|
||||
maxEntrySize: 1024 * 1024 * 100 // 100 MiB
|
||||
})
|
||||
})));
|
||||
function calculateRetryAfterHeader(retryAfter) {
|
||||
const current = Date.now();
|
||||
return new Date(retryAfter).getTime() - current;
|
||||
}
|
||||
class ResponseError extends Error {
|
||||
res;
|
||||
url;
|
||||
code;
|
||||
statusCode;
|
||||
constructor(res, url, ...args){
|
||||
const statusCode = 'statusCode' in res ? res.statusCode : res.status;
|
||||
super('HTTP ' + statusCode + ' ' + args.map((_)=>(0, _nodeutil.inspect)(_)).join(' ')), this.res = res, this.url = url;
|
||||
if ('captureStackTrace' in Error) {
|
||||
Error.captureStackTrace(this, ResponseError);
|
||||
}
|
||||
// eslint-disable-next-line sukka/unicorn/custom-error-definition -- deliberatly use previous name
|
||||
this.name = this.constructor.name;
|
||||
this.res = res;
|
||||
this.code = statusCode;
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
}
|
||||
const defaultRequestInit = {
|
||||
headers: {
|
||||
'User-Agent': 'curl/8.9.1 (https://github.com/SukkaW/Surge)'
|
||||
}
|
||||
};
|
||||
async function $$fetch(url, init) {
|
||||
try {
|
||||
const res = await _undici.default.fetch(url, init);
|
||||
if (res.status >= 400) {
|
||||
throw new ResponseError(res, url);
|
||||
}
|
||||
if (!(res.status >= 200 && res.status <= 299) && res.status !== 304) {
|
||||
throw new ResponseError(res, url);
|
||||
}
|
||||
return res;
|
||||
} catch (err) {
|
||||
if (typeof err === 'object' && err !== null && 'name' in err) {
|
||||
if (err.name === 'AbortError' || 'digest' in err && err.digest === 'AbortError') {
|
||||
console.log(_picocolors.default.gray('[fetch abort]'), url);
|
||||
}
|
||||
} else {
|
||||
console.log(_picocolors.default.gray('[fetch fail]'), url, {
|
||||
name: err.name
|
||||
}, err);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
async function requestWithLog(url, opt) {
|
||||
try {
|
||||
const res = await _undici.default.request(url, opt);
|
||||
if (res.statusCode >= 400) {
|
||||
throw new ResponseError(res, url);
|
||||
}
|
||||
if (!(res.statusCode >= 200 && res.statusCode <= 299) && res.statusCode !== 304) {
|
||||
throw new ResponseError(res, url);
|
||||
}
|
||||
return res;
|
||||
} catch (err) {
|
||||
if (typeof err === 'object' && err !== null && 'name' in err) {
|
||||
if (err.name === 'AbortError' || 'digest' in err && err.digest === 'AbortError') {
|
||||
console.log(_picocolors.default.gray('[fetch abort]'), url);
|
||||
}
|
||||
} else {
|
||||
console.log(_picocolors.default.gray('[fetch fail]'), url, {
|
||||
name: err.name
|
||||
}, err);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
} (fetchRetry));
|
||||
return fetchRetry;
|
||||
}exports.a=requireDir;exports.g=getDefaultExportFromCjs;exports.r=requireFetchRetry;
|
||||
221
Dist/chunks/fetch-text-by-line.YY5b5610.cjs
Normal file
221
Dist/chunks/fetch-text-by-line.YY5b5610.cjs
Normal file
@@ -0,0 +1,221 @@
|
||||
'use strict';const require$$1=require('node:fs'),require$$1$1=require('node:readline'),require$$0=require('node:stream/web'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs'),require$$6=require('foxts/guard');var processLine = {};var hasRequiredProcessLine;
|
||||
|
||||
function requireProcessLine () {
|
||||
if (hasRequiredProcessLine) return processLine;
|
||||
hasRequiredProcessLine = 1;
|
||||
(function (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, {
|
||||
ProcessLineStream: function() {
|
||||
return ProcessLineStream;
|
||||
},
|
||||
processLine: function() {
|
||||
return processLine;
|
||||
}
|
||||
});
|
||||
const _web = require$$0;
|
||||
function processLine(line) {
|
||||
const trimmed = line.trim();
|
||||
if (trimmed.length === 0) {
|
||||
return null;
|
||||
}
|
||||
const line_0 = trimmed.charCodeAt(0);
|
||||
if (// line_0 === 32 /** [space] */
|
||||
// || line_0 === 13 /** \r */
|
||||
// || line_0 === 10 /** \n */
|
||||
line_0 === 33 /** ! */ || line_0 === 47 /** / */ && trimmed.charCodeAt(1) === 47 /** / */ ) {
|
||||
return null;
|
||||
}
|
||||
if (line_0 === 35 /** # */ ) {
|
||||
if (trimmed.charCodeAt(1) !== 35 /** # */ ) {
|
||||
// # Comment
|
||||
return null;
|
||||
}
|
||||
if (trimmed.charCodeAt(2) === 35 /** # */ && trimmed.charCodeAt(3) === 35) {
|
||||
// ################## EOF ##################
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* AdGuard Filter can be:
|
||||
*
|
||||
* ##.class
|
||||
* ##tag.class
|
||||
* ###id
|
||||
*/ }
|
||||
return trimmed;
|
||||
}
|
||||
class ProcessLineStream extends _web.TransformStream {
|
||||
// private __buf = '';
|
||||
constructor(){
|
||||
super({
|
||||
transform (l, controller) {
|
||||
const line = processLine(l);
|
||||
if (line) {
|
||||
controller.enqueue(line);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} // export class ProcessLineNodeStream extends Transform {
|
||||
// _transform(chunk: string, encoding: BufferEncoding, callback: TransformCallback) {
|
||||
// // Convert chunk to string and then to uppercase
|
||||
// const upperCased = chunk.toUpperCase();
|
||||
// // Push transformed data to readable side
|
||||
// this.push(upperCased);
|
||||
// // Call callback when done
|
||||
// callback();
|
||||
// }
|
||||
// }
|
||||
} (processLine));
|
||||
return processLine;
|
||||
}var fetchTextByLine = {};var textLineTransformStream = {};var hasRequiredTextLineTransformStream;
|
||||
|
||||
function requireTextLineTransformStream () {
|
||||
if (hasRequiredTextLineTransformStream) return textLineTransformStream;
|
||||
hasRequiredTextLineTransformStream = 1;
|
||||
(function (exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "TextLineStream", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return TextLineStream;
|
||||
}
|
||||
});
|
||||
const _web = require$$0;
|
||||
class TextLineStream extends _web.TransformStream {
|
||||
// private __buf = '';
|
||||
constructor({ allowCR = false } = {}){
|
||||
let __buf = '';
|
||||
let chunkIndex = 0;
|
||||
super({
|
||||
transform (chunk, controller) {
|
||||
chunk = __buf + chunk;
|
||||
chunkIndex = 0;
|
||||
for(;;){
|
||||
const lfIndex = chunk.indexOf('\n', chunkIndex);
|
||||
if (allowCR) {
|
||||
const crIndex = chunk.indexOf('\r', chunkIndex);
|
||||
if (crIndex !== -1 && crIndex !== chunk.length - 1 && (lfIndex === -1 || lfIndex - 1 > crIndex)) {
|
||||
controller.enqueue(chunk.slice(chunkIndex, crIndex));
|
||||
chunkIndex = crIndex + 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (lfIndex === -1) {
|
||||
break;
|
||||
}
|
||||
// enqueue current line, and loop again to find next line
|
||||
let crOrLfIndex = lfIndex;
|
||||
if (chunk[lfIndex - 1] === '\r') {
|
||||
crOrLfIndex--;
|
||||
}
|
||||
controller.enqueue(chunk.slice(chunkIndex, crOrLfIndex));
|
||||
chunkIndex = lfIndex + 1;
|
||||
continue;
|
||||
}
|
||||
__buf = chunk.slice(chunkIndex);
|
||||
},
|
||||
flush (controller) {
|
||||
if (__buf.length > 0) {
|
||||
// eslint-disable-next-line sukka/string/prefer-string-starts-ends-with -- performance
|
||||
if (allowCR && __buf[__buf.length - 1] === '\r') {
|
||||
controller.enqueue(__buf.slice(0, -1));
|
||||
} else {
|
||||
controller.enqueue(__buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} (textLineTransformStream));
|
||||
return textLineTransformStream;
|
||||
}var hasRequiredFetchTextByLine;
|
||||
|
||||
function requireFetchTextByLine () {
|
||||
if (hasRequiredFetchTextByLine) return fetchTextByLine;
|
||||
hasRequiredFetchTextByLine = 1;
|
||||
(function (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, {
|
||||
createReadlineInterfaceFromResponse: function() {
|
||||
return createReadlineInterfaceFromResponse;
|
||||
},
|
||||
fetchRemoteTextByLine: function() {
|
||||
return fetchRemoteTextByLine;
|
||||
},
|
||||
readFileByLine: function() {
|
||||
return readFileByLine;
|
||||
},
|
||||
readFileIntoProcessedArray: function() {
|
||||
return readFileIntoProcessedArray;
|
||||
}
|
||||
});
|
||||
const _nodefs = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
const _nodereadline = /*#__PURE__*/ _interop_require_default(require$$1$1);
|
||||
const _textlinetransformstream = /*@__PURE__*/ requireTextLineTransformStream();
|
||||
const _web = require$$0;
|
||||
const _processline = /*@__PURE__*/ requireProcessLine();
|
||||
const _fetchretry = /*@__PURE__*/ fetchRetry.r();
|
||||
const _guard = require$$6;
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function readFileByLine(file) {
|
||||
return _nodereadline.default.createInterface({
|
||||
input: _nodefs.default.createReadStream(file /* , { encoding: 'utf-8' } */ ),
|
||||
crlfDelay: Infinity
|
||||
});
|
||||
}
|
||||
const createReadlineInterfaceFromResponse = (resp, processLine = false)=>{
|
||||
(0, _guard.invariant)(resp.body, 'Failed to fetch remote text');
|
||||
if ('bodyUsed' in resp && resp.bodyUsed) {
|
||||
throw new Error('Body has already been consumed.');
|
||||
}
|
||||
let webStream;
|
||||
if ('pipeThrough' in resp.body) {
|
||||
webStream = resp.body;
|
||||
} else {
|
||||
throw new TypeError('Invalid response body!');
|
||||
}
|
||||
const resultStream = webStream.pipeThrough(new _web.TextDecoderStream()).pipeThrough(new _textlinetransformstream.TextLineStream());
|
||||
if (processLine) {
|
||||
return resultStream.pipeThrough(new _processline.ProcessLineStream());
|
||||
}
|
||||
return resultStream;
|
||||
};
|
||||
function fetchRemoteTextByLine(url, processLine = false) {
|
||||
return (0, _fetchretry.$$fetch)(url).then((resp)=>createReadlineInterfaceFromResponse(resp, processLine));
|
||||
}
|
||||
async function readFileIntoProcessedArray(file/* | FileHandle */ ) {
|
||||
const results = [];
|
||||
for await (const line of readFileByLine(file)){
|
||||
if ((0, _processline.processLine)(line)) {
|
||||
results.push(line);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
} (fetchTextByLine));
|
||||
return fetchTextByLine;
|
||||
}exports.a=requireFetchTextByLine;exports.b=requireTextLineTransformStream;exports.r=requireProcessLine;
|
||||
222
Dist/chunks/fs-memo.Dw823m02.cjs
Normal file
222
Dist/chunks/fs-memo.Dw823m02.cjs
Normal file
@@ -0,0 +1,222 @@
|
||||
'use strict';const require$$0$2=require('node:path'),require$$11=require('ci-info'),require$$0$1=require('picocolors'),require$$0=require('better-sqlite3'),require$$1$1=require('node:os'),require$$1=require('node:fs'),require$$3=require('foxts/fast-string-array-join'),require$$6=require('node:perf_hooks'),require$$4=require('foxts/serialized-memo'),fetchRetry=require('./fetch-retry.D06uBUaW.cjs');var cacheFilesystem = {};var hasRequiredCacheFilesystem;
|
||||
|
||||
function requireCacheFilesystem () {
|
||||
if (hasRequiredCacheFilesystem) return cacheFilesystem;
|
||||
hasRequiredCacheFilesystem = 1;
|
||||
(function (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, {
|
||||
Cache: function() {
|
||||
return Cache;
|
||||
},
|
||||
deserializeArray: function() {
|
||||
return deserializeArray;
|
||||
},
|
||||
serializeArray: function() {
|
||||
return serializeArray;
|
||||
}
|
||||
});
|
||||
const _bettersqlite3 = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _nodeos = /*#__PURE__*/ _interop_require_default(require$$1$1);
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0$2);
|
||||
const _nodefs = require$$1;
|
||||
const _picocolors = /*#__PURE__*/ _interop_require_default(require$$0$1);
|
||||
const _faststringarrayjoin = require$$3;
|
||||
const _nodeperf_hooks = require$$6;
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
class Cache {
|
||||
db;
|
||||
/** Time before deletion */ tbd = 60 * 1000;
|
||||
/** SQLite file path */ cachePath;
|
||||
/** Table name */ tableName;
|
||||
type;
|
||||
statement;
|
||||
constructor({ cachePath = _nodepath.default.join(_nodeos.default.tmpdir() || '/tmp', 'hdc'), tbd, tableName = 'cache', type } = {}){
|
||||
const start = _nodeperf_hooks.performance.now();
|
||||
this.cachePath = cachePath;
|
||||
(0, _nodefs.mkdirSync)(this.cachePath, {
|
||||
recursive: true
|
||||
});
|
||||
if (tbd != null) this.tbd = tbd;
|
||||
this.tableName = tableName;
|
||||
if (type) {
|
||||
this.type = type;
|
||||
} else {
|
||||
// @ts-expect-error -- fallback type
|
||||
this.type = 'string';
|
||||
}
|
||||
const db = (0, _bettersqlite3.default)(_nodepath.default.join(this.cachePath, 'cache.db'));
|
||||
db.pragma('journal_mode = WAL');
|
||||
db.pragma('synchronous = normal');
|
||||
db.pragma('temp_store = memory');
|
||||
db.pragma('optimize');
|
||||
db.prepare(`CREATE TABLE IF NOT EXISTS ${this.tableName} (key TEXT PRIMARY KEY, value ${this.type === 'string' ? 'TEXT' : 'BLOB'}, ttl REAL NOT NULL);`).run();
|
||||
db.prepare(`CREATE INDEX IF NOT EXISTS cache_ttl ON ${this.tableName} (ttl);`).run();
|
||||
/** cache stmt */ this.statement = {
|
||||
updateTtl: db.prepare(`UPDATE ${this.tableName} SET ttl = ? WHERE key = ?;`),
|
||||
del: db.prepare(`DELETE FROM ${this.tableName} WHERE key = ?`),
|
||||
insert: db.prepare(`INSERT INTO ${this.tableName} (key, value, ttl) VALUES ($key, $value, $valid) ON CONFLICT(key) DO UPDATE SET value = $value, ttl = $valid`),
|
||||
get: db.prepare(`SELECT ttl, value FROM ${this.tableName} WHERE key = ? LIMIT 1`)
|
||||
};
|
||||
const date = new Date();
|
||||
// perform purge on startup
|
||||
// ttl + tbd < now => ttl < now - tbd
|
||||
const now = date.getTime() - this.tbd;
|
||||
db.prepare(`DELETE FROM ${this.tableName} WHERE ttl < ?`).run(now);
|
||||
this.db = db;
|
||||
const dateString = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
||||
const lastVaccum = this.get('__LAST_VACUUM');
|
||||
if (lastVaccum === undefined || lastVaccum !== dateString && date.getUTCDay() === 6) {
|
||||
console.log(_picocolors.default.magenta('[cache] vacuuming'));
|
||||
this.set('__LAST_VACUUM', dateString, 10 * 365 * 60 * 60 * 24 * 1000);
|
||||
this.db.exec('VACUUM;');
|
||||
}
|
||||
const end = _nodeperf_hooks.performance.now();
|
||||
console.log(`${_picocolors.default.gray(`[${(end - start).toFixed(3)}ns]`)} cache initialized from ${this.tableName} @ ${this.cachePath}`);
|
||||
}
|
||||
set(key, value, ttl = 60 * 1000) {
|
||||
const valid = Date.now() + ttl;
|
||||
this.statement.insert.run({
|
||||
$key: key,
|
||||
key,
|
||||
$value: value,
|
||||
value,
|
||||
$valid: valid,
|
||||
valid
|
||||
});
|
||||
}
|
||||
get(key) {
|
||||
const rv = this.statement.get.get(key);
|
||||
if (!rv) return null;
|
||||
if (rv.ttl < Date.now()) {
|
||||
this.del(key);
|
||||
return null;
|
||||
}
|
||||
if (rv.value == null) {
|
||||
this.del(key);
|
||||
return null;
|
||||
}
|
||||
return rv.value;
|
||||
}
|
||||
updateTtl(key, ttl) {
|
||||
this.statement.updateTtl.run(Date.now() + ttl, key);
|
||||
}
|
||||
del(key) {
|
||||
this.statement.del.run(key);
|
||||
}
|
||||
destroy() {
|
||||
this.db.close();
|
||||
}
|
||||
deleteTable(tableName) {
|
||||
this.db.exec(`DROP TABLE IF EXISTS ${tableName};`);
|
||||
}
|
||||
}
|
||||
// process.on('exit', () => {
|
||||
// fsFetchCache.destroy();
|
||||
// });
|
||||
const separator = '\u0000';
|
||||
const serializeArray = (arr)=>(0, _faststringarrayjoin.fastStringArrayJoin)(arr, separator);
|
||||
const deserializeArray = (str)=>str.split(separator);
|
||||
} (cacheFilesystem));
|
||||
return cacheFilesystem;
|
||||
}var fsMemo = {};var hasRequiredFsMemo;
|
||||
|
||||
function requireFsMemo () {
|
||||
if (hasRequiredFsMemo) return fsMemo;
|
||||
hasRequiredFsMemo = 1;
|
||||
(function (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, {
|
||||
cache: function() {
|
||||
return cache;
|
||||
},
|
||||
cachedOnlyFail: function() {
|
||||
return cachedOnlyFail;
|
||||
}
|
||||
});
|
||||
const _nodepath = /*#__PURE__*/ _interop_require_default(require$$0$2);
|
||||
const _ciinfo = require$$11;
|
||||
const _picocolors = /*#__PURE__*/ _interop_require_default(require$$0$1);
|
||||
const _cachefilesystem = /*@__PURE__*/ requireCacheFilesystem();
|
||||
const _serializedmemo = require$$4;
|
||||
const _dir = /*@__PURE__*/ fetchRetry.a();
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const fsMemoCache = new _cachefilesystem.Cache({
|
||||
cachePath: _nodepath.default.join(_dir.ROOT_DIR, '.cache'),
|
||||
tableName: 'fs_memo_cache'
|
||||
});
|
||||
const fsMemoCacheProvider = {
|
||||
has (key) {
|
||||
return fsMemoCache.get(key) !== null;
|
||||
},
|
||||
delete () {
|
||||
// noop
|
||||
},
|
||||
get (key) {
|
||||
return fsMemoCache.get(key) ?? undefined;
|
||||
},
|
||||
set (key, value, ttl) {
|
||||
fsMemoCache.set(key, value, ttl);
|
||||
},
|
||||
updateTtl (key, ttl) {
|
||||
fsMemoCache.updateTtl(key, ttl);
|
||||
}
|
||||
};
|
||||
const TTL = _ciinfo.isCI ? 1.5 * 86400 * 1000 : 7 * 86400 * 1000;
|
||||
const cache = (0, _serializedmemo.createMemoize)(fsMemoCacheProvider, {
|
||||
defaultTtl: TTL,
|
||||
onCacheMiss (key, { humanReadableName, isUseCachedIfFail }) {
|
||||
const cacheName = _picocolors.default.gray(humanReadableName);
|
||||
if (isUseCachedIfFail) {
|
||||
console.log(_picocolors.default.red('[fail] and no cache, throwing'), cacheName);
|
||||
} else {
|
||||
console.log(_picocolors.default.yellow('[cache] miss'), cacheName);
|
||||
}
|
||||
},
|
||||
onCacheUpdate (key, { humanReadableName, isUseCachedIfFail }) {
|
||||
const cacheName = _picocolors.default.gray(humanReadableName);
|
||||
if (isUseCachedIfFail) {
|
||||
console.log(_picocolors.default.gray('[cache] update'), cacheName);
|
||||
}
|
||||
},
|
||||
onCacheHit (key, { humanReadableName, isUseCachedIfFail }) {
|
||||
const cacheName = _picocolors.default.gray(humanReadableName);
|
||||
if (isUseCachedIfFail) {
|
||||
console.log(_picocolors.default.yellow('[fail] try cache'), cacheName);
|
||||
} else {
|
||||
console.log(_picocolors.default.green('[cache] hit'), cacheName);
|
||||
}
|
||||
}
|
||||
});
|
||||
const cachedOnlyFail = (0, _serializedmemo.createMemoize)(fsMemoCacheProvider, {
|
||||
defaultTtl: TTL,
|
||||
onlyUseCachedIfFail: true
|
||||
}); // export const cache = createCache(false);
|
||||
// export const cachedOnlyFail = createCache(true);
|
||||
} (fsMemo));
|
||||
return fsMemo;
|
||||
}exports.a=requireCacheFilesystem;exports.r=requireFsMemo;
|
||||
182
Dist/chunks/index.B8Uk9n3v.cjs
Normal file
182
Dist/chunks/index.B8Uk9n3v.cjs
Normal file
@@ -0,0 +1,182 @@
|
||||
'use strict';const require$$2=require('foxts/noop'),require$$0=require('node:path'),require$$1=require('node:process'),require$$0$1=require('picocolors');var trace = {};var hasRequiredTrace;
|
||||
|
||||
function requireTrace () {
|
||||
if (hasRequiredTrace) return trace;
|
||||
hasRequiredTrace = 1;
|
||||
(function (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, {
|
||||
createSpan: function() {
|
||||
return createSpan;
|
||||
},
|
||||
dummySpan: function() {
|
||||
return dummySpan;
|
||||
},
|
||||
printTraceResult: function() {
|
||||
return printTraceResult;
|
||||
},
|
||||
task: function() {
|
||||
return task;
|
||||
},
|
||||
whyIsNodeRunning: function() {
|
||||
return whyIsNodeRunning;
|
||||
}
|
||||
});
|
||||
const _noop = require$$2;
|
||||
const _nodepath = require$$0;
|
||||
const _nodeprocess = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
const _picocolors = /*#__PURE__*/ _interop_require_default(require$$0$1);
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
const SPAN_STATUS_START = 0;
|
||||
const SPAN_STATUS_END = 1;
|
||||
const spanTag = Symbol('span');
|
||||
const rootTraceResult = {
|
||||
name: 'root',
|
||||
start: 0,
|
||||
end: 0,
|
||||
children: []
|
||||
};
|
||||
function createSpan(name, parentTraceResult) {
|
||||
const start = performance.now();
|
||||
let curTraceResult;
|
||||
if (parentTraceResult == null) {
|
||||
curTraceResult = rootTraceResult;
|
||||
} else {
|
||||
curTraceResult = {
|
||||
name,
|
||||
start,
|
||||
end: 0,
|
||||
children: []
|
||||
};
|
||||
parentTraceResult.children.push(curTraceResult);
|
||||
}
|
||||
let status = SPAN_STATUS_START;
|
||||
const stop = (time)=>{
|
||||
if (status === SPAN_STATUS_END) {
|
||||
throw new Error(`span already stopped: ${name}`);
|
||||
}
|
||||
const end = time ?? performance.now();
|
||||
curTraceResult.end = end;
|
||||
status = SPAN_STATUS_END;
|
||||
};
|
||||
const traceChild = (name)=>createSpan(name, curTraceResult);
|
||||
const span = {
|
||||
[spanTag]: true,
|
||||
stop,
|
||||
traceChild,
|
||||
traceSyncFn (fn) {
|
||||
const res = fn(span);
|
||||
span.stop();
|
||||
return res;
|
||||
},
|
||||
async traceAsyncFn (fn) {
|
||||
const res = await fn(span);
|
||||
span.stop();
|
||||
return res;
|
||||
},
|
||||
traceResult: curTraceResult,
|
||||
async tracePromise (promise) {
|
||||
const res = await promise;
|
||||
span.stop();
|
||||
return res;
|
||||
},
|
||||
traceChildSync: (name, fn)=>traceChild(name).traceSyncFn(fn),
|
||||
traceChildAsync: (name, fn)=>traceChild(name).traceAsyncFn(fn),
|
||||
traceChildPromise: (name, promise)=>traceChild(name).tracePromise(promise)
|
||||
};
|
||||
// eslint-disable-next-line sukka/no-redundant-variable -- self reference
|
||||
return span;
|
||||
}
|
||||
const dummySpan = createSpan('');
|
||||
function task(importMetaMain, importMetaPath) {
|
||||
return (fn, customName)=>{
|
||||
const taskName = customName ?? (0, _nodepath.basename)(importMetaPath, (0, _nodepath.extname)(importMetaPath));
|
||||
let cleanup = _noop.noop;
|
||||
const onCleanup = (cb)=>{
|
||||
cleanup = cb;
|
||||
};
|
||||
const dummySpan = createSpan(taskName);
|
||||
if (importMetaMain) {
|
||||
_nodeprocess.default.on('uncaughtException', (error)=>{
|
||||
console.error('Uncaught exception:', error);
|
||||
_nodeprocess.default.exit(1);
|
||||
});
|
||||
_nodeprocess.default.on('unhandledRejection', (reason)=>{
|
||||
console.error('Unhandled rejection:', reason);
|
||||
_nodeprocess.default.exit(1);
|
||||
});
|
||||
dummySpan.traceChildAsync('dummy', (childSpan)=>fn(childSpan, onCleanup)).finally(()=>{
|
||||
dummySpan.stop();
|
||||
printTraceResult(dummySpan.traceResult);
|
||||
_nodeprocess.default.nextTick(whyIsNodeRunning);
|
||||
});
|
||||
}
|
||||
return async (span)=>{
|
||||
if (span) {
|
||||
return span.traceChildAsync(taskName, (childSpan)=>fn(childSpan, onCleanup).finally(()=>cleanup()));
|
||||
}
|
||||
return fn(dummySpan, onCleanup).finally(()=>cleanup());
|
||||
};
|
||||
};
|
||||
}
|
||||
async function whyIsNodeRunning() {
|
||||
const mod = await import('why-is-node-running');
|
||||
return mod.default();
|
||||
}
|
||||
function printTraceResult(traceResult = rootTraceResult) {
|
||||
printStats(traceResult.children);
|
||||
printTree(traceResult, (node)=>{
|
||||
if (node.end - node.start < 0) {
|
||||
return node.name;
|
||||
}
|
||||
return `${node.name} ${_picocolors.default.bold(`${(node.end - node.start).toFixed(3)}ms`)}`;
|
||||
});
|
||||
}
|
||||
function printTree(initialTree, printNode) {
|
||||
function printBranch(tree, branch, isGraphHead, isChildOfLastBranch) {
|
||||
const children = tree.children;
|
||||
let branchHead = '';
|
||||
if (!isGraphHead) {
|
||||
branchHead = children.length > 0 ? '┬ ' : '─ ';
|
||||
}
|
||||
const toPrint = printNode(tree, `${branch}${branchHead}`);
|
||||
if (typeof toPrint === 'string') {
|
||||
console.log(`${branch}${branchHead}${toPrint}`);
|
||||
}
|
||||
let baseBranch = branch;
|
||||
if (!isGraphHead) {
|
||||
baseBranch = branch.slice(0, -2) + (isChildOfLastBranch ? ' ' : '│ ');
|
||||
}
|
||||
const nextBranch = `${baseBranch}├─`;
|
||||
const lastBranch = `${baseBranch}└─`;
|
||||
children.forEach((child, index)=>{
|
||||
const last = children.length - 1 === index;
|
||||
printBranch(child, last ? lastBranch : nextBranch, false, last);
|
||||
});
|
||||
}
|
||||
printBranch(initialTree, '', true, false);
|
||||
}
|
||||
function printStats(stats) {
|
||||
const longestTaskName = Math.max(...stats.map((i)=>i.name.length));
|
||||
const realStart = Math.min(...stats.map((i)=>i.start));
|
||||
const realEnd = Math.max(...stats.map((i)=>i.end));
|
||||
const statsStep = (realEnd - realStart) / 120 | 0;
|
||||
stats.sort((a, b)=>a.start - b.start).forEach((stat)=>{
|
||||
console.log(`[${stat.name}]${' '.repeat(longestTaskName - stat.name.length)}`, ' '.repeat((stat.start - realStart) / statsStep | 0), '='.repeat(Math.max((stat.end - stat.start) / statsStep | 0, 1)));
|
||||
});
|
||||
}
|
||||
} (trace));
|
||||
return trace;
|
||||
}exports.r=requireTrace;
|
||||
47
Dist/chunks/loose-tldts-opt.DLUpGXpj.cjs
Normal file
47
Dist/chunks/loose-tldts-opt.DLUpGXpj.cjs
Normal file
@@ -0,0 +1,47 @@
|
||||
'use strict';var looseTldtsOpt = {};var hasRequiredLooseTldtsOpt;
|
||||
|
||||
function requireLooseTldtsOpt () {
|
||||
if (hasRequiredLooseTldtsOpt) return looseTldtsOpt;
|
||||
hasRequiredLooseTldtsOpt = 1;
|
||||
(function (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, {
|
||||
loosTldOptWithPrivateDomains: function() {
|
||||
return loosTldOptWithPrivateDomains;
|
||||
},
|
||||
looseTldtsOpt: function() {
|
||||
return looseTldtsOpt;
|
||||
},
|
||||
normalizeTldtsOpt: function() {
|
||||
return normalizeTldtsOpt;
|
||||
}
|
||||
});
|
||||
const looseTldtsOpt = {
|
||||
allowPrivateDomains: false,
|
||||
extractHostname: false,
|
||||
validateHostname: false,
|
||||
detectIp: false,
|
||||
mixedInputs: false
|
||||
};
|
||||
const loosTldOptWithPrivateDomains = {
|
||||
...looseTldtsOpt,
|
||||
allowPrivateDomains: true
|
||||
};
|
||||
const normalizeTldtsOpt = {
|
||||
allowPrivateDomains: true,
|
||||
// in normalizeDomain, we only care if it contains IP, we don't care if we need to extract it
|
||||
// by setting detectIp to false and manually check ip outside tldts.parse, we can skip the tldts
|
||||
// inner "extractHostname" call
|
||||
detectIp: false
|
||||
};
|
||||
} (looseTldtsOpt));
|
||||
return looseTldtsOpt;
|
||||
}exports.r=requireLooseTldtsOpt;
|
||||
35
Dist/chunks/memo-promise.BbOsVeGo.cjs
Normal file
35
Dist/chunks/memo-promise.BbOsVeGo.cjs
Normal file
@@ -0,0 +1,35 @@
|
||||
'use strict';var memoPromise = {};var hasRequiredMemoPromise;
|
||||
|
||||
function requireMemoPromise () {
|
||||
if (hasRequiredMemoPromise) return memoPromise;
|
||||
hasRequiredMemoPromise = 1;
|
||||
(function (exports) {
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
Object.defineProperty(exports, "createMemoizedPromise", {
|
||||
enumerable: true,
|
||||
get: function() {
|
||||
return createMemoizedPromise;
|
||||
}
|
||||
});
|
||||
const notError = Symbol('notError');
|
||||
function createMemoizedPromise(fn, /** whether to create promise immediately or only create after first access */ preload = true) {
|
||||
let error = notError;
|
||||
let promise = preload ? fn().catch((e)=>{
|
||||
// Here we record the error so that we can throw it later when the function is called
|
||||
error = e;
|
||||
// Here we make sure the Promise still returns the never type
|
||||
throw e;
|
||||
}) : null;
|
||||
return ()=>{
|
||||
if (error !== notError) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
promise ??= fn();
|
||||
return promise;
|
||||
};
|
||||
}
|
||||
} (memoPromise));
|
||||
return memoPromise;
|
||||
}exports.r=requireMemoPromise;
|
||||
122
Dist/chunks/misc.BpcQjda1.cjs
Normal file
122
Dist/chunks/misc.BpcQjda1.cjs
Normal file
@@ -0,0 +1,122 @@
|
||||
'use strict';const require$$0=require('node:path'),require$$1=require('node:fs'),require$$2=require('node:fs/promises');var misc = {};var hasRequiredMisc;
|
||||
|
||||
function requireMisc () {
|
||||
if (hasRequiredMisc) return misc;
|
||||
hasRequiredMisc = 1;
|
||||
(function (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, {
|
||||
fastIpVersion: function() {
|
||||
return fastIpVersion;
|
||||
},
|
||||
fastStringCompare: function() {
|
||||
return fastStringCompare;
|
||||
},
|
||||
isDirectoryEmptySync: function() {
|
||||
return isDirectoryEmptySync;
|
||||
},
|
||||
mkdirp: function() {
|
||||
return mkdirp;
|
||||
},
|
||||
notSupported: function() {
|
||||
return notSupported;
|
||||
},
|
||||
removeFiles: function() {
|
||||
return removeFiles;
|
||||
},
|
||||
withBannerArray: function() {
|
||||
return withBannerArray;
|
||||
},
|
||||
withIdentityContent: function() {
|
||||
return withIdentityContent;
|
||||
},
|
||||
writeFile: function() {
|
||||
return writeFile;
|
||||
}
|
||||
});
|
||||
const _nodepath = require$$0;
|
||||
const _nodefs = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
const _promises = /*#__PURE__*/ _interop_require_default(require$$2);
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function fastStringCompare(a, b) {
|
||||
const lenA = a.length;
|
||||
const lenB = b.length;
|
||||
const minLen = lenA < lenB ? lenA : lenB;
|
||||
for(let i = 0; i < minLen; ++i){
|
||||
const ca = a.charCodeAt(i);
|
||||
const cb = b.charCodeAt(i);
|
||||
if (ca > cb) return 1;
|
||||
if (ca < cb) return -1;
|
||||
}
|
||||
if (lenA === lenB) {
|
||||
return 0;
|
||||
}
|
||||
return lenA > lenB ? 1 : -1;
|
||||
}
|
||||
function mkdirp(dir) {
|
||||
if (_nodefs.default.existsSync(dir)) {
|
||||
return;
|
||||
}
|
||||
return _promises.default.mkdir(dir, {
|
||||
recursive: true
|
||||
});
|
||||
}
|
||||
const writeFile = async (destination, input, dir = (0, _nodepath.dirname)(destination))=>{
|
||||
const p = mkdirp(dir);
|
||||
if (p) {
|
||||
await p;
|
||||
}
|
||||
return _promises.default.writeFile(destination, input, {
|
||||
encoding: 'utf-8'
|
||||
});
|
||||
};
|
||||
const removeFiles = async (files)=>Promise.all(files.map((file)=>_promises.default.rm(file, {
|
||||
force: true
|
||||
})));
|
||||
function withBannerArray(title, description, date, content) {
|
||||
return [
|
||||
'#########################################',
|
||||
`# ${title}`,
|
||||
`# Last Updated: ${date.toISOString()}`,
|
||||
`# Size: ${content.length}`,
|
||||
...description.map((line)=>line ? `# ${line}` : '#'),
|
||||
'#########################################',
|
||||
...content,
|
||||
'################## EOF ##################'
|
||||
];
|
||||
}
|
||||
function notSupported(name) {
|
||||
return (...args)=>{
|
||||
console.error(`${name}: not supported.`, args);
|
||||
throw new Error(`${name}: not implemented.`);
|
||||
};
|
||||
}
|
||||
function withIdentityContent(title, description, date, content) {
|
||||
return content;
|
||||
}
|
||||
function isDirectoryEmptySync(path) {
|
||||
const directoryHandle = _nodefs.default.opendirSync(path);
|
||||
try {
|
||||
return directoryHandle.readSync() === null;
|
||||
} finally{
|
||||
directoryHandle.closeSync();
|
||||
}
|
||||
}
|
||||
function fastIpVersion(ip) {
|
||||
return ip.includes(':') ? 6 : ip.includes('.') ? 4 : 0;
|
||||
}
|
||||
} (misc));
|
||||
return misc;
|
||||
}exports.r=requireMisc;
|
||||
79
Dist/chunks/normalize-domain.Cfz4j8eP.cjs
Normal file
79
Dist/chunks/normalize-domain.Cfz4j8eP.cjs
Normal file
@@ -0,0 +1,79 @@
|
||||
'use strict';const require$$0=require('tldts'),looseTldtsOpt=require('./loose-tldts-opt.DLUpGXpj.cjs'),require$$2=require('foxts/is-probably-ip');var normalizeDomain = {};var hasRequiredNormalizeDomain;
|
||||
|
||||
function requireNormalizeDomain () {
|
||||
if (hasRequiredNormalizeDomain) return normalizeDomain;
|
||||
hasRequiredNormalizeDomain = 1;
|
||||
(function (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, {
|
||||
fastNormalizeDomain: function() {
|
||||
return fastNormalizeDomain;
|
||||
},
|
||||
fastNormalizeDomainWithoutWww: function() {
|
||||
return fastNormalizeDomainWithoutWww;
|
||||
},
|
||||
normalizeDomain: function() {
|
||||
return normalizeDomain;
|
||||
}
|
||||
});
|
||||
const _tldts = /*#__PURE__*/ _interop_require_default(require$$0);
|
||||
const _loosetldtsopt = /*@__PURE__*/ looseTldtsOpt.r();
|
||||
const _isprobablyip = require$$2;
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
function fastNormalizeDomainWithoutWww(domain, parsed = null) {
|
||||
// We don't want tldts to call its own "extractHostname" on ip, bail out ip first.
|
||||
// Now ip has been bailed out, we can safely set normalizeTldtsOpt.detectIp to false.
|
||||
if ((0, _isprobablyip.isProbablyIpv4)(domain) || (0, _isprobablyip.isProbablyIpv6)(domain)) {
|
||||
return null;
|
||||
}
|
||||
parsed ??= _tldts.default.parse(domain, _loosetldtsopt.normalizeTldtsOpt);
|
||||
// Private invalid domain (things like .tor, .dn42, etc)
|
||||
if (!parsed.isIcann && !parsed.isPrivate) return null;
|
||||
if (parsed.subdomain) {
|
||||
if (parsed.subdomain === 'www') {
|
||||
return parsed.domain;
|
||||
}
|
||||
if (parsed.subdomain.startsWith('www.')) {
|
||||
return parsed.subdomain.slice(4) + '.' + parsed.domain;
|
||||
}
|
||||
}
|
||||
return parsed.hostname;
|
||||
}
|
||||
function fastNormalizeDomain(domain, parsed = null) {
|
||||
// We don't want tldts to call its own "extractHostname" on ip, bail out ip first.
|
||||
// Now ip has been bailed out, we can safely set normalizeTldtsOpt.detectIp to false.
|
||||
if ((0, _isprobablyip.isProbablyIpv4)(domain) || (0, _isprobablyip.isProbablyIpv6)(domain)) {
|
||||
return null;
|
||||
}
|
||||
parsed ??= _tldts.default.parse(domain, _loosetldtsopt.normalizeTldtsOpt);
|
||||
// Private invalid domain (things like .tor, .dn42, etc)
|
||||
if (!parsed.isIcann && !parsed.isPrivate) return null;
|
||||
return parsed.hostname;
|
||||
}
|
||||
function normalizeDomain(domain, parsed = null) {
|
||||
if (domain.length === 0) return null;
|
||||
if ((0, _isprobablyip.isProbablyIpv4)(domain) || (0, _isprobablyip.isProbablyIpv6)(domain)) {
|
||||
return null;
|
||||
}
|
||||
parsed ??= _tldts.default.parse(domain, _loosetldtsopt.normalizeTldtsOpt);
|
||||
// Private invalid domain (things like .tor, .dn42, etc)
|
||||
if (!parsed.isIcann && !parsed.isPrivate) return null;
|
||||
// const h = parsed.hostname;
|
||||
// if (h === null) return null;
|
||||
return parsed.hostname;
|
||||
}
|
||||
} (normalizeDomain));
|
||||
return normalizeDomain;
|
||||
}exports.r=requireNormalizeDomain;
|
||||
44
Dist/chunks/parse-dnsmasq.CiH7YJVY.cjs
Normal file
44
Dist/chunks/parse-dnsmasq.CiH7YJVY.cjs
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';const fetchTextByLine=require('./fetch-text-by-line.YY5b5610.cjs'),normalizeDomain=require('./normalize-domain.Cfz4j8eP.cjs');var parseDnsmasq = {};var hasRequiredParseDnsmasq;
|
||||
|
||||
function requireParseDnsmasq () {
|
||||
if (hasRequiredParseDnsmasq) return parseDnsmasq;
|
||||
hasRequiredParseDnsmasq = 1;
|
||||
(function (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, {
|
||||
extractDomainsFromFelixDnsmasq: function() {
|
||||
return extractDomainsFromFelixDnsmasq;
|
||||
},
|
||||
parseFelixDnsmasqFromResp: function() {
|
||||
return parseFelixDnsmasqFromResp;
|
||||
}
|
||||
});
|
||||
const _fetchtextbyline = /*@__PURE__*/ fetchTextByLine.a();
|
||||
const _normalizedomain = /*@__PURE__*/ normalizeDomain.r();
|
||||
function extractDomainsFromFelixDnsmasq(line) {
|
||||
if (line.startsWith('server=/') && line.endsWith('/114.114.114.114')) {
|
||||
return line.slice(8, -16);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
async function parseFelixDnsmasqFromResp(resp) {
|
||||
const results = [];
|
||||
for await (const line of (0, _fetchtextbyline.createReadlineInterfaceFromResponse)(resp, true)){
|
||||
const domain = extractDomainsFromFelixDnsmasq(line);
|
||||
if (domain && (0, _normalizedomain.fastNormalizeDomain)(domain)) {
|
||||
results.push(domain);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
} (parseDnsmasq));
|
||||
return parseDnsmasq;
|
||||
}exports.r=requireParseDnsmasq;
|
||||
584
Dist/chunks/reject-data-source.DaKwvNlG.cjs
Normal file
584
Dist/chunks/reject-data-source.DaKwvNlG.cjs
Normal file
@@ -0,0 +1,584 @@
|
||||
'use strict';var rejectDataSource = {};var hasRequiredRejectDataSource;
|
||||
|
||||
function requireRejectDataSource () {
|
||||
if (hasRequiredRejectDataSource) return rejectDataSource;
|
||||
hasRequiredRejectDataSource = 1;
|
||||
(function (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, {
|
||||
ADGUARD_FILTERS: function() {
|
||||
return ADGUARD_FILTERS;
|
||||
},
|
||||
ADGUARD_FILTERS_EXTRA: function() {
|
||||
return ADGUARD_FILTERS_EXTRA;
|
||||
},
|
||||
ADGUARD_FILTERS_WHITELIST: function() {
|
||||
return ADGUARD_FILTERS_WHITELIST;
|
||||
},
|
||||
CRASHLYTICS_WHITELIST: function() {
|
||||
return CRASHLYTICS_WHITELIST;
|
||||
},
|
||||
DEBUG_DOMAIN_TO_FIND: function() {
|
||||
return DEBUG_DOMAIN_TO_FIND;
|
||||
},
|
||||
DOMAIN_LISTS: function() {
|
||||
return DOMAIN_LISTS;
|
||||
},
|
||||
DOMAIN_LISTS_EXTRA: function() {
|
||||
return DOMAIN_LISTS_EXTRA;
|
||||
},
|
||||
HOSTS: function() {
|
||||
return HOSTS;
|
||||
},
|
||||
HOSTS_EXTRA: function() {
|
||||
return HOSTS_EXTRA;
|
||||
},
|
||||
PHISHING_DOMAIN_LISTS_EXTRA: function() {
|
||||
return PHISHING_DOMAIN_LISTS_EXTRA;
|
||||
},
|
||||
PHISHING_HOSTS_EXTRA: function() {
|
||||
return PHISHING_HOSTS_EXTRA;
|
||||
},
|
||||
PREDEFINED_WHITELIST: function() {
|
||||
return PREDEFINED_WHITELIST;
|
||||
}
|
||||
});
|
||||
const DEBUG_DOMAIN_TO_FIND = null; // example.com | null
|
||||
const HOSTS = [
|
||||
[
|
||||
// WindowsSpyBlocker hasn't been updated since 2022-06-16, let's use jsDelivr as primary URL
|
||||
'https://cdn.jsdelivr.net/gh/crazy-max/WindowsSpyBlocker@master/data/hosts/spy.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
'https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Xiaomi-Extension.txt',
|
||||
null,
|
||||
false
|
||||
],
|
||||
[
|
||||
'https://raw.githubusercontent.com/jerryn70/GoodbyeAds/master/Extension/GoodbyeAds-Huawei-AdBlock.txt',
|
||||
null,
|
||||
false
|
||||
]
|
||||
];
|
||||
const HOSTS_EXTRA = [
|
||||
[
|
||||
'https://raw.githubusercontent.com/durablenapkin/block/master/tvstream.txt',
|
||||
null,
|
||||
true
|
||||
],
|
||||
// This stupid hosts blocks t.co, so we determine that this is also bullshit, so it is extra
|
||||
[
|
||||
'https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintext',
|
||||
[
|
||||
'https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/thirdparties/pgl.yoyo.org/as/serverlist'
|
||||
],
|
||||
true
|
||||
],
|
||||
// Dan Pollock's hosts file, 0.0.0.0 version is 30 KiB smaller
|
||||
[
|
||||
'https://someonewhocares.org/hosts/zero/hosts',
|
||||
[
|
||||
'https://proxy.cdn.skk.moe/https/someonewhocares.org/hosts/zero/hosts'
|
||||
],
|
||||
true
|
||||
],
|
||||
// ad-wars is not actively maintained since 2023.11, so we use jsDelivr as primary URL
|
||||
[
|
||||
'https://cdn.jsdelivr.net/gh/jdlingyu/ad-wars@master/hosts',
|
||||
[
|
||||
'https://raw.githubusercontent.com/jdlingyu/ad-wars/master/hosts'
|
||||
],
|
||||
false
|
||||
]
|
||||
];
|
||||
const DOMAIN_LISTS = [];
|
||||
const DOMAIN_LISTS_EXTRA = [
|
||||
// CoinBlockerList - Full
|
||||
// The CoinBlockerList is no longer maintained and even close-source, so we no longer trust it
|
||||
// instead we maintain a list of our own
|
||||
// BarbBlock
|
||||
// The barbblock list has never been updated since 2019-05, so we set a 14 days cache ttl
|
||||
[
|
||||
'https://paulgb.github.io/BarbBlock/blacklists/domain-list.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/paulgb/BarbBlock/refs/heads/main/blacklists/domain-list.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
// DigitalSide Threat-Intel - OSINT Hub
|
||||
// Update once per day
|
||||
[
|
||||
'https://osint.digitalside.it/Threat-Intel/lists/latestdomains.txt',
|
||||
[],
|
||||
true
|
||||
],
|
||||
// AdGuard CNAME Filter Combined
|
||||
// Update on a 7 days basis, so we can also use jsDelivr as primary URL
|
||||
[
|
||||
'https://cdn.jsdelivr.net/gh/AdguardTeam/cname-trackers@master/data/combined_disguised_ads_justdomains.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_ads_justdomains.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
'https://cdn.jsdelivr.net/gh/AdguardTeam/cname-trackers@master/data/combined_disguised_trackers_justdomains.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_trackers_justdomains.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
'https://cdn.jsdelivr.net/gh/AdguardTeam/cname-trackers@master/data/combined_disguised_clickthroughs_justdomains.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_clickthroughs_justdomains.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
'https://cdn.jsdelivr.net/gh/AdguardTeam/cname-trackers@master/data/combined_disguised_microsites_justdomains.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_microsites_justdomains.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
// ['https://raw.githubusercontent.com/AdguardTeam/cname-trackers/master/data/combined_disguised_mail_trackers_justdomains.txt', [], true],
|
||||
// Curben's PUP Domains Blocklist
|
||||
// The PUP filter has paused the update since 2023-05, so we set a 14 days cache ttl, and move it to extra
|
||||
// [
|
||||
// 'https://pup-filter.pages.dev/pup-filter-domains.txt',
|
||||
// [
|
||||
// // 'https://malware-filter.pages.dev/pup-filter-domains.txt',
|
||||
// // 'https://malware-filter.gitlab.io/malware-filter/pup-filter-domains.txt',
|
||||
// 'https://malware-filter.gitlab.io/pup-filter/pup-filter-domains.txt'
|
||||
// // 'https://curbengh.github.io/pup-filter/pup-filter-domains.txt',
|
||||
// // 'https://malware-filter.pages.dev/pup-filter-domains.txt'
|
||||
// ],
|
||||
// true
|
||||
// ],
|
||||
// Curben's UrlHaus Malicious URL Blocklist
|
||||
[
|
||||
'https://urlhaus-filter.pages.dev/urlhaus-filter-domains.txt',
|
||||
[
|
||||
'https://malware-filter.pages.dev/urlhaus-filter-domains.txt',
|
||||
'https://malware-filter.gitlab.io/urlhaus-filter/urlhaus-filter-domains.txt',
|
||||
'https://malware-filter.gitlab.io/malware-filter/urlhaus-filter-domains.txt',
|
||||
'https://curbengh.github.io/urlhaus-filter/urlhaus-filter-domains.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
// Spam404
|
||||
// Not actively maintained, let's use jsDelivr as primary URL
|
||||
[
|
||||
'https://cdn.jsdelivr.net/gh/Spam404/lists@master/main-blacklist.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/Spam404/lists/master/main-blacklist.txt'
|
||||
],
|
||||
true
|
||||
]
|
||||
];
|
||||
const PHISHING_HOSTS_EXTRA = [
|
||||
[
|
||||
'https://raw.githubusercontent.com/durablenapkin/scamblocklist/master/hosts.txt',
|
||||
[],
|
||||
true
|
||||
]
|
||||
];
|
||||
const PHISHING_DOMAIN_LISTS_EXTRA = [
|
||||
[
|
||||
'https://phishing-filter.pages.dev/phishing-filter-domains.txt',
|
||||
[
|
||||
'https://malware-filter.pages.dev/phishing-filter-domains.txt',
|
||||
'https://malware-filter.gitlab.io/phishing-filter/phishing-filter-domains.txt',
|
||||
'https://malware-filter.gitlab.io/malware-filter/phishing-filter-domains.txt',
|
||||
'https://curbengh.github.io/phishing-filter/phishing-filter-domains.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
[
|
||||
'https://phishing.army/download/phishing_army_blocklist.txt',
|
||||
[],
|
||||
true
|
||||
]
|
||||
];
|
||||
const ADGUARD_FILTERS = [
|
||||
// EasyList
|
||||
[
|
||||
'https://easylist.to/easylist/easylist.txt',
|
||||
[
|
||||
'https://easylist-downloads.adblockplus.org/easylist.txt',
|
||||
'https://secure.fanboy.co.nz/easylist.txt',
|
||||
'https://ublockorigin.github.io/uAssetsCDN/thirdparties/easylist.txt',
|
||||
'https://ublockorigin.pages.dev/thirdparties/easylist.txt',
|
||||
'https://raw.githubusercontent.com/easylist/easylist/gh-pages/easylist.txt',
|
||||
'https://filters.adtidy.org/extension/ublock/filters/101_optimized.txt'
|
||||
]
|
||||
],
|
||||
// EasyPrivacy
|
||||
[
|
||||
'https://easylist.to/easylist/easyprivacy.txt',
|
||||
[
|
||||
'https://easylist-downloads.adblockplus.org/easyprivacy.txt',
|
||||
'https://secure.fanboy.co.nz/easyprivacy.txt',
|
||||
'https://ublockorigin.github.io/uAssetsCDN/thirdparties/easyprivacy.txt',
|
||||
'https://ublockorigin.pages.dev/thirdparties/easyprivacy.txt',
|
||||
'https://raw.githubusercontent.com/easylist/easylist/gh-pages/easyprivacy.txt',
|
||||
'https://filters.adtidy.org/extension/ublock/filters/118_optimized.txt'
|
||||
]
|
||||
],
|
||||
// AdGuard Base Filter
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/2_without_easylist.txt',
|
||||
[
|
||||
'https://proxy.cdn.skk.moe/https/filters.adtidy.org/extension/ublock/filters/2_without_easylist.txt'
|
||||
]
|
||||
],
|
||||
// AdGuard Mobile AD
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/11_optimized.txt',
|
||||
[
|
||||
'https://proxy.cdn.skk.moe/https/filters.adtidy.org/extension/ublock/filters/2_without_easylist.txt'
|
||||
]
|
||||
],
|
||||
// AdGuard Tracking Protection
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/3_optimized.txt',
|
||||
[
|
||||
'https://proxy.cdn.skk.moe/https/filters.adtidy.org/extension/ublock/filters/3_optimized.txt'
|
||||
]
|
||||
],
|
||||
// AdGuard Chinese filter (EasyList China + AdGuard Chinese filter)
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/224_optimized.txt',
|
||||
[
|
||||
'https://proxy.cdn.skk.moe/https/filters.adtidy.org/extension/ublock/filters/224_optimized.txt'
|
||||
]
|
||||
],
|
||||
// GameConsoleAdblockList
|
||||
// Update almost once per 1 to 3 months, let's set a 10 days cache ttl
|
||||
[
|
||||
'https://cdn.jsdelivr.net/gh/DandelionSprout/adfilt@master/GameConsoleAdblockList.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/DandelionSprout/adfilt/master/GameConsoleAdblockList.txt'
|
||||
]
|
||||
],
|
||||
// PiHoleBlocklist
|
||||
// Update almost once per 3 months, let's set a 10 days cache ttl
|
||||
[
|
||||
'https://perflyst.github.io/PiHoleBlocklist/SmartTV-AGH.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/SmartTV-AGH.txt'
|
||||
]
|
||||
],
|
||||
// uBlock Origin Unbreak
|
||||
[
|
||||
'https://ublockorigin.github.io/uAssetsCDN/filters/unbreak.min.txt',
|
||||
[
|
||||
'https://ublockorigin.pages.dev/filters/unbreak.min.txt'
|
||||
]
|
||||
]
|
||||
];
|
||||
const ADGUARD_FILTERS_WHITELIST = [
|
||||
[
|
||||
'https://adguardteam.github.io/AdGuardSDNSFilter/Filters/exceptions.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/AdguardTeam/AdGuardSDNSFilter/master/Filters/exceptions.txt'
|
||||
]
|
||||
],
|
||||
[
|
||||
'https://adguardteam.github.io/AdGuardSDNSFilter/Filters/exclusions.txt',
|
||||
[
|
||||
'https://raw.githubusercontent.com/AdguardTeam/AdGuardSDNSFilter/master/Filters/exclusions.txt'
|
||||
]
|
||||
]
|
||||
];
|
||||
const ADGUARD_FILTERS_EXTRA = [
|
||||
// AdGuard DNS Filter
|
||||
// way too many other countries' domains (JP, Spanish, RU, VN, Turkish, Ukarainian, Dutch, etc.)
|
||||
// EasyList, EasyPrivacy, Chinese and general filters are already included in base data source
|
||||
[
|
||||
'https://adguardteam.github.io/AdGuardSDNSFilter/Filters/filter.txt',
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/15_optimized.txt',
|
||||
'https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt'
|
||||
]
|
||||
],
|
||||
// no coin list adguard list is more maintained than its hosts
|
||||
[
|
||||
'https://raw.githubusercontent.com/hoshsadiq/adblock-nocoin-list/master/nocoin.txt',
|
||||
[],
|
||||
true
|
||||
],
|
||||
// AdGuard Annoyances filter
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/14_optimized.txt',
|
||||
[
|
||||
'https://proxy.cdn.skk.moe/https/filters.adtidy.org/extension/ublock/filters/14_optimized.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
// AdGuard Cookie Notices, included in Annoyances filter
|
||||
// ['https://filters.adtidy.org/extension/ublock/filters/18_optimized.txt', null, true],
|
||||
// EasyList Germany filter, not even included in extra for now
|
||||
// [
|
||||
// 'https://easylist.to/easylistgermany/easylistgermany.txt',
|
||||
// [
|
||||
// 'https://easylist-downloads.adblockplus.org/easylistgermany.txt'
|
||||
// ],
|
||||
//
|
||||
// ],
|
||||
// AdGuard Japanese filter
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/7_optimized.txt',
|
||||
[
|
||||
'https://proxy.cdn.skk.moe/https/filters.adtidy.org/extension/ublock/filters/7_optimized.txt'
|
||||
]
|
||||
],
|
||||
// uBlock Origin Filter List
|
||||
[
|
||||
'https://ublockorigin.github.io/uAssetsCDN/filters/filters.min.txt',
|
||||
[
|
||||
'https://ublockorigin.pages.dev/filters/filters.min.txt'
|
||||
]
|
||||
],
|
||||
// AdGuard Popup Overlay - included in Annoyances filter
|
||||
// ['https://filters.adtidy.org/extension/ublock/filters/19_optimized.txt', null, true],
|
||||
// AdGuard Mobile Banner
|
||||
// almost all generic rule
|
||||
// ['https://filters.adtidy.org/extension/ublock/filters/20_optimized.txt', null],
|
||||
// uBlock Origin Badware Risk List
|
||||
[
|
||||
'https://ublockorigin.github.io/uAssetsCDN/filters/badware.min.txt',
|
||||
[
|
||||
'https://ublockorigin.pages.dev/filters/badware.min.txt'
|
||||
]
|
||||
],
|
||||
// uBlock Origin Privacy List
|
||||
[
|
||||
'https://ublockorigin.github.io/uAssetsCDN/filters/privacy.min.txt',
|
||||
[
|
||||
'https://ublockorigin.pages.dev/filters/privacy.min.txt'
|
||||
]
|
||||
],
|
||||
// uBlock Origin Resource Abuse: merged in uBlock Origin Privacy List
|
||||
// [
|
||||
// 'https://ublockorigin.github.io/uAssetsCDN/filters/resource-abuse.txt',
|
||||
// ['https://ublockorigin.pages.dev/filters/resource-abuse.txt']
|
||||
// ],
|
||||
// uBlock Origin Annoyances (the un-merged of Fanboy Annoyances List)
|
||||
[
|
||||
'https://ublockorigin.github.io/uAssetsCDN/filters/annoyances.min.txt',
|
||||
[
|
||||
'https://ublockorigin.pages.dev/filters/annoyances.min.txt'
|
||||
]
|
||||
],
|
||||
// EasyList Annoyances
|
||||
[
|
||||
'https://ublockorigin.github.io/uAssetsCDN/thirdparties/easylist-annoyances.txt',
|
||||
[
|
||||
'https://ublockorigin.pages.dev/thirdparties/easylist-annoyances.txt'
|
||||
]
|
||||
],
|
||||
// EasyList - Newsletters
|
||||
[
|
||||
'https://ublockorigin.github.io/uAssetsCDN/thirdparties/easylist-newsletters.txt',
|
||||
[
|
||||
'https://ublockorigin.pages.dev/thirdparties/easylist-newsletters.txt'
|
||||
]
|
||||
],
|
||||
// EasyList - Notifications
|
||||
[
|
||||
'https://ublockorigin.github.io/uAssets/thirdparties/easylist-notifications.txt',
|
||||
[
|
||||
'https://ublockorigin.pages.dev/thirdparties/easylist-notifications.txt'
|
||||
]
|
||||
],
|
||||
// Fanboy Cookie Monster (EasyList Cookie List)
|
||||
[
|
||||
'https://ublockorigin.github.io/uAssets/thirdparties/easylist-cookies.txt',
|
||||
[
|
||||
'https://ublockorigin.pages.dev/thirdparties/easylist-cookies.txt',
|
||||
'https://secure.fanboy.co.nz/fanboy-cookiemonster_ubo.txt'
|
||||
]
|
||||
],
|
||||
// Dandelion Sprout's Annoyances
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/250_optimized.txt',
|
||||
[
|
||||
'https://proxy.cdn.skk.moe/https/filters.adtidy.org/extension/ublock/filters/250_optimized.txt'
|
||||
],
|
||||
true
|
||||
],
|
||||
// Adblock Warning Removal List
|
||||
[
|
||||
'https://easylist-downloads.adblockplus.org/antiadblockfilters.txt',
|
||||
[
|
||||
'https://filters.adtidy.org/extension/ublock/filters/207_optimized.txt'
|
||||
],
|
||||
true
|
||||
]
|
||||
];
|
||||
const CRASHLYTICS_WHITELIST = [
|
||||
// VSCode Telemetry, see https://sts.online.visualstudio.com/api/swagger/index.html
|
||||
'sts.online.visualstudio.com',
|
||||
// Sentry
|
||||
'.ingest.sentry.io',
|
||||
'.ingest.us.sentry.io',
|
||||
'.ingest.de.sentry.io',
|
||||
// bugsnag
|
||||
'.sessions.bugsnag.com',
|
||||
'.notify.bugsnag.com',
|
||||
// influxdata
|
||||
'.cloud.influxdata.com',
|
||||
'.cloud1.influxdata.com',
|
||||
'.cloud2.influxdata.com',
|
||||
// split.io A/B flag
|
||||
'streaming.split.io',
|
||||
'telemetry.split.io',
|
||||
'sdk.split.io',
|
||||
// Google
|
||||
// -ds.metric.gstatic.com are specifically exempted from reject, but it could use secondary proxy policy
|
||||
'.metric.gstatic.com',
|
||||
// Misc
|
||||
'telemetry.1passwordservices.com',
|
||||
'events.tableplus.com',
|
||||
'telemetry.nextjs.org',
|
||||
'telemetry.vercel.com',
|
||||
'stats.setapp.com',
|
||||
'stats.setapp.macpaw.dev',
|
||||
'.app-analytics-services.com',
|
||||
'.telemetry.services.yofi.ai',
|
||||
'.cdn.pubnub.com',
|
||||
'.data.debugbear.com',
|
||||
'.cdn.applicationinsights.io',
|
||||
'.applicationinsights.azure.com',
|
||||
'.applicationinsights.azure.cn',
|
||||
'.api.loganalytics.io',
|
||||
'.bugly.qcloud.com',
|
||||
'.cdn.signalfx.com',
|
||||
'.crash-reports.browser.yandex.net',
|
||||
'.crashlytics2.l.google.com',
|
||||
'.crashlyticsreports-pa.googleapis.com',
|
||||
'.e.crashlytics.com',
|
||||
'.events.backtrace.io',
|
||||
'auth.split.io',
|
||||
'events.split.io',
|
||||
'streaming.split.io',
|
||||
'.in.appcenter.ms',
|
||||
'.loggly.com',
|
||||
'.logz.io',
|
||||
'.opentelemetry.io',
|
||||
'.raygun.io',
|
||||
'.rum.cronitor.io',
|
||||
'.settings.crashlytics.com',
|
||||
'.sny.monosnap.com',
|
||||
'.lr-ingest.com',
|
||||
'.cdn.rollbar.com',
|
||||
'.api.instabug.com',
|
||||
'.ensighten.com',
|
||||
'api.crashguard.me'
|
||||
];
|
||||
const PREDEFINED_WHITELIST = [
|
||||
...CRASHLYTICS_WHITELIST,
|
||||
'.localhost',
|
||||
'.local',
|
||||
'.localdomain',
|
||||
'.broadcasthost',
|
||||
'.ip6-loopback',
|
||||
'.ip6-localnet',
|
||||
'.ip6-mcastprefix',
|
||||
'.ip6-allnodes',
|
||||
'.ip6-allrouters',
|
||||
'.ip6-allhosts',
|
||||
'.mcastprefix',
|
||||
'.skk.moe',
|
||||
'analytics.google.com',
|
||||
'.cloud.answerhub.com',
|
||||
'ae01.alicdn.com',
|
||||
'.whoami.akamai.net',
|
||||
'.whoami.ds.akahelp.net',
|
||||
'.instant.page',
|
||||
'.piwik.pro',
|
||||
'mixpanel.com',
|
||||
'cdn.mxpnl.com',
|
||||
'.heapanalytics.com',
|
||||
'.segment.com',
|
||||
'.segmentify.com',
|
||||
'.t.co',
|
||||
'.survicate.com',
|
||||
'.perfops.io',
|
||||
'.d2axgrpnciinw7.cloudfront.net',
|
||||
'.sb-cd.com',
|
||||
'.storage.yandexcloud.net',
|
||||
'.login.microsoftonline.com',
|
||||
'api.xiaomi.com',
|
||||
'api.io.mi.com',
|
||||
'.cdn.userreport.com',
|
||||
'.ip-api.com',
|
||||
'.fastly-analytics.com',
|
||||
'.digitaloceanspaces.com',
|
||||
's3.nl-ams.scw.cloud',
|
||||
'.geolocation-db.com',
|
||||
'.uploads.codesandbox.io',
|
||||
'.vlscppe.microsoft.com',
|
||||
'.statsig.com',
|
||||
'.pstmrk.it',
|
||||
'.clicks.mlsend.com',
|
||||
'email.accounts.bitly.com',
|
||||
'adsense.google.com',
|
||||
'api.vip.miui.com',
|
||||
'api.comm.miui.com',
|
||||
'.ai.api.xiaomi.com',
|
||||
'm.stripe.com',
|
||||
// yet stupid AdGuardDNSFilter blocks all of it. Stupid AdGuard
|
||||
'.w3s.link',
|
||||
'.r2.dev',
|
||||
'mlsend.com',
|
||||
'ab.chatgpt.com',
|
||||
'jnn-pa.googleapis.com',
|
||||
'imasdk.googleapis.com',
|
||||
'.l.qq.com',
|
||||
'.in-addr.arpa',
|
||||
'.ip6.arpa',
|
||||
'.clients.your-server.de',
|
||||
'.bc.googleusercontent.com',
|
||||
'.host.secureserver.net',
|
||||
'.ip.linodeusercontent.com',
|
||||
'.static.akamaitechnologies.com',
|
||||
'.compute.amazonaws.com',
|
||||
'.shoppy.gg',
|
||||
'transcend-cdn.com',
|
||||
'store1.gofile.io',
|
||||
'ad.12306.cn',
|
||||
'.ib.snssdk.com',
|
||||
'.nstool.netease.com',
|
||||
'.wns.windows.com',
|
||||
'.lon.llnw.net',
|
||||
'.lcy.llnw.net',
|
||||
'repo.huaweicloud.com',
|
||||
'.hubspotlinks.com',
|
||||
'cldup.com',
|
||||
// Doesn't make sense: CNAME domains
|
||||
'.cdn.cloudflare.net',
|
||||
'.apple-dns.net',
|
||||
'.data.microsoft.com.akadns.net',
|
||||
// Expired domains
|
||||
'.expobarrio.com',
|
||||
'.hamdandates.com',
|
||||
'.amzone.co.jp'
|
||||
];
|
||||
} (rejectDataSource));
|
||||
return rejectDataSource;
|
||||
}exports.r=requireRejectDataSource;
|
||||
59
Dist/chunks/ruleset.iYH0XOC1.cjs
Normal file
59
Dist/chunks/ruleset.iYH0XOC1.cjs
Normal file
@@ -0,0 +1,59 @@
|
||||
'use strict';const base=require('./base.C13YY5P3.cjs');var ruleset = {};var hasRequiredRuleset;
|
||||
|
||||
function requireRuleset () {
|
||||
if (hasRequiredRuleset) return ruleset;
|
||||
hasRequiredRuleset = 1;
|
||||
(function (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, {
|
||||
ClashOnlyRulesetOutput: function() {
|
||||
return ClashOnlyRulesetOutput;
|
||||
},
|
||||
RulesetOutput: function() {
|
||||
return RulesetOutput;
|
||||
},
|
||||
SurgeOnlyRulesetOutput: function() {
|
||||
return SurgeOnlyRulesetOutput;
|
||||
}
|
||||
});
|
||||
const _clash = /*@__PURE__*/ base.c();
|
||||
const _singbox = /*@__PURE__*/ base.f();
|
||||
const _surge = /*@__PURE__*/ base.e();
|
||||
const _base = /*@__PURE__*/ base.b();
|
||||
class RulesetOutput extends _base.FileOutput {
|
||||
constructor(span, id, type){
|
||||
super(span, id);
|
||||
this.strategies = [
|
||||
new _surge.SurgeRuleSet(type),
|
||||
new _clash.ClashClassicRuleSet(type),
|
||||
new _singbox.SingboxSource(type)
|
||||
];
|
||||
}
|
||||
}
|
||||
class SurgeOnlyRulesetOutput extends _base.FileOutput {
|
||||
constructor(span, id, type, overrideOutputDir){
|
||||
super(span, id);
|
||||
this.strategies = [
|
||||
new _surge.SurgeRuleSet(type, overrideOutputDir)
|
||||
];
|
||||
}
|
||||
}
|
||||
class ClashOnlyRulesetOutput extends _base.FileOutput {
|
||||
constructor(span, id, type){
|
||||
super(span, id);
|
||||
this.strategies = [
|
||||
new _clash.ClashClassicRuleSet(type)
|
||||
];
|
||||
}
|
||||
}
|
||||
} (ruleset));
|
||||
return ruleset;
|
||||
}exports.r=requireRuleset;
|
||||
858
Dist/chunks/stream.C9eZuk9f.cjs
Normal file
858
Dist/chunks/stream.C9eZuk9f.cjs
Normal file
@@ -0,0 +1,858 @@
|
||||
'use strict';var stream = {};var hasRequiredStream;
|
||||
|
||||
function requireStream () {
|
||||
if (hasRequiredStream) return stream;
|
||||
hasRequiredStream = 1;
|
||||
(function (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, {
|
||||
ALL: function() {
|
||||
return ALL;
|
||||
},
|
||||
AU: function() {
|
||||
return AU;
|
||||
},
|
||||
EU: function() {
|
||||
return EU;
|
||||
},
|
||||
HK: function() {
|
||||
return HK;
|
||||
},
|
||||
JP: function() {
|
||||
return JP;
|
||||
},
|
||||
KR: function() {
|
||||
return KR;
|
||||
},
|
||||
NORTH_AMERICA: function() {
|
||||
return NORTH_AMERICA;
|
||||
},
|
||||
SOUTH_EAST_ASIA: function() {
|
||||
return SOUTH_EAST_ASIA;
|
||||
},
|
||||
TW: function() {
|
||||
return TW;
|
||||
}
|
||||
});
|
||||
const $4GTV = {
|
||||
name: '4gtv',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,4gtv.tv',
|
||||
'DOMAIN,4gtvfreepcvod-cds.cdn.hinet.net'
|
||||
]
|
||||
};
|
||||
const ALL4 = {
|
||||
name: 'All4',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,c4assets.com',
|
||||
'DOMAIN-SUFFIX,channel4.com',
|
||||
'USER-AGENT,All4*'
|
||||
]
|
||||
};
|
||||
const AMAZON_PRIME_VIDEO = {
|
||||
name: 'Amazon Prime Video',
|
||||
rules: [
|
||||
'DOMAIN,avodmp4s3ww-a.akamaihd.net',
|
||||
'DOMAIN,d1v5ir2lpwr8os.cloudfront.net',
|
||||
'DOMAIN,d22qjgkvxw22r6.cloudfront.net',
|
||||
'DOMAIN,d25xi40x97liuc.cloudfront.net',
|
||||
'DOMAIN,dmqdd6hw24ucf.cloudfront.net',
|
||||
'DOMAIN,d27xxe7juh1us6.cloudfront.net',
|
||||
'DOMAIN,d184dfn36gombl.cloudfront.net',
|
||||
'DOMAIN,d1xfray82862hr.cloudfront.net',
|
||||
'DOMAIN,d3196yreox78o9.cloudfront.net',
|
||||
'DOMAIN-KEYWORD,avoddashs',
|
||||
'DOMAIN-SUFFIX,aiv-cdn.net',
|
||||
'DOMAIN-SUFFIX,aiv-delivery.net',
|
||||
'DOMAIN-SUFFIX,amazonvideo.com',
|
||||
'DOMAIN-SUFFIX,amazonvideo.cc',
|
||||
'DOMAIN-SUFFIX,media-amazon.com',
|
||||
'DOMAIN-SUFFIX,primevideo.com',
|
||||
'DOMAIN-SUFFIX,prime-video.com',
|
||||
'DOMAIN-SUFFIX,primevideo.cc',
|
||||
'DOMAIN-SUFFIX,primevideo.info',
|
||||
'DOMAIN-SUFFIX,primevideo.org',
|
||||
'DOMAIN-SUFFIX,primevideo.tv',
|
||||
'DOMAIN-SUFFIX,amazonvideodirect.cc',
|
||||
'DOMAIN-SUFFIX,amazonprimevideos.com',
|
||||
'DOMAIN-SUFFIX,atv-ps.amazon.com',
|
||||
'DOMAIN-SUFFIX,avodmp4s3ww-a.akamaihd.net',
|
||||
'DOMAIN-SUFFIX,fls-na.amazon.com',
|
||||
'USER-AGENT,InstantVideo.US*',
|
||||
'USER-AGENT,Prime Video*',
|
||||
'PROCESS-NAME,com.amazon.avod.thirdpartyclient'
|
||||
]
|
||||
};
|
||||
const ABEMA_TV = {
|
||||
name: 'AbemaTV',
|
||||
rules: [
|
||||
// Pure Front-End detection https://ds-linear-abematv.akamaized.net/region check HTTP 200
|
||||
'DOMAIN,ds-linear-abematv.akamaized.net',
|
||||
'DOMAIN-SUFFIX,abema.io',
|
||||
'DOMAIN-SUFFIX,abema.tv',
|
||||
'DOMAIN-SUFFIX,ameba.jp',
|
||||
'DOMAIN-SUFFIX,abema-tv.com',
|
||||
'DOMAIN-SUFFIX,hayabusa.dev',
|
||||
'DOMAIN-SUFFIX,hayabusa.io',
|
||||
'DOMAIN-SUFFIX,hayabusa.media',
|
||||
'DOMAIN-SUFFIX,amebame.com',
|
||||
'DOMAIN-SUFFIX,amebaownd.com',
|
||||
'DOMAIN-SUFFIX,amebaowndme.com',
|
||||
'DOMAIN-SUFFIX,ameblo.jp',
|
||||
'DOMAIN-SUFFIX,dokusho-ojikan.jp',
|
||||
'DOMAIN-SUFFIX,winticket.jp',
|
||||
'USER-AGENT,AbemaTV*'
|
||||
]
|
||||
};
|
||||
const APPLE_TV = {
|
||||
name: 'Apple TV',
|
||||
rules: [
|
||||
'DOMAIN,ocvideo.apple.com',
|
||||
'DOMAIN,linear.tv.apple.com',
|
||||
'DOMAIN,play-edge.itunes.apple.com',
|
||||
'DOMAIN,np-edge.itunes.apple.com',
|
||||
'DOMAIN,uts-api.itunes.apple.com',
|
||||
'DOMAIN,hls-amt.itunes.apple.com',
|
||||
'DOMAIN,hls.itunes.apple.com',
|
||||
'USER-AGENT,AppleTV*',
|
||||
'USER-AGENT,com.apple.tv*',
|
||||
'PROCESS-NAME,tv'
|
||||
]
|
||||
};
|
||||
const APPLE_MUSIC_TV = {
|
||||
name: 'Apple Music TV',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,applemusic.com',
|
||||
'PROCESS-NAME,music'
|
||||
]
|
||||
};
|
||||
const BAHAMUT = {
|
||||
name: 'Bahamut',
|
||||
rules: [
|
||||
// 'DOMAIN,bahamut.akamaized.net', // Akamai based CDN, no geoblock at all
|
||||
'DOMAIN,gamer-cds.cdn.hinet.net',
|
||||
'DOMAIN,gamer2-cds.cdn.hinet.net',
|
||||
'DOMAIN-SUFFIX,viblast.com',
|
||||
'DOMAIN-SUFFIX,bahamut.com.tw',
|
||||
'DOMAIN-SUFFIX,ani.gamer.com.tw',
|
||||
'USER-AGENT,Anime*'
|
||||
]
|
||||
};
|
||||
const BBC = {
|
||||
name: 'BBC',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,tvlicensing.co.uk',
|
||||
'DOMAIN-KEYWORD,bbcfmt',
|
||||
'DOMAIN-KEYWORD,uk-live',
|
||||
'DOMAIN-SUFFIX,bbc.co.uk',
|
||||
'DOMAIN-SUFFIX,bbci.co.uk',
|
||||
'USER-AGENT,BBCiPlayer*'
|
||||
]
|
||||
};
|
||||
const BILIBILI_INTL = {
|
||||
name: 'Bilibili International',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,biliintl.com',
|
||||
'DOMAIN,apm-misaka.biliapi.net',
|
||||
'DOMAIN,upos-bstar-mirrorakam.akamaized.net',
|
||||
'DOMAIN,upos-bstar1-mirrorakam.akamaized.net',
|
||||
// upos-sz-mirroralibstar1.bilivideo.com, from domain bilivideo.com and without geoblocking
|
||||
'DOMAIN-SUFFIX,bilibili.tv',
|
||||
'PROCESS-NAME,com.bstar.intl'
|
||||
]
|
||||
};
|
||||
const DAZN = {
|
||||
name: 'DAZN',
|
||||
rules: [
|
||||
'DOMAIN,d151l6v8er5bdm.cloudfront.net',
|
||||
'DOMAIN,d1sgwhnao7452x.cloudfront.net',
|
||||
'DOMAIN-KEYWORD,voddazn',
|
||||
'DOMAIN-SUFFIX,dazn-api.com',
|
||||
'DOMAIN-SUFFIX,dazn.com',
|
||||
'DOMAIN-SUFFIX,dazndn.com',
|
||||
'DOMAIN-SUFFIX,indazn.com',
|
||||
'DOMAIN-SUFFIX,indaznlab.com',
|
||||
'DOMAIN-SUFFIX,dca-ll-livedazn-dznlivejp.s.llnwi.net',
|
||||
'DOMAIN-SUFFIX,dcalivedazn.akamaized.net',
|
||||
'DOMAIN-SUFFIX,dcblivedazn.akamaized.net',
|
||||
'USER-AGENT,DAZN*'
|
||||
]
|
||||
};
|
||||
const DEEZER = {
|
||||
name: 'Deezer',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,deezer.com',
|
||||
'DOMAIN-SUFFIX,dzcdn.net',
|
||||
'USER-AGENT,Deezer*'
|
||||
]
|
||||
};
|
||||
const DISNEY_PLUS = {
|
||||
name: 'Disney+',
|
||||
rules: [
|
||||
'DOMAIN,cdn.registerdisney.go.com',
|
||||
'DOMAIN-SUFFIX,bamgrid.com',
|
||||
'DOMAIN-SUFFIX,disney-plus.net',
|
||||
'DOMAIN-SUFFIX,disneyplus.com',
|
||||
'DOMAIN-SUFFIX,dssott.com',
|
||||
'DOMAIN-SUFFIX,disneystreaming.com',
|
||||
'USER-AGENT,Disney+*'
|
||||
]
|
||||
};
|
||||
const DISCOVERY_PLUS = {
|
||||
name: 'Discovery+',
|
||||
rules: [
|
||||
'USER-AGENT,DPlus*',
|
||||
'USER-AGENT,discovery+*',
|
||||
'DOMAIN-SUFFIX,disco-api.com',
|
||||
'DOMAIN-SUFFIX,discoveryplus.co.uk',
|
||||
'DOMAIN-SUFFIX,discoveryplus.com',
|
||||
'DOMAIN-SUFFIX,discoveryplus.in',
|
||||
'DOMAIN-SUFFIX,dnitv.com'
|
||||
]
|
||||
};
|
||||
const DMM = {
|
||||
name: 'DMM',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,dmm.co.jp',
|
||||
'DOMAIN-SUFFIX,dmm.com',
|
||||
'DOMAIN-SUFFIX,dmm-extension.com'
|
||||
]
|
||||
};
|
||||
const ENCORE_TVB = {
|
||||
name: 'encoreTVB',
|
||||
rules: [
|
||||
'DOMAIN,bcbolt446c5271-a.akamaihd.net',
|
||||
'DOMAIN,edge.api.brightcove.com',
|
||||
'DOMAIN-SUFFIX,encoretvb.com',
|
||||
'USER-AGENT,encoreTVB*',
|
||||
'USER-AGENT,TVer-Release*'
|
||||
]
|
||||
};
|
||||
const ENCORE_TVB_JP_TVER = {
|
||||
name: 'encoreTVB JP',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,tver.jp'
|
||||
]
|
||||
};
|
||||
const FOX_NOW = {
|
||||
name: 'Fox Now',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,fox.com',
|
||||
'DOMAIN-SUFFIX,foxdcg.com',
|
||||
'DOMAIN-SUFFIX,uplynk.com',
|
||||
'USER-AGENT,FOX NOW*'
|
||||
]
|
||||
};
|
||||
const FOX_PLUS = {
|
||||
name: 'Fox+',
|
||||
rules: [
|
||||
'DOMAIN,dashasiafox.akamaized.net',
|
||||
'DOMAIN,staticasiafox.akamaized.net',
|
||||
'DOMAIN-SUFFIX,foxplus.com',
|
||||
'DOMAIN-SUFFIX,theplatform.com',
|
||||
'USER-AGENT,FOXPlus*'
|
||||
]
|
||||
};
|
||||
const HBO = {
|
||||
name: 'HBO Go / HBO Now / HBO Max / Max',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,hbo.com',
|
||||
'DOMAIN-SUFFIX,hbogo.com',
|
||||
'DOMAIN-SUFFIX,hbonow.com',
|
||||
'USER-AGENT,HBO NOW*',
|
||||
'USER-AGENT,HBOMAX*',
|
||||
'DOMAIN-SUFFIX,hbomax.com',
|
||||
'DOMAIN-SUFFIX,hbomaxcdn.com',
|
||||
// 'USER-AGENT,Max',
|
||||
// 'PROCESS-NAME,com.wbd.stream',
|
||||
'DOMAIN-SUFFIX,max.com',
|
||||
'DOMAIN-SUFFIX,discomax.com'
|
||||
]
|
||||
};
|
||||
const HBO_ASIA = {
|
||||
name: 'HBO Asia',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,hboasia.com',
|
||||
'DOMAIN-SUFFIX,hbogoasia.com',
|
||||
'DOMAIN-SUFFIX,hbogoasia.hk',
|
||||
'DOMAIN-KEYWORD,.hbogoasia.',
|
||||
'DOMAIN,44wilhpljf.execute-api.ap-southeast-1.amazonaws.com',
|
||||
// 'DOMAIN,bcbolthboa-a.akamaihd.net',
|
||||
// 'DOMAIN,cf-images.ap-southeast-1.prod.boltdns.net',
|
||||
// 'DOMAIN,dai3fd1oh325y.cloudfront.net',
|
||||
// 'DOMAIN,hboasia1-i.akamaihd.net',
|
||||
// 'DOMAIN,hboasia2-i.akamaihd.net',
|
||||
// 'DOMAIN,hboasia3-i.akamaihd.net',
|
||||
// 'DOMAIN,hboasia4-i.akamaihd.net',
|
||||
// 'DOMAIN,hboasia5-i.akamaihd.net',
|
||||
// 'DOMAIN,hbogoprod-vod.akamaized.net',
|
||||
'DOMAIN,manifest.prod.boltdns.net',
|
||||
'DOMAIN,players.brightcove.net',
|
||||
// 'DOMAIN,hboasialive.akamaized.net',
|
||||
'DOMAIN,hbounify-prod.evergent.com',
|
||||
'DOMAIN,hbolb.onwardsmg.com'
|
||||
]
|
||||
};
|
||||
const HIMALAYA_FM = {
|
||||
name: 'Himalaya FM',
|
||||
rules: [
|
||||
'USER-AGENT,Himalaya*',
|
||||
'DOMAIN-SUFFIX,himalaya.com'
|
||||
]
|
||||
};
|
||||
const HULU = {
|
||||
name: 'Hulu',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,hulu.com',
|
||||
'DOMAIN-SUFFIX,hulu.tv',
|
||||
'DOMAIN-SUFFIX,hulu.us',
|
||||
'DOMAIN-SUFFIX,huluim.com',
|
||||
'DOMAIN-SUFFIX,hulustream.com',
|
||||
'USER-AGENT,Hulu*',
|
||||
'PROCESS-NAME,com.hulu.plus'
|
||||
]
|
||||
};
|
||||
const HULU_JP = {
|
||||
name: 'Hulu Japan',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,happyon.jp',
|
||||
'DOMAIN-SUFFIX,hjholdings.jp',
|
||||
'DOMAIN-SUFFIX,hulu.jp'
|
||||
]
|
||||
};
|
||||
const HWTV = {
|
||||
name: 'HWTV',
|
||||
rules: [
|
||||
'USER-AGENT,HWTVMobile*',
|
||||
'DOMAIN-SUFFIX,5itv.tv',
|
||||
'DOMAIN-SUFFIX,ocnttv.com'
|
||||
]
|
||||
};
|
||||
const ITV = {
|
||||
name: 'ITV',
|
||||
rules: [
|
||||
'DOMAIN,itvpnpmobile-a.akamaihd.net',
|
||||
'DOMAIN-SUFFIX,itv.com',
|
||||
'USER-AGENT,ITV_Player*'
|
||||
]
|
||||
};
|
||||
const IQIYI_GLOBAL = {
|
||||
name: 'iQiYi Global',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,iq.com',
|
||||
'DOMAIN,cache.video.iqiyi.com',
|
||||
'DOMAIN,cache-video.iq.com',
|
||||
'DOMAIN,akmcdnoversea-tw.inter.ptqy.gitv.tv',
|
||||
'DOMAIN,chuangcachecdnoversea-tw.inter.ptqy.gitv.tv',
|
||||
'DOMAIN-SUFFIX,inter.iqiyi.com',
|
||||
'DOMAIN-SUFFIX,intl-rcd.iqiyi.com',
|
||||
'DOMAIN-SUFFIX,intl-subscription.iqiyi.com',
|
||||
'DOMAIN-SUFFIX,intl.iqiyi.com'
|
||||
]
|
||||
};
|
||||
const JOOX = {
|
||||
name: 'JOOX',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,joox.com',
|
||||
'DOMAIN-KEYWORD,jooxweb-api',
|
||||
'USER-AGENT,JOOX*',
|
||||
'USER-AGENT,WeMusic*',
|
||||
'PROCESS-NAME,com.tencent.ibg.joox'
|
||||
]
|
||||
};
|
||||
const KKBOX = {
|
||||
name: 'KKBOX',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,kfs.io',
|
||||
'DOMAIN-SUFFIX,kkbox.com',
|
||||
'DOMAIN-SUFFIX,kkbox.com.tw',
|
||||
'DOMAIN-SUFFIX,kkbox-prime.com',
|
||||
'DOMAIN-SUFFIX,kktix.com'
|
||||
]
|
||||
};
|
||||
const KKTV = {
|
||||
name: 'KKTV',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,kk.stream',
|
||||
'DOMAIN-SUFFIX,kktv.com.tw',
|
||||
'DOMAIN-SUFFIX,kktv.me',
|
||||
'USER-AGENT,com.kktv.ios.kktv*',
|
||||
'USER-AGENT,KKTV*'
|
||||
]
|
||||
};
|
||||
const LINE_TV = {
|
||||
name: 'Line TV',
|
||||
rules: [
|
||||
'DOMAIN,d3c7rimkq79yfu.cloudfront.net',
|
||||
'DOMAIN-SUFFIX,linetv.tw',
|
||||
'USER-AGENT,LINE TV*',
|
||||
'PROCESS-NAME,com.linecorp.linetv'
|
||||
]
|
||||
};
|
||||
const LITV = {
|
||||
name: 'LiTV',
|
||||
rules: [
|
||||
'DOMAIN,litvfreemobile-hichannel.cdn.hinet.net',
|
||||
'DOMAIN-SUFFIX,litv.tv'
|
||||
]
|
||||
};
|
||||
const MY5 = {
|
||||
name: 'My5',
|
||||
rules: [
|
||||
'DOMAIN,d349g9zuie06uo.cloudfront.net',
|
||||
'DOMAIN-SUFFIX,channel5.com',
|
||||
'DOMAIN-SUFFIX,my5.tv',
|
||||
'USER-AGENT,My5*'
|
||||
]
|
||||
};
|
||||
const MYTV_SUPER = {
|
||||
name: 'myTV Super',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,mytvsuper.com',
|
||||
'DOMAIN-SUFFIX,tvb.com',
|
||||
'DOMAIN-SUFFIX,psg.cdn.hgc.com.hk',
|
||||
'USER-AGENT,mytv*',
|
||||
'DOMAIN-KEYWORD,nowtv100',
|
||||
'DOMAIN-KEYWORD,rthklive'
|
||||
]
|
||||
};
|
||||
const NAVER_TV = {
|
||||
name: 'Naver TV',
|
||||
rules: [
|
||||
'USER-AGENT,Naver TV*',
|
||||
'DOMAIN-SUFFIX,tv.naver.com',
|
||||
'DOMAIN-SUFFIX,smartmediarep.com'
|
||||
]
|
||||
};
|
||||
const NICONICO = {
|
||||
name: 'niconico',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,dmc.nico',
|
||||
'DOMAIN-SUFFIX,nicovideo.jp',
|
||||
'DOMAIN-SUFFIX,asset.domand.nicovideo.jp',
|
||||
// 'DOMAIN-SUFFIX,nimg.jp',
|
||||
'DOMAIN-SUFFIX,socdm.com',
|
||||
'USER-AGENT,Niconico*'
|
||||
]
|
||||
};
|
||||
const NETFLIX = {
|
||||
name: 'Netflix',
|
||||
ip: {
|
||||
v4: [
|
||||
'23.246.18.0/23',
|
||||
'37.77.184.0/21',
|
||||
'45.57.0.0/17',
|
||||
'64.120.128.0/17',
|
||||
'66.197.128.0/17',
|
||||
'69.53.224.0/19',
|
||||
'108.175.32.0/20',
|
||||
'185.2.220.0/22',
|
||||
'185.9.188.0/22',
|
||||
'192.173.64.0/18',
|
||||
'198.38.96.0/19',
|
||||
'198.45.48.0/20',
|
||||
'208.75.76.0/22'
|
||||
],
|
||||
v6: [
|
||||
'2607:fb10::/32',
|
||||
'2620:10c:7000::/44',
|
||||
'2a00:86c0::/32',
|
||||
'2a03:5640::/32'
|
||||
]
|
||||
},
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,netflix.ca',
|
||||
'DOMAIN-SUFFIX,netflix.com',
|
||||
'DOMAIN-SUFFIX,netflix.net',
|
||||
'DOMAIN-SUFFIX,nflxext.com',
|
||||
'DOMAIN-SUFFIX,nflximg.com',
|
||||
'DOMAIN-SUFFIX,nflximg.net',
|
||||
'DOMAIN-SUFFIX,nflxso.net',
|
||||
'DOMAIN-SUFFIX,nflxvideo.net',
|
||||
'DOMAIN-SUFFIX,nflxsearch.net',
|
||||
'DOMAIN-SUFFIX,netflix.com.edgesuite.net',
|
||||
'DOMAIN-KEYWORD,netflixdnstest',
|
||||
'DOMAIN-KEYWORD,dualstack.apiproxy-',
|
||||
'DOMAIN-KEYWORD,dualstack.ichnaea-web-',
|
||||
'DOMAIN-KEYWORD,apiproxy-device-prod-nlb-',
|
||||
'USER-AGENT,Argo*',
|
||||
'PROCESS-NAME,com.netflix.mediaclient'
|
||||
]
|
||||
};
|
||||
const NHK_PLUS = {
|
||||
name: 'NHK Plus',
|
||||
rules: [
|
||||
// Pure Front-End detection just like AbemaTV: https://location-plus.nhk.jp/geoip/area.json
|
||||
'DOMAIN-SUFFIX,location-plus.nhk.jp'
|
||||
]
|
||||
};
|
||||
const NOW_E = {
|
||||
name: 'Now E',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,nowe.com'
|
||||
]
|
||||
};
|
||||
const OVERCAST_FM = {
|
||||
name: 'Overcast FM',
|
||||
rules: [
|
||||
'USER-AGENT,Overcast*',
|
||||
'DOMAIN-SUFFIX,overcast.fm'
|
||||
]
|
||||
};
|
||||
const PARAMOUNT = {
|
||||
name: 'Paramount+',
|
||||
rules: [
|
||||
'USER-AGENT,PPlus*',
|
||||
'DOMAIN-SUFFIX,pluto.tv',
|
||||
'DOMAIN-SUFFIX,cbsi.com',
|
||||
'DOMAIN-SUFFIX,cbsaavideo.com',
|
||||
'DOMAIN-SUFFIX,cbsivideo.com',
|
||||
'DOMAIN-SUFFIX,paramountplus.com',
|
||||
'DOMAIN,cbsi.live.ott.irdeto.com',
|
||||
'DOMAIN,cbsplaylistserver.aws.syncbak.com',
|
||||
'DOMAIN,cbsservice.aws.syncbak.com',
|
||||
'DOMAIN,link.theplatform.com'
|
||||
]
|
||||
};
|
||||
const PBS = {
|
||||
name: 'PBS',
|
||||
rules: [
|
||||
'USER-AGENT,PBS*',
|
||||
'DOMAIN-SUFFIX,pbs.org'
|
||||
]
|
||||
};
|
||||
const PEACOCK = {
|
||||
name: 'Peacock',
|
||||
rules: [
|
||||
'USER-AGENT,PeacockMobile*',
|
||||
'DOMAIN-SUFFIX,peacocktv.com'
|
||||
]
|
||||
};
|
||||
const PANDORA = {
|
||||
name: 'Pandora',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,pandora.com',
|
||||
'USER-AGENT,Pandora*'
|
||||
]
|
||||
};
|
||||
const PORNHUB = {
|
||||
name: 'Pornhub',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,phprcdn.com',
|
||||
'DOMAIN-SUFFIX,pornhub.com',
|
||||
'DOMAIN-SUFFIX,pornhubpremium.com'
|
||||
]
|
||||
};
|
||||
const SOUNDCLOUD = {
|
||||
name: 'SoundCloud',
|
||||
rules: [
|
||||
// 'DOMAIN-SUFFIX,sndcdn.com',
|
||||
'DOMAIN-SUFFIX,soundcloud.com',
|
||||
'USER-AGENT,SoundCloud*'
|
||||
]
|
||||
};
|
||||
const SPOTIFY = {
|
||||
name: 'Spotify',
|
||||
ip: {
|
||||
v4: [
|
||||
'35.186.224.47/32'
|
||||
],
|
||||
v6: []
|
||||
},
|
||||
rules: [
|
||||
'DOMAIN-KEYWORD,-spotify-com',
|
||||
'DOMAIN-SUFFIX,pscdn.co',
|
||||
'DOMAIN-SUFFIX,scdn.co',
|
||||
'DOMAIN-SUFFIX,spoti.fi',
|
||||
'DOMAIN-SUFFIX,spotify.com',
|
||||
'DOMAIN-SUFFIX,byspotify.com',
|
||||
'DOMAIN-SUFFIX,spotify-everywhere.com',
|
||||
'DOMAIN-SUFFIX,spotify.design',
|
||||
'DOMAIN-SUFFIX,spotifycdn.com',
|
||||
'DOMAIN-SUFFIX,spotifycdn.net',
|
||||
'DOMAIN-SUFFIX,spotifycharts.com',
|
||||
'DOMAIN-SUFFIX,spotifycodes.com',
|
||||
'DOMAIN-SUFFIX,spotifyforbrands.com',
|
||||
'DOMAIN-SUFFIX,spotifyjobs.com',
|
||||
'DOMAIN-SUFFIX,spotify-com.akamaized.net',
|
||||
'DOMAIN-SUFFIX,spotifynewsroom.jp',
|
||||
'DOMAIN-SUFFIX,spotilocal.com',
|
||||
'DOMAIN-SUFFIX,tospotify.com',
|
||||
'USER-AGENT,*Spotify*'
|
||||
]
|
||||
};
|
||||
const TVB_ANYWHERE = {
|
||||
name: 'TVB Anywhere',
|
||||
rules: [
|
||||
'DOMAIN-KEYWORD,tvbanywhere'
|
||||
]
|
||||
};
|
||||
const TAIWAN_GOOD = {
|
||||
name: 'TaiwanGood',
|
||||
rules: [
|
||||
'DOMAIN,hamifans.emome.net',
|
||||
'DOMAIN-SUFFIX,skyking.com.tw',
|
||||
'USER-AGENT,TaiwanGood*',
|
||||
'PROCESS-NAME,com.twgood.android'
|
||||
]
|
||||
};
|
||||
const TIDAL = {
|
||||
name: 'TIDAL',
|
||||
rules: [
|
||||
'USER-AGENT,TIDAL*',
|
||||
'DOMAIN-SUFFIX,tidal.com',
|
||||
'DOMAIN-SUFFIX,tidalhifi.com'
|
||||
]
|
||||
};
|
||||
const TIKTOK = {
|
||||
name: 'TikTok',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,byteoversea.com',
|
||||
'DOMAIN-SUFFIX,ibytedtos.com',
|
||||
// 'DOMAIN-SUFFIX,ibyteimg.com', // We confirm that tiktokcdn DOES NOT have ANY geoblock
|
||||
'DOMAIN-SUFFIX,ipstatp.com',
|
||||
'DOMAIN-SUFFIX,isnssdk.com',
|
||||
'DOMAIN-SUFFIX,muscdn.com',
|
||||
'DOMAIN-SUFFIX,musical.ly',
|
||||
'DOMAIN-SUFFIX,tiktok.com',
|
||||
'DOMAIN-SUFFIX,tiktok.us',
|
||||
'DOMAIN-SUFFIX,tiktokv.us',
|
||||
'DOMAIN-SUFFIX,tik-tokapi.com',
|
||||
// 'DOMAIN-SUFFIX,tiktokcdn.com', // We confirm that tiktokcdn DOES NOT have ANY geoblock
|
||||
'DOMAIN-SUFFIX,tiktokv.com',
|
||||
'DOMAIN-SUFFIX,tiktokw.com',
|
||||
'DOMAIN-KEYWORD,-tiktokcdn-com',
|
||||
'USER-AGENT,TikTok*'
|
||||
]
|
||||
};
|
||||
const TWITCH = {
|
||||
name: 'Twitch',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,jtvnw.net',
|
||||
'DOMAIN-SUFFIX,ttvnw.net',
|
||||
'DOMAIN-SUFFIX,twitch.tv',
|
||||
'DOMAIN-SUFFIX,twitchcdn.net',
|
||||
'DOMAIN-SUFFIX,twitchsvc.net',
|
||||
'DOMAIN-SUFFIX,ext-twitch.tv',
|
||||
'PROCESS-NAME,tv.twitch.android.app'
|
||||
]
|
||||
};
|
||||
const VIUTV = {
|
||||
name: 'ViuTV',
|
||||
rules: [
|
||||
'DOMAIN,api.viu.now.com',
|
||||
'DOMAIN,d1k2us671qcoau.cloudfront.net',
|
||||
'DOMAIN,d2anahhhmp1ffz.cloudfront.net',
|
||||
'DOMAIN,dfp6rglgjqszk.cloudfront.net',
|
||||
'DOMAIN-SUFFIX,viu.com',
|
||||
'DOMAIN-SUFFIX,viu.now.com',
|
||||
'DOMAIN-SUFFIX,viu.tv',
|
||||
'PROCESS-NAME,com.viu.pad',
|
||||
'PROCESS-NAME,com.viu.phone',
|
||||
'PROCESS-NAME,com.vuclip.viu',
|
||||
'PROCESS-NAME,com.hktve.viutv',
|
||||
'USER-AGENT,Viu*'
|
||||
]
|
||||
};
|
||||
const YOUTUBE = {
|
||||
name: 'YouTube',
|
||||
rules: [
|
||||
'DOMAIN,youtubei.googleapis.com',
|
||||
'DOMAIN,youtube.googleapis.com',
|
||||
'DOMAIN-SUFFIX,googlevideo.com',
|
||||
'DOMAIN-SUFFIX,youtube.com',
|
||||
'DOMAIN-SUFFIX,withyoutube.com',
|
||||
'DOMAIN-SUFFIX,youtubeeducation.com',
|
||||
'DOMAIN-SUFFIX,youtubegaming.com',
|
||||
'DOMAIN-SUFFIX,youtubekids.com',
|
||||
'DOMAIN-SUFFIX,youtube-nocookie.com',
|
||||
'USER-AGENT,com.google.ios.youtube*',
|
||||
'USER-AGENT,YouTube*'
|
||||
]
|
||||
};
|
||||
const YOUTUBE_MUSIC = {
|
||||
name: 'YouTube Music',
|
||||
rules: [
|
||||
'USER-AGENT,com.google.ios.youtubemusic*',
|
||||
'USER-AGENT,YouTubeMusic*'
|
||||
]
|
||||
};
|
||||
const SHOWTIME = {
|
||||
name: 'SHOWTIME',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,sho.com',
|
||||
'DOMAIN-SUFFIX,showtime.com'
|
||||
]
|
||||
};
|
||||
const WETV = {
|
||||
name: 'WeTV',
|
||||
ip: {
|
||||
v4: [
|
||||
'150.109.28.51/32'
|
||||
],
|
||||
v6: []
|
||||
},
|
||||
rules: [
|
||||
'USER-AGENT,WeTV*',
|
||||
'DOMAIN-SUFFIX,wetv.vip',
|
||||
'DOMAIN-SUFFIX,wetvinfo.com'
|
||||
]
|
||||
};
|
||||
const VUDU = {
|
||||
name: 'Vudu',
|
||||
rules: [
|
||||
'DOMAIN-SUFFIX,vudu.com'
|
||||
]
|
||||
};
|
||||
const ALL = [
|
||||
$4GTV,
|
||||
ABEMA_TV,
|
||||
AMAZON_PRIME_VIDEO,
|
||||
ALL4,
|
||||
APPLE_TV,
|
||||
APPLE_MUSIC_TV,
|
||||
BAHAMUT,
|
||||
BBC,
|
||||
BILIBILI_INTL,
|
||||
DAZN,
|
||||
DEEZER,
|
||||
DISNEY_PLUS,
|
||||
DISCOVERY_PLUS,
|
||||
DMM,
|
||||
ENCORE_TVB,
|
||||
ENCORE_TVB_JP_TVER,
|
||||
FOX_NOW,
|
||||
FOX_PLUS,
|
||||
HBO,
|
||||
HBO_ASIA,
|
||||
HIMALAYA_FM,
|
||||
HULU,
|
||||
HWTV,
|
||||
IQIYI_GLOBAL,
|
||||
ITV,
|
||||
JOOX,
|
||||
KKBOX,
|
||||
KKTV,
|
||||
LINE_TV,
|
||||
LITV,
|
||||
MY5,
|
||||
MYTV_SUPER,
|
||||
NETFLIX,
|
||||
NAVER_TV,
|
||||
NICONICO,
|
||||
NHK_PLUS,
|
||||
NOW_E,
|
||||
OVERCAST_FM,
|
||||
PARAMOUNT,
|
||||
PBS,
|
||||
PEACOCK,
|
||||
PANDORA,
|
||||
PORNHUB,
|
||||
SOUNDCLOUD,
|
||||
SHOWTIME,
|
||||
SPOTIFY,
|
||||
TAIWAN_GOOD,
|
||||
TIDAL,
|
||||
TIKTOK,
|
||||
TVB_ANYWHERE,
|
||||
TWITCH,
|
||||
VIUTV,
|
||||
VUDU,
|
||||
WETV,
|
||||
YOUTUBE,
|
||||
YOUTUBE_MUSIC
|
||||
];
|
||||
const NORTH_AMERICA = [
|
||||
FOX_NOW,
|
||||
FOX_PLUS,
|
||||
HULU,
|
||||
HULU_JP,
|
||||
VUDU,
|
||||
// HBO,
|
||||
// www.nfl.com
|
||||
// epix.com
|
||||
// starz.com
|
||||
// www.philo.com
|
||||
// https://www.shudder.com/
|
||||
// https://www.britbox.com
|
||||
// crackle.com
|
||||
// www.cwtv.com
|
||||
// www.aetv.com
|
||||
// https://www.nba.com/watch/
|
||||
// fubo.tv
|
||||
// mola.tv
|
||||
// https://setantasports.com/
|
||||
// tubitv.com
|
||||
// SlingTV
|
||||
// PlutoTV
|
||||
// AcornTV
|
||||
SHOWTIME,
|
||||
ENCORE_TVB,
|
||||
// Funimation
|
||||
DISCOVERY_PLUS,
|
||||
PARAMOUNT,
|
||||
PEACOCK
|
||||
];
|
||||
const EU = [
|
||||
// RakutenTV
|
||||
// Funimation
|
||||
// SkyShowTime
|
||||
// HBO,
|
||||
// MathSpot
|
||||
// SkyGo
|
||||
// BritBox
|
||||
ITV,
|
||||
// BBC Channel 4
|
||||
// BBC Channel 5
|
||||
BBC
|
||||
];
|
||||
const HK = [
|
||||
NOW_E,
|
||||
VIUTV,
|
||||
MYTV_SUPER,
|
||||
HBO_ASIA,
|
||||
BILIBILI_INTL
|
||||
];
|
||||
const TW = [
|
||||
KKTV,
|
||||
LITV,
|
||||
// MyVideo
|
||||
$4GTV,
|
||||
LINE_TV,
|
||||
// HamiVideo
|
||||
// CatchPlay
|
||||
HBO_ASIA,
|
||||
BAHAMUT
|
||||
];
|
||||
const JP = [
|
||||
DMM,
|
||||
// DMMTV
|
||||
ABEMA_TV,
|
||||
NICONICO,
|
||||
// music.jp
|
||||
// Telasa
|
||||
// Paravi
|
||||
// unext
|
||||
HULU_JP,
|
||||
ENCORE_TVB_JP_TVER,
|
||||
NHK_PLUS
|
||||
];
|
||||
const AU = [];
|
||||
const KR = [
|
||||
// WAVEE
|
||||
// Tving
|
||||
// CoupangPlay
|
||||
NAVER_TV
|
||||
];
|
||||
const SOUTH_EAST_ASIA = [];
|
||||
} (stream));
|
||||
return stream;
|
||||
}exports.r=requireStream;
|
||||
540
Dist/chunks/trie.Vu1FNyv-.cjs
Normal file
540
Dist/chunks/trie.Vu1FNyv-.cjs
Normal file
@@ -0,0 +1,540 @@
|
||||
'use strict';const misc=require('./misc.BpcQjda1.cjs'),require$$1=require('node:util'),require$$2=require('foxts/noop'),require$$3=require('foxts/fast-string-array-join'),require$$4=require('foxts/bitwise');var trie = {};/**
|
||||
* Hostbane-Optimized Trie based on Mnemonist Trie
|
||||
*/
|
||||
|
||||
var hasRequiredTrie;
|
||||
|
||||
function requireTrie () {
|
||||
if (hasRequiredTrie) return trie;
|
||||
hasRequiredTrie = 1;
|
||||
(function (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, {
|
||||
HostnameSmolTrie: function() {
|
||||
return HostnameSmolTrie;
|
||||
},
|
||||
HostnameTrie: function() {
|
||||
return HostnameTrie;
|
||||
}
|
||||
});
|
||||
const _misc = /*@__PURE__*/ misc.r();
|
||||
const _nodeutil = /*#__PURE__*/ _interop_require_default(require$$1);
|
||||
const _noop = require$$2;
|
||||
const _faststringarrayjoin = require$$3;
|
||||
const _bitwise = require$$4;
|
||||
function _interop_require_default(obj) {
|
||||
return obj && obj.__esModule ? obj : {
|
||||
default: obj
|
||||
};
|
||||
}
|
||||
var _computedKey;
|
||||
const START = 1 << 1;
|
||||
const INCLUDE_ALL_SUBDOMAIN = 1 << 2;
|
||||
function deepTrieNodeToJSON(node, unpackMeta) {
|
||||
const obj = {};
|
||||
obj['[start]'] = (0, _bitwise.getBit)(node[0], START);
|
||||
obj['[subdomain]'] = (0, _bitwise.getBit)(node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
if (node[3] != null) {
|
||||
if (unpackMeta) {
|
||||
obj['[meta]'] = unpackMeta(node[3]);
|
||||
} else {
|
||||
obj['[meta]'] = node[3];
|
||||
}
|
||||
}
|
||||
node[2].forEach((value, key)=>{
|
||||
obj[key] = deepTrieNodeToJSON(value, unpackMeta);
|
||||
});
|
||||
return obj;
|
||||
}
|
||||
const createNode = (parent = null)=>[
|
||||
1,
|
||||
parent,
|
||||
new Map(),
|
||||
null
|
||||
];
|
||||
function hostnameToTokens(hostname, hostnameFromIndex) {
|
||||
const tokens = hostname.split('.');
|
||||
const results = [];
|
||||
let token = '';
|
||||
for(let i = hostnameFromIndex, l = tokens.length; i < l; i++){
|
||||
token = tokens[i];
|
||||
if (token.length > 0) {
|
||||
results.push(token);
|
||||
} else {
|
||||
throw new TypeError(JSON.stringify({
|
||||
hostname,
|
||||
hostnameFromIndex
|
||||
}, null, 2));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
function walkHostnameTokens(hostname, onToken, hostnameFromIndex) {
|
||||
const tokens = hostname.split('.');
|
||||
const l = tokens.length - 1;
|
||||
// we are at the first of hostname, no splitor there
|
||||
let token = '';
|
||||
for(let i = l; i >= hostnameFromIndex; i--){
|
||||
token = tokens[i];
|
||||
if (token.length > 0) {
|
||||
const t = onToken(token);
|
||||
if (t === null) {
|
||||
return null;
|
||||
}
|
||||
// if the callback returns true, we should skip the rest
|
||||
if (t) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
_computedKey = _nodeutil.default.inspect.custom;
|
||||
class Triebase {
|
||||
$root = createNode();
|
||||
$size = 0;
|
||||
get root() {
|
||||
return this.$root;
|
||||
}
|
||||
constructor(from){
|
||||
// Actually build trie
|
||||
if (Array.isArray(from)) {
|
||||
for(let i = 0, l = from.length; i < l; i++){
|
||||
this.add(from[i]);
|
||||
}
|
||||
} else if (from) {
|
||||
from.forEach((value)=>this.add(value));
|
||||
}
|
||||
}
|
||||
walkIntoLeafWithTokens(tokens, onLoop = _noop.noop) {
|
||||
let node = this.$root;
|
||||
let parent = node;
|
||||
let token;
|
||||
let child = node[2];
|
||||
// reverse lookup from end to start
|
||||
for(let i = tokens.length - 1; i >= 0; i--){
|
||||
token = tokens[i];
|
||||
// if (token === '') {
|
||||
// break;
|
||||
// }
|
||||
parent = node;
|
||||
child = node[2];
|
||||
// cache node index access is 20% faster than direct access when doing twice
|
||||
if (child.has(token)) {
|
||||
node = child.get(token);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
onLoop(node, parent, token);
|
||||
}
|
||||
return {
|
||||
node,
|
||||
parent
|
||||
};
|
||||
}
|
||||
walkIntoLeafWithSuffix(suffix, hostnameFromIndex, onLoop = _noop.noop) {
|
||||
let node = this.$root;
|
||||
let parent = node;
|
||||
let child = node[2];
|
||||
const onToken = (token)=>{
|
||||
// if (token === '') {
|
||||
// return true;
|
||||
// }
|
||||
parent = node;
|
||||
child = node[2];
|
||||
if (child.has(token)) {
|
||||
node = child.get(token);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
onLoop(node, parent, token);
|
||||
return false;
|
||||
};
|
||||
if (walkHostnameTokens(suffix, onToken, hostnameFromIndex) === null) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
node,
|
||||
parent
|
||||
};
|
||||
}
|
||||
contains(suffix, includeAllSubdomain = suffix[0] === '.') {
|
||||
const hostnameFromIndex = suffix[0] === '.' ? 1 : 0;
|
||||
const res = this.walkIntoLeafWithSuffix(suffix, hostnameFromIndex);
|
||||
if (!res) return false;
|
||||
if (includeAllSubdomain) return (0, _bitwise.getBit)(res.node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
return true;
|
||||
}
|
||||
static bfsResults = [
|
||||
null,
|
||||
[]
|
||||
];
|
||||
static dfs(nodeStack, suffixStack) {
|
||||
const node = nodeStack.pop();
|
||||
const suffix = suffixStack.pop();
|
||||
node[2].forEach((childNode, k)=>{
|
||||
// Pushing the child node to the stack for next iteration of DFS
|
||||
nodeStack.push(childNode);
|
||||
suffixStack.push([
|
||||
k,
|
||||
...suffix
|
||||
]);
|
||||
});
|
||||
Triebase.bfsResults[0] = node;
|
||||
Triebase.bfsResults[1] = suffix;
|
||||
return Triebase.bfsResults;
|
||||
}
|
||||
static dfsWithSort(nodeStack, suffixStack) {
|
||||
const node = nodeStack.pop();
|
||||
const suffix = suffixStack.pop();
|
||||
const child = node[2];
|
||||
if (child.size) {
|
||||
const keys = Array.from(child.keys()).sort(Triebase.compare);
|
||||
for(let i = 0, l = keys.length; i < l; i++){
|
||||
const key = keys[i];
|
||||
const childNode = child.get(key);
|
||||
// Pushing the child node to the stack for next iteration of DFS
|
||||
nodeStack.push(childNode);
|
||||
suffixStack.push([
|
||||
key,
|
||||
...suffix
|
||||
]);
|
||||
}
|
||||
}
|
||||
Triebase.bfsResults[0] = node;
|
||||
Triebase.bfsResults[1] = suffix;
|
||||
return Triebase.bfsResults;
|
||||
}
|
||||
walk(onMatches, initialNode = this.$root, initialSuffix = [], withSort = false) {
|
||||
const bfsImpl = withSort ? Triebase.dfsWithSort : Triebase.dfs;
|
||||
const nodeStack = [];
|
||||
nodeStack.push(initialNode);
|
||||
// Resolving initial string (begin the start of the stack)
|
||||
const suffixStack = [];
|
||||
suffixStack.push(initialSuffix);
|
||||
let node = initialNode;
|
||||
let r;
|
||||
do {
|
||||
r = bfsImpl(nodeStack, suffixStack);
|
||||
node = r[0];
|
||||
const suffix = r[1];
|
||||
// If the node is a sentinel, we push the suffix to the results
|
||||
if ((0, _bitwise.getBit)(node[0], START)) {
|
||||
onMatches(suffix, (0, _bitwise.getBit)(node[0], INCLUDE_ALL_SUBDOMAIN), node[3]);
|
||||
}
|
||||
}while (nodeStack.length)
|
||||
}
|
||||
static compare(a, b) {
|
||||
if (a === b) return 0;
|
||||
return a.length - b.length || (0, _misc.fastStringCompare)(a, b);
|
||||
}
|
||||
walkWithSort(onMatches, initialNode = this.$root, initialSuffix = []) {
|
||||
const nodeStack = [];
|
||||
nodeStack.push(initialNode);
|
||||
// Resolving initial string (begin the start of the stack)
|
||||
const suffixStack = [];
|
||||
suffixStack.push(initialSuffix);
|
||||
let node = initialNode;
|
||||
let child = node[2];
|
||||
do {
|
||||
node = nodeStack.pop();
|
||||
const suffix = suffixStack.pop();
|
||||
child = node[2];
|
||||
if (child.size) {
|
||||
const keys = Array.from(child.keys()).sort(Triebase.compare);
|
||||
for(let i = 0, l = keys.length; i < l; i++){
|
||||
const key = keys[i];
|
||||
const childNode = child.get(key);
|
||||
// Pushing the child node to the stack for next iteration of DFS
|
||||
nodeStack.push(childNode);
|
||||
suffixStack.push([
|
||||
key,
|
||||
...suffix
|
||||
]);
|
||||
}
|
||||
}
|
||||
// If the node is a sentinel, we push the suffix to the results
|
||||
if ((0, _bitwise.getBit)(node[0], START)) {
|
||||
onMatches(suffix, (0, _bitwise.getBit)(node[0], INCLUDE_ALL_SUBDOMAIN), node[3]);
|
||||
}
|
||||
}while (nodeStack.length)
|
||||
}
|
||||
getSingleChildLeaf(tokens) {
|
||||
let toPrune = null;
|
||||
let tokenToPrune = null;
|
||||
const onLoop = (node, parent, token)=>{
|
||||
// Keeping track of a potential branch to prune
|
||||
const child = node[2];
|
||||
// console.log({
|
||||
// child, parent, token
|
||||
// });
|
||||
// console.log(this.inspect(0));
|
||||
if (toPrune !== null) {
|
||||
if (child.size > 1) {
|
||||
// The branch has some children, the branch need retain.
|
||||
// And we need to abort prune that parent branch, so we set it to null
|
||||
toPrune = null;
|
||||
tokenToPrune = null;
|
||||
}
|
||||
} else if (child.size < 1) {
|
||||
// There is only one token child, or no child at all, we can prune it safely
|
||||
// It is now the top-est branch that could potentially being pruned
|
||||
toPrune = parent;
|
||||
tokenToPrune = token;
|
||||
}
|
||||
};
|
||||
const res = this.walkIntoLeafWithTokens(tokens, onLoop);
|
||||
if (res === null) return null;
|
||||
return {
|
||||
node: res.node,
|
||||
toPrune,
|
||||
tokenToPrune,
|
||||
parent: res.parent
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Method used to retrieve every item in the trie with the given prefix.
|
||||
*/ find(inputSuffix, subdomainOnly = inputSuffix[0] === '.', hostnameFromIndex = inputSuffix[0] === '.' ? 1 : 0) {
|
||||
const inputTokens = hostnameToTokens(inputSuffix, hostnameFromIndex);
|
||||
const res = this.walkIntoLeafWithTokens(inputTokens);
|
||||
if (res === null) return [];
|
||||
const results = [];
|
||||
const onMatches = subdomainOnly ? (suffix, subdomain)=>{
|
||||
const d = (0, _faststringarrayjoin.fastStringArrayJoin)(suffix, '.');
|
||||
if (!subdomain && subStringEqual(inputSuffix, d, 1)) return;
|
||||
results.push(subdomain ? '.' + d : d);
|
||||
} : (suffix, subdomain)=>{
|
||||
const d = (0, _faststringarrayjoin.fastStringArrayJoin)(suffix, '.');
|
||||
results.push(subdomain ? '.' + d : d);
|
||||
};
|
||||
this.walk(onMatches, res.node, inputTokens);
|
||||
return results;
|
||||
}
|
||||
/**
|
||||
* Method used to delete a prefix from the trie.
|
||||
*/ remove(suffix) {
|
||||
const res = this.getSingleChildLeaf(hostnameToTokens(suffix, 0));
|
||||
if (res === null) return false;
|
||||
if ((0, _bitwise.missingBit)(res.node[0], START)) return false;
|
||||
this.$size--;
|
||||
const { node, toPrune, tokenToPrune } = res;
|
||||
if (tokenToPrune && toPrune) {
|
||||
toPrune[2].delete(tokenToPrune);
|
||||
} else {
|
||||
node[0] = (0, _bitwise.deleteBit)(node[0], START);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/unbound-method -- safe
|
||||
delete = this.remove;
|
||||
/**
|
||||
* Method used to assert whether the given prefix exists in the Trie.
|
||||
*/ has(suffix, includeAllSubdomain = suffix[0] === '.') {
|
||||
const hostnameFromIndex = suffix[0] === '.' ? 1 : 0;
|
||||
const res = this.walkIntoLeafWithSuffix(suffix, hostnameFromIndex);
|
||||
if (res === null) return false;
|
||||
if ((0, _bitwise.missingBit)(res.node[0], START)) return false;
|
||||
if (includeAllSubdomain) return (0, _bitwise.getBit)(res.node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
return true;
|
||||
}
|
||||
dumpWithoutDot(onSuffix, withSort = false) {
|
||||
const handleSuffix = (suffix, subdomain)=>{
|
||||
onSuffix((0, _faststringarrayjoin.fastStringArrayJoin)(suffix, '.'), subdomain);
|
||||
};
|
||||
if (withSort) {
|
||||
this.walkWithSort(handleSuffix);
|
||||
} else {
|
||||
this.walk(handleSuffix);
|
||||
}
|
||||
}
|
||||
dump(onSuffix, withSort = false) {
|
||||
const results = [];
|
||||
const handleSuffix = onSuffix ? (suffix, subdomain)=>{
|
||||
const d = (0, _faststringarrayjoin.fastStringArrayJoin)(suffix, '.');
|
||||
onSuffix(subdomain ? '.' + d : d);
|
||||
} : (suffix, subdomain)=>{
|
||||
const d = (0, _faststringarrayjoin.fastStringArrayJoin)(suffix, '.');
|
||||
results.push(subdomain ? '.' + d : d);
|
||||
};
|
||||
if (withSort) {
|
||||
this.walkWithSort(handleSuffix);
|
||||
} else {
|
||||
this.walk(handleSuffix);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
dumpMeta(onMeta, withSort = false) {
|
||||
const results = [];
|
||||
const handleMeta = onMeta ? (_suffix, _subdomain, meta)=>onMeta(meta) : (_suffix, _subdomain, meta)=>results.push(meta);
|
||||
if (withSort) {
|
||||
this.walkWithSort(handleMeta);
|
||||
} else {
|
||||
this.walk(handleMeta);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
dumpWithMeta(onSuffix, withSort = false) {
|
||||
const results = [];
|
||||
const handleSuffix = onSuffix ? (suffix, subdomain, meta)=>{
|
||||
const d = (0, _faststringarrayjoin.fastStringArrayJoin)(suffix, '.');
|
||||
return onSuffix(subdomain ? '.' + d : d, meta);
|
||||
} : (suffix, subdomain, meta)=>{
|
||||
const d = (0, _faststringarrayjoin.fastStringArrayJoin)(suffix, '.');
|
||||
results.push([
|
||||
subdomain ? '.' + d : d,
|
||||
meta
|
||||
]);
|
||||
};
|
||||
if (withSort) {
|
||||
this.walkWithSort(handleSuffix);
|
||||
} else {
|
||||
this.walk(handleSuffix);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
inspect(depth, unpackMeta) {
|
||||
return (0, _faststringarrayjoin.fastStringArrayJoin)(JSON.stringify(deepTrieNodeToJSON(this.$root, unpackMeta), null, 2).split('\n').map((line)=>' '.repeat(depth) + line), '\n');
|
||||
}
|
||||
[_computedKey](depth) {
|
||||
return this.inspect(depth);
|
||||
}
|
||||
merge(trie) {
|
||||
const handleSuffix = (suffix, subdomain, meta)=>{
|
||||
this.add((0, _faststringarrayjoin.fastStringArrayJoin)(suffix, '.'), subdomain, meta);
|
||||
};
|
||||
trie.walk(handleSuffix);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class HostnameSmolTrie extends Triebase {
|
||||
smolTree = true;
|
||||
add(suffix, includeAllSubdomain = suffix[0] === '.', meta, hostnameFromIndex = suffix[0] === '.' ? 1 : 0) {
|
||||
let node = this.$root;
|
||||
let curNodeChildren = node[2];
|
||||
const onToken = (token)=>{
|
||||
curNodeChildren = node[2];
|
||||
if (curNodeChildren.has(token)) {
|
||||
node = curNodeChildren.get(token);
|
||||
// During the adding of `[start]blog|.skk.moe` and find out that there is a `[start].skk.moe` in the trie, skip adding the rest of the node
|
||||
if ((0, _bitwise.getBit)(node[0], INCLUDE_ALL_SUBDOMAIN)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
const newNode = createNode(node);
|
||||
curNodeChildren.set(token, newNode);
|
||||
node = newNode;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
// When walkHostnameTokens returns true, we should skip the rest
|
||||
if (walkHostnameTokens(suffix, onToken, hostnameFromIndex)) {
|
||||
return;
|
||||
}
|
||||
// If we are in smolTree mode, we need to do something at the end of the loop
|
||||
if (includeAllSubdomain) {
|
||||
// Trying to add `[.]sub.example.com` where there is already a `blog.sub.example.com` in the trie
|
||||
// Make sure parent `[start]sub.example.com` (without dot) is removed (SETINEL to false)
|
||||
// (/** parent */ node[2]!)[0] = false;
|
||||
// Removing the rest of the parent's child nodes
|
||||
node[2].clear();
|
||||
// The SENTINEL of this node will be set to true at the end of the function, so we don't need to set it here
|
||||
// we can use else-if here, because the children is now empty, we don't need to check the leading "."
|
||||
} else if ((0, _bitwise.getBit)(node[0], INCLUDE_ALL_SUBDOMAIN)) {
|
||||
// Trying to add `example.com` when there is already a `.example.com` in the trie
|
||||
// No need to increment size and set SENTINEL to true (skip this "new" item)
|
||||
return;
|
||||
}
|
||||
node[0] = (0, _bitwise.setBit)(node[0], START);
|
||||
if (includeAllSubdomain) {
|
||||
node[0] = (0, _bitwise.setBit)(node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
} else {
|
||||
node[0] = (0, _bitwise.deleteBit)(node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
}
|
||||
node[3] = meta;
|
||||
}
|
||||
whitelist(suffix, includeAllSubdomain = suffix[0] === '.', hostnameFromIndex = suffix[0] === '.' ? 1 : 0) {
|
||||
const tokens = hostnameToTokens(suffix, hostnameFromIndex);
|
||||
const res = this.getSingleChildLeaf(tokens);
|
||||
if (res === null) return;
|
||||
const { node, toPrune, tokenToPrune } = res;
|
||||
// Trying to whitelist `[start].sub.example.com` where there might already be a `[start]blog.sub.example.com` in the trie
|
||||
if (includeAllSubdomain) {
|
||||
// If there is a `[start]sub.example.com` here, remove it
|
||||
node[0] = (0, _bitwise.deleteBit)(node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
node[0] = (0, _bitwise.deleteBit)(node[0], START);
|
||||
// Removing all the child nodes by empty the children
|
||||
node[2].clear();
|
||||
} else {
|
||||
// Trying to whitelist `example.com` when there is already a `.example.com` in the trie
|
||||
node[0] = (0, _bitwise.deleteBit)(node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
}
|
||||
// return early if not found
|
||||
if ((0, _bitwise.missingBit)(node[0], START)) return;
|
||||
if (toPrune && tokenToPrune) {
|
||||
toPrune[2].delete(tokenToPrune);
|
||||
} else {
|
||||
node[0] = (0, _bitwise.deleteBit)(node[0], START);
|
||||
}
|
||||
}
|
||||
}
|
||||
class HostnameTrie extends Triebase {
|
||||
get size() {
|
||||
return this.$size;
|
||||
}
|
||||
add(suffix, includeAllSubdomain = suffix[0] === '.', meta, hostnameFromIndex = suffix[0] === '.' ? 1 : 0) {
|
||||
let node = this.$root;
|
||||
let child = node[2];
|
||||
const onToken = (token)=>{
|
||||
child = node[2];
|
||||
if (child.has(token)) {
|
||||
node = child.get(token);
|
||||
} else {
|
||||
const newNode = createNode(node);
|
||||
child.set(token, newNode);
|
||||
node = newNode;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
// When walkHostnameTokens returns true, we should skip the rest
|
||||
if (walkHostnameTokens(suffix, onToken, hostnameFromIndex)) {
|
||||
return;
|
||||
}
|
||||
// if same entry has been added before, skip
|
||||
if ((0, _bitwise.getBit)(node[0], START)) {
|
||||
return;
|
||||
}
|
||||
this.$size++;
|
||||
node[0] = (0, _bitwise.setBit)(node[0], START);
|
||||
if (includeAllSubdomain) {
|
||||
node[0] = (0, _bitwise.setBit)(node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
} else {
|
||||
node[0] = (0, _bitwise.deleteBit)(node[0], INCLUDE_ALL_SUBDOMAIN);
|
||||
}
|
||||
node[3] = meta;
|
||||
}
|
||||
}
|
||||
// function deepEqualArray(a: string[], b: string[]) {
|
||||
// let len = a.length;
|
||||
// if (len !== b.length) return false;
|
||||
// while (len--) {
|
||||
// if (a[len] !== b[len]) return false;
|
||||
// }
|
||||
// return true;
|
||||
// };
|
||||
function subStringEqual(needle, haystack, needleIndex = 0) {
|
||||
for(let i = 0, l = haystack.length; i < l; i++){
|
||||
if (needle[i + needleIndex] !== haystack[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} (trie));
|
||||
return trie;
|
||||
}exports.r=requireTrie;
|
||||
Reference in New Issue
Block a user