Browse Source

Update CN CIDR

SukkaW 4 years ago
parent
commit
b1f24f8a6d
3 changed files with 242 additions and 592 deletions
  1. 7 27
      Build/build-cidr.js
  2. 234 564
      List/ip/china_ip.conf
  3. 1 1
      Modules/sukka_url_rewrite.sgmodule

+ 7 - 27
Build/build-cidr.js

@@ -13,37 +13,17 @@ try {
 }
 
 (async () => {
-  const cidr = (await get('raw.githubusercontent.com', '/tmplink/IPDB/main/ipv4/cidr/CN.txt')).split('\n');
+  const cidr = (await get('raw.githubusercontent.com', 'misakaio/chnroutes2/master/chnroutes.txt')).split('\n');
 
-  let FILTER_FLAG = false;
-  const filteredCidr = cidr.filter(Boolean).filter((ip, index) => {
-    if (FILTER_FLAG) return false;
-
-    const prev = cidr[index - 1];
-    const next = cidr[index + 1];
-    const prevA = Number(prev?.split('.')[0]);
-    const nextA = Number(next?.split('.')[0]);
-
-    if (
-      prevA >= 223 // MCAST-TEST-NET
-      && nextA < 10
-      && prevA > nextA
-    ) {
-      FILTER_FLAG = true;
-      return false;
+  const filteredCidr = cidr.filter(line => {
+    if (line) {
+      return !line.startsWith('#')
     }
 
-    return true;
-  });
-
-  const mergedCidr = cidrTools.merge(filteredCidr);
-
-  if (mergedCidr.length < 4500) {
-    console.log(`Merged routes (which is ${mergedCidr.length}) is less than 5000 routes, which can't be right. Aborted`);
-    process.exit(1);
-  }
+    return false;
+  })
 
-  return fsPromises.writeFile(pathResolve(__dirname, '../List/ip/china_ip.conf'), makeCidrList(mergedCidr), { encoding: 'utf-8' });
+  return fsPromises.writeFile(pathResolve(__dirname, '../List/ip/china_ip.conf'), makeCidrList(filteredCidr), { encoding: 'utf-8' });
 })();
 
 function makeCidrList(cidr) {

File diff suppressed because it is too large
+ 234 - 564
List/ip/china_ip.conf


+ 1 - 1
Modules/sukka_url_rewrite.sgmodule

@@ -16,7 +16,7 @@
 ^http://(www.)?yhd\.com https://yhd.com/ 302
 # Redirect False to True
 # >> IGN China to IGN Global
-^https?://(www.)?ign\.xn--fiqs8s/ http://cn.ign.com/ccpref/us 302
+^https?://(www.)?ign\.xn--fiqs8s/ https://cn.ign.com/ccpref/us 302
 # >> Fake Website Made By Makeding
 ^https?://(www.)?abbyychina\.com/ http://www.abbyy.cn/ 302
 ^https?://(www.)?bartender\.cc/ https://cn.seagullscientific.com 302

Some files were not shown because too many files changed in this diff