Browse Source

Chore: debug telegram cidr update

SukkaW 3 years ago
parent
commit
e93a801bf7
1 changed files with 5 additions and 0 deletions
  1. 5 0
      Build/build-telegram-cidr.js

+ 5 - 0
Build/build-telegram-cidr.js

@@ -13,12 +13,17 @@ const { isIPv4, isIPv6 } = require('net');
     .split('\n')
     .split('\n')
     .filter(line => line.trim() !== '');
     .filter(line => line.trim() !== '');
 
 
+  if (res.length === 0) {
+    throw new Error('Failed to fetch data!');
+  }
+
   await fs.promises.writeFile(
   await fs.promises.writeFile(
     path.resolve(__dirname, '../List/ip/telegram.conf'),
     path.resolve(__dirname, '../List/ip/telegram.conf'),
     '# Telegram CIDR (https://core.telegram.org/resources/cidr.txt)' + '\n' +
     '# Telegram CIDR (https://core.telegram.org/resources/cidr.txt)' + '\n' +
     '# Last Updated: ' + lastModified.toISOString() + '\n' +
     '# Last Updated: ' + lastModified.toISOString() + '\n' +
     res.map(ip => {
     res.map(ip => {
       const [subnet] = ip.split('/');
       const [subnet] = ip.split('/');
+      console.log('  - ' + ip + ': ' + subnet);
       if (isIPv4(subnet)) {
       if (isIPv4(subnet)) {
         return `IP-CIDR,${ip},no-resolve`;
         return `IP-CIDR,${ip},no-resolve`;
       }
       }