From 2db87bd57d85455a51ad2a50927b6caf84a23a5e Mon Sep 17 00:00:00 2001 From: SukkaW Date: Tue, 6 Aug 2024 17:18:51 +0800 Subject: [PATCH] Feat: add China IPv6 list --- Build/build-chn-cidr.ts | 52 +++++++++++++++++++----- Build/build-internal-reverse-chn-cidr.ts | 2 +- Build/build-sspanel-appprofile.ts | 5 ++- README.md | 16 ++++++-- 4 files changed, 60 insertions(+), 15 deletions(-) diff --git a/Build/build-chn-cidr.ts b/Build/build-chn-cidr.ts index 11de2b8a..c58b6225 100644 --- a/Build/build-chn-cidr.ts +++ b/Build/build-chn-cidr.ts @@ -10,22 +10,22 @@ import { CN_CIDR_NOT_INCLUDED_IN_CHNROUTE, NON_CN_CIDR_INCLUDED_IN_CHNROUTE } fr import { appendArrayInPlace } from './lib/append-array-in-place'; export const getChnCidrPromise = createMemoizedPromise(async () => { - const cidr = await processLineFromReadline(await fetchRemoteTextByLine('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt')); + const cidr4 = await processLineFromReadline(await fetchRemoteTextByLine('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt')); + const cidr6 = await processLineFromReadline(await fetchRemoteTextByLine('https://gaoyifan.github.io/china-operator-ip/china6.txt')); - appendArrayInPlace(cidr, CN_CIDR_NOT_INCLUDED_IN_CHNROUTE); - return exclude(cidr, NON_CN_CIDR_INCLUDED_IN_CHNROUTE, true); + appendArrayInPlace(cidr4, CN_CIDR_NOT_INCLUDED_IN_CHNROUTE); + return [exclude(cidr4, NON_CN_CIDR_INCLUDED_IN_CHNROUTE, true), cidr6] as const; }); export const buildChnCidr = task(require.main === module, __filename)(async (span) => { - const filteredCidr = await span.traceChildAsync('download chnroutes2', getChnCidrPromise); + const [filteredCidr4, cidr6] = await span.traceChildAsync('download chnroutes2', getChnCidrPromise); // Can not use SHARED_DESCRIPTION here as different license const description = [ 'License: CC BY-SA 2.0', 'Homepage: https://ruleset.skk.moe', 'GitHub: https://github.com/SukkaW/Surge', - '', - 'Data from https://misaka.io (misakaio @ GitHub)' + '' ]; // Can not use createRuleset here, as Clash support advanced ipset syntax @@ -34,9 +34,12 @@ export const buildChnCidr = task(require.main === module, __filename)(async (spa span, withBannerArray( 'Sukka\'s Ruleset - Mainland China IPv4 CIDR', - description, + [ + ...description, + 'Data from https://misaka.io (misakaio @ GitHub)' + ], new Date(), - filteredCidr.map(i => `IP-CIDR,${i}`) + filteredCidr4.map(i => `IP-CIDR,${i}`) ), pathResolve(__dirname, '../List/ip/china_ip.conf') ), @@ -44,11 +47,40 @@ export const buildChnCidr = task(require.main === module, __filename)(async (spa span, withBannerArray( 'Sukka\'s Ruleset - Mainland China IPv4 CIDR', - description, + [ + ...description, + 'Data from https://github.com/gaoyifan/china-operator-ip' + ], new Date(), - filteredCidr + filteredCidr4.map(i => `IP-CIDR6,${i}`) + ), + pathResolve(__dirname, '../List/ip/china_ip_ipv6.conf') + ), + compareAndWriteFile( + span, + withBannerArray( + 'Sukka\'s Ruleset - Mainland China IPv4 CIDR', + [ + ...description, + 'Data from https://misaka.io (misakaio @ GitHub)' + ], + new Date(), + cidr6 ), pathResolve(__dirname, '../Clash/ip/china_ip.txt') + ), + compareAndWriteFile( + span, + withBannerArray( + 'Sukka\'s Ruleset - Mainland China IPv4 CIDR', + [ + ...description, + 'Data from https://github.com/gaoyifan/china-operator-ip' + ], + new Date(), + cidr6 + ), + pathResolve(__dirname, '../Clash/ip/china_ip_ipv6.txt') ) ]); }); diff --git a/Build/build-internal-reverse-chn-cidr.ts b/Build/build-internal-reverse-chn-cidr.ts index 57d240cf..29b8e3a5 100644 --- a/Build/build-internal-reverse-chn-cidr.ts +++ b/Build/build-internal-reverse-chn-cidr.ts @@ -8,7 +8,7 @@ import { NON_CN_CIDR_INCLUDED_IN_CHNROUTE, RESERVED_IPV4_CIDR } from './constant import { writeFile } from './lib/misc'; export const buildInternalReverseChnCIDR = task(require.main === module, __filename)(async () => { - const cidr = await getChnCidrPromise(); + const [cidr] = await getChnCidrPromise(); const reversedCidr = merge( exclude( diff --git a/Build/build-sspanel-appprofile.ts b/Build/build-sspanel-appprofile.ts index c3241ac9..79f0be8e 100644 --- a/Build/build-sspanel-appprofile.ts +++ b/Build/build-sspanel-appprofile.ts @@ -68,7 +68,10 @@ export const buildSSPanelUIMAppProfile = task(require.main === module, __filenam readFileIntoProcessedArray(path.resolve(__dirname, '../Source/non_ip/global.conf')).then(surgeRulesetToClashClassicalTextRuleset), readFileIntoProcessedArray(path.resolve(__dirname, '../Source/non_ip/telegram.conf')).then(surgeRulesetToClashClassicalTextRuleset), // domestic - ip cidr - getChnCidrPromise().then(cidrs => cidrs.map(cidr => `IP-CIDR,${cidr}`)), + getChnCidrPromise().then(([cidrs4, cidrs6]) => [ + ...cidrs4.map(cidr => `IP-CIDR,${cidr}`), + ...cidrs6.map(cidr => `IP-CIDR,${cidr}`) + ]), AllStreamServices.flatMap((i) => ( i.ip ? [ diff --git a/README.md b/README.md index aa50e386..0f522fbd 100644 --- a/README.md +++ b/README.md @@ -710,13 +710,15 @@ rules: #### chnroute CIDR - 自动生成 -- [原始数据](https://github.com/misakaio/chnroutes2) 由 Misaka Network, Inc.、DMIT, Inc.、NEROCLOUD Ltd.、Rainbow network Ltd.、MOACK Co., Ltd. 提供,由 Misaka Network, Inc. 整理,以 [CC BY-SA 2.0](https://creativecommons.org/licenses/by-sa/2.0/) 协议发布 -- 二次处理:补充合并了 Misaka Network, Inc. 收不到 BGP 路由的部分国内段、排除了被 Misaka Network, Inc. 误收的在香港广播的 IP 段(通常由 中国移动国际 CMI 广播) +- IPv4 [原始数据](https://github.com/misakaio/chnroutes2) 由 Misaka Network, Inc. 以 [CC BY-SA 2.0](https://creativecommons.org/licenses/by-sa/2.0/) 协议发布,二次处理补充合并了 Misaka Network, Inc. 收不到 BGP 路由的部分国内段、排除了被 Misaka Network, Inc. 误收的在香港广播的 IP 段(通常由 中国移动国际 CMI 广播) +- IPv6 原始数据 由 [gaoyifan/china-operator-ip](https://github.com/gaoyifan/china-operator-ip) 以 MIT 协议发布 **Surge** ```ini RULE-SET,https://ruleset.skk.moe/List/ip/china_ip.conf,[Replace with your policy] +# Only use it if you are using IPv6 +# RULE-SET,https://ruleset.skk.moe/List/ip/china_ip_ipv6.conf,[Replace with your policy] ``` **Clash Premium** @@ -730,9 +732,17 @@ rule-providers: interval: 43200 url: https://ruleset.skk.moe/Clash/ip/china_ip.txt path: ./sukkaw_ruleset/china_ip.txt - + china_ip_ipv6: + type: http + behavior: ipcidr + format: text + interval: 43200 + url: https://ruleset.skk.moe/Clash/ip/china_ip_ipv6.txt + path: ./sukkaw_ruleset/china_ip.txt rules: - RULE-SET,china_ip,[Replace with your policy] + # Only use it if you are using IPv6 + # - RULE-SET,china_ip_ipv6,[Replace with your policy] ``` ## Surge 模块列表