mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Chore: update build infra / use fast-cidr-tools
This commit is contained in:
parent
7548dc1b03
commit
2e3ef60ad3
@ -4,22 +4,21 @@ import { compareAndWriteFile, withBannerArray } from './lib/create-file';
|
||||
import { processLineFromReadline } from './lib/process-line';
|
||||
import { task } from './lib/trace-runner';
|
||||
|
||||
import { exclude } from 'fast-cidr-tools';
|
||||
|
||||
// https://github.com/misakaio/chnroutes2/issues/25
|
||||
const EXCLUDE_CIDRS = [
|
||||
'223.118.0.0/15',
|
||||
'223.120.0.0/15'
|
||||
];
|
||||
|
||||
// preload the module
|
||||
import('cidr-tools-wasm');
|
||||
const INCLUDE_CIDRS = [
|
||||
'211.99.96.0/19' // wy.com.cn
|
||||
];
|
||||
|
||||
export const buildChnCidr = task(import.meta.path, async () => {
|
||||
const [{ exclude }, cidr] = await Promise.all([
|
||||
import('cidr-tools-wasm'),
|
||||
processLineFromReadline(await fetchRemoteTextAndCreateReadlineInterface('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt'))
|
||||
]);
|
||||
|
||||
const filteredCidr = exclude(cidr, EXCLUDE_CIDRS, true);
|
||||
const cidr = await processLineFromReadline(await fetchRemoteTextAndCreateReadlineInterface('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt'));
|
||||
const filteredCidr = exclude([...cidr, ...INCLUDE_CIDRS], EXCLUDE_CIDRS, true);
|
||||
|
||||
// Can not use SHARED_DESCRIPTION here as different license
|
||||
const description = [
|
||||
|
||||
@ -4,6 +4,8 @@ import path from 'path';
|
||||
import fsp from 'fs/promises';
|
||||
import { task } from './lib/trace-runner';
|
||||
|
||||
import { exclude } from 'fast-cidr-tools';
|
||||
|
||||
const RESERVED_IPV4_CIDR = [
|
||||
'0.0.0.0/8',
|
||||
'10.0.0.0/8',
|
||||
@ -22,12 +24,8 @@ const RESERVED_IPV4_CIDR = [
|
||||
'240.0.0.0/4'
|
||||
];
|
||||
|
||||
// preload the module
|
||||
import('cidr-tools-wasm');
|
||||
|
||||
export const buildInternalReverseChnCIDR = task(import.meta.path, async () => {
|
||||
const [{ exclude }, cidr] = await Promise.all([
|
||||
import('cidr-tools-wasm'),
|
||||
const [cidr] = await Promise.all([
|
||||
processLineFromReadline(await fetchRemoteTextAndCreateReadlineInterface('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt')),
|
||||
fsp.mkdir(path.resolve(import.meta.dir, '../List/internal'), { recursive: true })
|
||||
]);
|
||||
|
||||
@ -76,14 +76,12 @@ export const downloadPreviousBuild = task(import.meta.path, async () => {
|
||||
const targetPath = path.join(import.meta.dir, '..', relativeEntryPath);
|
||||
await fsp.mkdir(path.dirname(targetPath), { recursive: true });
|
||||
|
||||
const targetFile = Bun.file(targetPath);
|
||||
const targetFileSink = targetFile.writer();
|
||||
const targetFileSink = Bun.file(targetPath).writer();
|
||||
const onData = (chunk: Buffer) => targetFileSink.write(chunk);
|
||||
|
||||
// I don't know, but for some reason it is impossible to consume entry with AsyncIterator
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
entry.on('data', (chunk) => {
|
||||
targetFileSink.write(chunk);
|
||||
});
|
||||
entry.on('data', onData);
|
||||
entry.on('end', resolve);
|
||||
entry.on('error', reject);
|
||||
});
|
||||
|
||||
@ -19,8 +19,8 @@
|
||||
"async-retry": "^1.3.3",
|
||||
"async-sema": "^3.1.1",
|
||||
"ci-info": "^4.0.0",
|
||||
"cidr-tools-wasm": "^0.0.14",
|
||||
"eslint": "^8.54.0",
|
||||
"fast-cidr-tools": "^0.1.0",
|
||||
"gorhill-publicsuffixlist": "github:gorhill/publicsuffixlist.js",
|
||||
"mnemonist": "^0.39.5",
|
||||
"path-scurry": "^1.10.1",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user