diff --git a/Build/build-telegram-cidr.js b/Build/build-telegram-cidr.js index d884a2ba2..436a249c1 100644 --- a/Build/build-telegram-cidr.js +++ b/Build/build-telegram-cidr.js @@ -1,6 +1,7 @@ const { fetch } = require('undici'); const fs = require('fs'); const path = require('path'); +const { isIPv4, isIPv6 } = require('net'); (async () => { const resp = await fetch('https://core.telegram.org/resources/cidr.txt'); @@ -15,9 +16,14 @@ const path = require('path'); '# Telegram CIDR (https://core.telegram.org/resources/cidr.txt)' + '\n' + '# Last Updated: ' + lastModified.toISOString() + '\n' + res.map(ip => { - return ip.includes(':') - ? `IP-CIDR6,${ip},no-resolve` - : `IP-CIDR,${ip},no-resolve`; + const [subnet, range] = ip.split('/'); + if (isIPv4(subnet)) { + return `IP-CIDR,${ip},no-resolve`; + } + if (isIPv6(subnet)) { + return `IP-CIDR6,${ip},no-resolve`; + } + return ''; }).join('\n') + '\n', 'utf-8' ); diff --git a/index.html b/index.html index 3f6f1b47e..35119fe9e 100644 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@

Sukka Surge Ruleset Server

Made by Sukka | Source @ GitHub | Licensed under AGPL-3.0

-

Last Updated: 2022-04-28T04:59:04.484Z

+

Last Updated: 2022-04-28T05:01:34.972Z