Chore: debug telegram cidr update

This commit is contained in:
SukkaW 2022-11-03 15:34:33 +08:00
parent cd5525b560
commit e93a801bf7

View File

@ -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`;
} }