mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
Chore: build sukka_always_real_ip.sgmodule w/ script
This commit is contained in:
parent
d41b4d031a
commit
b0dd2501a7
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,6 +9,7 @@ List/
|
|||||||
Clash/
|
Clash/
|
||||||
Modules/sukka_local_dns_mapping.sgmodule
|
Modules/sukka_local_dns_mapping.sgmodule
|
||||||
Modules/sukka_url_redirect.sgmodule
|
Modules/sukka_url_redirect.sgmodule
|
||||||
|
Modules/sukka_common_always_realip.sgmodule
|
||||||
Mock/www-google-analytics-com_ga.js
|
Mock/www-google-analytics-com_ga.js
|
||||||
Mock/www-googletagservices-com_gpt.js
|
Mock/www-googletagservices-com_gpt.js
|
||||||
Mock/www-google-analytics-com_analytics.js
|
Mock/www-google-analytics-com_analytics.js
|
||||||
|
|||||||
56
Build/build-sgmodule-always-realip.ts
Normal file
56
Build/build-sgmodule-always-realip.ts
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import path from 'path';
|
||||||
|
import { task } from './lib/trace-runner';
|
||||||
|
import { compareAndWriteFile } from './lib/create-file';
|
||||||
|
|
||||||
|
const HOSTNAMES = [
|
||||||
|
// Intranet
|
||||||
|
'*.lan',
|
||||||
|
'*.localdomain',
|
||||||
|
'*.localhost',
|
||||||
|
'*.home.arpa',
|
||||||
|
// Network Detection, Captive Portal
|
||||||
|
'*.msftncsi.com',
|
||||||
|
'*.msftconnecttest.com',
|
||||||
|
'network-test.debian.org',
|
||||||
|
'detectportal.firefox.com',
|
||||||
|
'resolver1.opendns.com',
|
||||||
|
// Handle SNAT conversation properly
|
||||||
|
'*.srv.nintendo.net',
|
||||||
|
'*.stun.playstation.net',
|
||||||
|
'xbox.*.microsoft.com',
|
||||||
|
'*.xboxlive.com',
|
||||||
|
'*.turn.twilio.com',
|
||||||
|
'*.stun.twilio.com',
|
||||||
|
'stun.*.*',
|
||||||
|
'stun.*.*.*',
|
||||||
|
// NTP
|
||||||
|
'time.*.com', 'time.*.gov, time.*.edu.cn, time.*.apple.com', 'time1.*.com', 'time2.*.com', 'time3.*.com', 'time4.*.com', 'time5.*.com', 'time6.*.com', 'time7.*.com', 'time8.*.com', 'time9.*.com, ntp.*.com, ntp1.*.com, ntp2.*.com, ntp3.*.com, ntp4.*.com, ntp5.*.com, ntp6.*.com, ntp7.*.com', 'time1.*.com', 'time2.*.com', 'time3.*.com', 'time4.*.com', 'time5.*.com', 'time6.*.com', 'time7.*.com', 'time8.*.com', 'ti me9.*.com', '*.time.edu.cn', '*.ntp.org.cn', '*.pool.ntp.org', 'time1.cloud.tencent.com',
|
||||||
|
// AdGuard
|
||||||
|
'local.adguard.org',
|
||||||
|
'injections.adguard.org',
|
||||||
|
// QQ Login
|
||||||
|
'localhost.ptlogin2.qq.com',
|
||||||
|
'localhost.sec.qq.com',
|
||||||
|
'localhost.work.weixin.qq.com',
|
||||||
|
// Microsoft Auto Discovery
|
||||||
|
'PDC._msDCS.*.*',
|
||||||
|
'DC._msDCS.*.*',
|
||||||
|
'GC._msDCS.*.*'
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export const buildAlwaysRealIPModule = task(import.meta.path, async () => {
|
||||||
|
return compareAndWriteFile(
|
||||||
|
[
|
||||||
|
'#!name=[Sukka] Always Real IP Plus',
|
||||||
|
`#!desc=Last Updated: ${new Date().toISOString()}`,
|
||||||
|
'',
|
||||||
|
'[General]',
|
||||||
|
`always-real-ip = %APPEND% ${HOSTNAMES.join(', ')}`
|
||||||
|
],
|
||||||
|
path.resolve(import.meta.dir, '../Modules/sukka_common_always_realip.sgmodule')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (import.meta.main) {
|
||||||
|
buildAlwaysRealIPModule();
|
||||||
|
}
|
||||||
@ -12,7 +12,7 @@ function escapeRegExp(string = '') {
|
|||||||
: string;
|
: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const REDIRECT = /** @type {const} */ ([
|
const REDIRECT = [
|
||||||
// Gravatar
|
// Gravatar
|
||||||
['gravatar.neworld.org/', 'https://secure.gravatar.com/'],
|
['gravatar.neworld.org/', 'https://secure.gravatar.com/'],
|
||||||
['cdn.v2ex.com/gravatar/', 'https://secure.gravatar.com/avatar/'],
|
['cdn.v2ex.com/gravatar/', 'https://secure.gravatar.com/avatar/'],
|
||||||
@ -69,7 +69,7 @@ const REDIRECT = /** @type {const} */ ([
|
|||||||
['pics.javbus.com/', 'https://i0.wp.com/pics.javbus.com/'],
|
['pics.javbus.com/', 'https://i0.wp.com/pics.javbus.com/'],
|
||||||
['googlefonts.wp-china-yes.net/', 'https://fonts.googleapis.com/'],
|
['googlefonts.wp-china-yes.net/', 'https://fonts.googleapis.com/'],
|
||||||
['googleajax.wp-china-yes.net/', 'https://ajax.googleapis.com/']
|
['googleajax.wp-china-yes.net/', 'https://ajax.googleapis.com/']
|
||||||
]);
|
] as const;
|
||||||
|
|
||||||
export const buildRedirectModule = task(import.meta.path, async () => {
|
export const buildRedirectModule = task(import.meta.path, async () => {
|
||||||
const domains = Array.from(new Set(REDIRECT.map(([from]) => tldts.getHostname(from, { detectIp: false })))).filter(Boolean);
|
const domains = Array.from(new Set(REDIRECT.map(([from]) => tldts.getHostname(from, { detectIp: false })))).filter(Boolean);
|
||||||
@ -11,7 +11,10 @@ import { buildInternalCDNDomains } from './build-internal-cdn-rules';
|
|||||||
// import { buildInternalChnDomains } from './build-internal-chn-domains';
|
// import { buildInternalChnDomains } from './build-internal-chn-domains';
|
||||||
import { buildDomesticRuleset } from './build-domestic-ruleset';
|
import { buildDomesticRuleset } from './build-domestic-ruleset';
|
||||||
import { buildStreamService } from './build-stream-service';
|
import { buildStreamService } from './build-stream-service';
|
||||||
import { buildRedirectModule } from './build-redirect-module';
|
|
||||||
|
import { buildRedirectModule } from './build-sgmodule-redirect';
|
||||||
|
import { buildAlwaysRealIPModule } from './build-sgmodule-always-realip';
|
||||||
|
|
||||||
import { validate } from './validate-domainset';
|
import { validate } from './validate-domainset';
|
||||||
|
|
||||||
import { buildMicrosoftCdn } from './build-microsoft-cdn';
|
import { buildMicrosoftCdn } from './build-microsoft-cdn';
|
||||||
@ -19,10 +22,11 @@ import { buildSSPanelUIMAppProfile } from './build-sspanel-appprofile';
|
|||||||
|
|
||||||
import { buildPublic } from './build-public';
|
import { buildPublic } from './build-public';
|
||||||
import { downloadMockAssets } from './download-mock-assets';
|
import { downloadMockAssets } from './download-mock-assets';
|
||||||
// import type { TaskResult } from './lib/trace-runner';
|
|
||||||
|
import type { TaskResult } from './lib/trace-runner';
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
console.log('Bun version:', Bun.version);
|
console.log('Bun version:', Bun.version, Bun.revision);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: restore this once Bun has fixed their worker
|
// TODO: restore this once Bun has fixed their worker
|
||||||
@ -66,6 +70,8 @@ import { downloadMockAssets } from './download-mock-assets';
|
|||||||
const buildDomesticRulesetPromise = downloadPreviousBuildPromise.then(() => buildDomesticRuleset());
|
const buildDomesticRulesetPromise = downloadPreviousBuildPromise.then(() => buildDomesticRuleset());
|
||||||
|
|
||||||
const buildRedirectModulePromise = downloadPreviousBuildPromise.then(() => buildRedirectModule());
|
const buildRedirectModulePromise = downloadPreviousBuildPromise.then(() => buildRedirectModule());
|
||||||
|
const buildAlwaysRealIPModulePromise = downloadPreviousBuildPromise.then(() => buildAlwaysRealIPModule());
|
||||||
|
|
||||||
const buildStreamServicePromise = downloadPreviousBuildPromise.then(() => buildStreamService());
|
const buildStreamServicePromise = downloadPreviousBuildPromise.then(() => buildStreamService());
|
||||||
|
|
||||||
const buildMicrosoftCdnPromise = downloadPreviousBuildPromise.then(() => buildMicrosoftCdn());
|
const buildMicrosoftCdnPromise = downloadPreviousBuildPromise.then(() => buildMicrosoftCdn());
|
||||||
@ -92,6 +98,7 @@ import { downloadMockAssets } from './download-mock-assets';
|
|||||||
// buildInternalChnDomainsPromise,
|
// buildInternalChnDomainsPromise,
|
||||||
buildDomesticRulesetPromise,
|
buildDomesticRulesetPromise,
|
||||||
buildRedirectModulePromise,
|
buildRedirectModulePromise,
|
||||||
|
buildAlwaysRealIPModulePromise,
|
||||||
buildStreamServicePromise,
|
buildStreamServicePromise,
|
||||||
buildMicrosoftCdnPromise,
|
buildMicrosoftCdnPromise,
|
||||||
buildSSPanelUIMAppProfilePromise,
|
buildSSPanelUIMAppProfilePromise,
|
||||||
@ -112,7 +119,7 @@ import { downloadMockAssets } from './download-mock-assets';
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function printStats(stats: Array<{ start: number, end: number, taskName: string }>): void {
|
function printStats(stats: TaskResult[]): void {
|
||||||
stats.sort((a, b) => a.start - b.start);
|
stats.sort((a, b) => a.start - b.start);
|
||||||
|
|
||||||
const longestTaskName = Math.max(...stats.map(i => i.taskName.length));
|
const longestTaskName = Math.max(...stats.map(i => i.taskName.length));
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
#!name=[Sukka] Always Real IP Plus
|
|
||||||
#!system=mac
|
|
||||||
|
|
||||||
[General]
|
|
||||||
always-real-ip = %APPEND%, *.msftncsi.com, *.msftconnecttest.com, network-test.debian.org, detectportal.firefox.com, resolver1.opendns.com, *.srv.nintendo.net, *.stun.playstation.net, xbox.*.microsoft.com, *.xboxlive.com, *.linksys.com, *.linksyssmartwifi.com, time.*.com, time.*.gov, time.*.edu.cn, time.*.apple.com, time1.*.com, time2.*.com, time3.*.com, time4.*.com, time5.*.com, time6.*.com, time7.*.com, time8.*.com, time9.*.com, ntp.*.com, ntp1.*.com, ntp2.*.com, ntp3.*.com, ntp4.*.com, ntp5.*.com, ntp6.*.com, ntp7.*.com, time1.*.com, time2.*.com, time3.*.com, time4.*.com, time5.*.com, time6.*.com, time7.*.com, time8.*.com, time9.*.com, *.time.edu.cn, *.ntp.org.cn, *.pool.ntp.org, time1.cloud.tencent.com, localhost.ptlogin2.qq.com, localhost.sec.qq.com, localhost.work.weixin.qq.com, stun.*.*, stun.*.*.*, local.adguard.org, injections.adguard.org, *.cmpassport.com, *.id6.me, open.e.189.cn, mdn.open.wo.cn, opencloud.wostore.cn, auth.wosms.cn, *.turn.twilio.com, *.stun.twilio.com, *.lan, *.localdomain, *.localhost, *.home.arpa
|
|
||||||
Loading…
x
Reference in New Issue
Block a user