mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
Update China IPv4
This commit is contained in:
parent
70df7d33c6
commit
8e2644ac6c
@ -2,32 +2,42 @@ import { fetchRemoteTextByLine } from './lib/fetch-text-by-line';
|
|||||||
import { processLineFromReadline } from './lib/process-line';
|
import { processLineFromReadline } from './lib/process-line';
|
||||||
import { task } from './trace';
|
import { task } from './trace';
|
||||||
|
|
||||||
import { contains, exclude } from 'fast-cidr-tools';
|
import { contains as containsCidr, exclude as excludeCidr } from 'fast-cidr-tools';
|
||||||
import { createMemoizedPromise } from './lib/memo-promise';
|
import { createMemoizedPromise } from './lib/memo-promise';
|
||||||
import { CN_CIDR_NOT_INCLUDED_IN_CHNROUTE, NON_CN_CIDR_INCLUDED_IN_CHNROUTE } from './constants/cidr';
|
import { CN_CIDR_MISSING_IN_CHNROUTE, NON_CN_CIDR_INCLUDED_IN_CHNROUTE } from './constants/cidr';
|
||||||
import { appendArrayInPlace } from './lib/append-array-in-place';
|
import { appendArrayInPlace } from './lib/append-array-in-place';
|
||||||
import { IPListOutput } from './lib/create-file';
|
import { IPListOutput } from './lib/create-file';
|
||||||
import { cachedOnlyFail } from './lib/fs-memo';
|
import { cachedOnlyFail } from './lib/fs-memo';
|
||||||
|
|
||||||
const PROBE_CHN_CIDR = [
|
const PROBE_CHN_CIDR_V4 = [
|
||||||
// NetEase Hangzhou
|
// NetEase Hangzhou
|
||||||
'223.252.196.38'
|
'223.252.196.38',
|
||||||
|
// Aliyun ShenZhen
|
||||||
|
'120.78.92.171'
|
||||||
];
|
];
|
||||||
|
|
||||||
export const getChnCidrPromise = createMemoizedPromise(cachedOnlyFail(
|
export const getChnCidrPromise = createMemoizedPromise(cachedOnlyFail(
|
||||||
async function getChnCidr() {
|
async function getChnCidr() {
|
||||||
const [cidr4, cidr6] = await Promise.all([
|
const [_cidr4, cidr6] = await Promise.all([
|
||||||
fetchRemoteTextByLine('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt').then(processLineFromReadline),
|
fetchRemoteTextByLine('https://raw.githubusercontent.com/misakaio/chnroutes2/master/chnroutes.txt').then(processLineFromReadline),
|
||||||
fetchRemoteTextByLine('https://gaoyifan.github.io/china-operator-ip/china6.txt').then(processLineFromReadline)
|
fetchRemoteTextByLine('https://gaoyifan.github.io/china-operator-ip/china6.txt').then(processLineFromReadline)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
appendArrayInPlace(cidr4, CN_CIDR_NOT_INCLUDED_IN_CHNROUTE);
|
const cidr4 = excludeCidr(
|
||||||
|
appendArrayInPlace(_cidr4, CN_CIDR_MISSING_IN_CHNROUTE),
|
||||||
|
NON_CN_CIDR_INCLUDED_IN_CHNROUTE,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
if (!contains(cidr4, PROBE_CHN_CIDR)) {
|
for (const probeIp of PROBE_CHN_CIDR_V4) {
|
||||||
throw new TypeError('chnroutes missing probe IP');
|
if (!containsCidr(cidr4, PROBE_CHN_CIDR_V4)) {
|
||||||
|
const err = new TypeError('chnroutes missing probe IP');
|
||||||
|
err.cause = probeIp;
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return [exclude(cidr4, NON_CN_CIDR_INCLUDED_IN_CHNROUTE, true), cidr6] as const;
|
return [cidr4, cidr6] as const;
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
serializer: JSON.stringify,
|
serializer: JSON.stringify,
|
||||||
|
|||||||
@ -25,7 +25,8 @@ export const NON_CN_CIDR_INCLUDED_IN_CHNROUTE = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
// https://github.com/misakaio/chnroutes2/issues/46
|
// https://github.com/misakaio/chnroutes2/issues/46
|
||||||
export const CN_CIDR_NOT_INCLUDED_IN_CHNROUTE = [
|
// https://github.com/misakaio/chnroutes2/issues/48
|
||||||
|
export const CN_CIDR_MISSING_IN_CHNROUTE = [
|
||||||
// Baidu Public DNS
|
// Baidu Public DNS
|
||||||
'180.76.76.0/24',
|
'180.76.76.0/24',
|
||||||
// Ali Public DNS
|
// Ali Public DNS
|
||||||
@ -44,19 +45,25 @@ export const CN_CIDR_NOT_INCLUDED_IN_CHNROUTE = [
|
|||||||
'101.198.198.0/24',
|
'101.198.198.0/24',
|
||||||
'101.198.199.0/24',
|
'101.198.199.0/24',
|
||||||
|
|
||||||
'211.99.96.0/19', // wy.com.cn
|
// Aliyun Shenzhen
|
||||||
|
'120.78.0.0/16',
|
||||||
|
|
||||||
'40.72.0.0/15', // AS58593, Azure China, Shanghai
|
// wy.com.cn
|
||||||
'42.159.0.0/16', // AS58593, Azure China, Shanghai
|
'211.99.96.0/19',
|
||||||
'52.130.0.0/17', // AS58593, Azure China, Shanghai
|
|
||||||
'52.131.0.0/16', // AS58593, Azure China, Beijing
|
// AS58593, Azure China
|
||||||
'103.9.8.0/22', // AS58593, Azure China, Backbone
|
'40.72.0.0/15', // Shanghai
|
||||||
'139.217.0.0/16', // AS58593, Azure China, Shanghai
|
'42.159.0.0/16', // Shanghai
|
||||||
'139.219.0.0/16', // AS58593, Azure China, Shanghai
|
'52.130.0.0/17', // Shanghai
|
||||||
'143.64.0.0/16', // AS58593, Azure China, Beijing
|
'52.131.0.0/16', // Beijing
|
||||||
'159.27.0.0/16', // AS58593, Azure China, Beijing
|
'103.9.8.0/22', // Backbone
|
||||||
'163.228.0.0/16', // AS58593, Azure China, Beijing
|
'139.217.0.0/16', // Shanghai
|
||||||
|
'139.219.0.0/16', // Shanghai
|
||||||
|
'143.64.0.0/16', // Beijing
|
||||||
|
'159.27.0.0/16', // Beijing
|
||||||
|
'163.228.0.0/16', // Beijing
|
||||||
|
|
||||||
// NetEase
|
// NetEase
|
||||||
|
'223.252.194.0/24',
|
||||||
'223.252.196.0/24'
|
'223.252.196.0/24'
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user