浏览代码

Feat: add China IPv6 list

SukkaW 1 年之前
父节点
当前提交
2db87bd57d
共有 4 个文件被更改,包括 60 次插入15 次删除
  1. 42 10
      Build/build-chn-cidr.ts
  2. 1 1
      Build/build-internal-reverse-chn-cidr.ts
  3. 4 1
      Build/build-sspanel-appprofile.ts
  4. 13 3
      README.md

+ 42 - 10
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')
     )
   ]);
 });

+ 1 - 1
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(

+ 4 - 1
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
         ? [

+ 13 - 3
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 模块列表