mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-28 17:41:54 +08:00
Chore: create rule set / Add China IP sing-box
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { fetchRemoteTextByLine } from './lib/fetch-text-by-line';
|
||||
import { resolve as pathResolve } from 'path';
|
||||
import { compareAndWriteFile, withBannerArray } from './lib/create-file';
|
||||
import { createRuleset } from './lib/create-file';
|
||||
import { processLineFromReadline } from './lib/process-line';
|
||||
import { task } from './trace';
|
||||
|
||||
@@ -8,6 +7,7 @@ import { exclude } from 'fast-cidr-tools';
|
||||
import { createMemoizedPromise } from './lib/memo-promise';
|
||||
import { CN_CIDR_NOT_INCLUDED_IN_CHNROUTE, NON_CN_CIDR_INCLUDED_IN_CHNROUTE } from './constants/cidr';
|
||||
import { appendArrayInPlace } from './lib/append-array-in-place';
|
||||
import { output } from './lib/misc';
|
||||
|
||||
export const getChnCidrPromise = createMemoizedPromise(async () => {
|
||||
const cidr4 = await processLineFromReadline(await fetchRemoteTextByLine('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt'));
|
||||
@@ -30,57 +30,29 @@ export const buildChnCidr = task(require.main === module, __filename)(async (spa
|
||||
|
||||
// Can not use createRuleset here, as Clash support advanced ipset syntax
|
||||
return Promise.all([
|
||||
compareAndWriteFile(
|
||||
createRuleset(
|
||||
span,
|
||||
withBannerArray(
|
||||
'Sukka\'s Ruleset - Mainland China IPv4 CIDR',
|
||||
[
|
||||
...description,
|
||||
'Data from https://misaka.io (misakaio @ GitHub)'
|
||||
],
|
||||
new Date(),
|
||||
filteredCidr4.map(i => `IP-CIDR,${i}`)
|
||||
),
|
||||
pathResolve(__dirname, '../List/ip/china_ip.conf')
|
||||
'Sukka\'s Ruleset - Mainland China IPv4 CIDR',
|
||||
[
|
||||
...description,
|
||||
'Data from https://misaka.io (misakaio @ GitHub)'
|
||||
],
|
||||
new Date(),
|
||||
filteredCidr4,
|
||||
'ipcidr',
|
||||
...output('china_ip', 'ip')
|
||||
),
|
||||
compareAndWriteFile(
|
||||
createRuleset(
|
||||
span,
|
||||
withBannerArray(
|
||||
'Sukka\'s Ruleset - Mainland China IPv6 CIDR',
|
||||
[
|
||||
...description,
|
||||
'Data from https://github.com/gaoyifan/china-operator-ip'
|
||||
],
|
||||
new Date(),
|
||||
cidr6.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(),
|
||||
filteredCidr4
|
||||
),
|
||||
pathResolve(__dirname, '../Clash/ip/china_ip.txt')
|
||||
),
|
||||
compareAndWriteFile(
|
||||
span,
|
||||
withBannerArray(
|
||||
'Sukka\'s Ruleset - Mainland China IPv6 CIDR',
|
||||
[
|
||||
...description,
|
||||
'Data from https://github.com/gaoyifan/china-operator-ip'
|
||||
],
|
||||
new Date(),
|
||||
cidr6
|
||||
),
|
||||
pathResolve(__dirname, '../Clash/ip/china_ip_ipv6.txt')
|
||||
'Sukka\'s Ruleset - Mainland China IPv6 CIDR',
|
||||
[
|
||||
...description,
|
||||
'Data from https://github.com/gaoyifan/china-operator-ip'
|
||||
],
|
||||
new Date(),
|
||||
cidr6,
|
||||
'ipcidr6',
|
||||
...output('china_ip_ipv6', 'ip')
|
||||
)
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user