Feat: add China IPv6 list

This commit is contained in:
SukkaW 2024-08-06 17:18:51 +08:00
parent ffb92989fa
commit 2db87bd57d
4 changed files with 60 additions and 15 deletions

View File

@ -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')
)
]);
});

View File

@ -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(

View File

@ -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
? [

View File

@ -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 模块列表