mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 01:00:34 +08:00
Feat: add more way to fetch Telegram Backup IP
This commit is contained in:
parent
c4aa6afad3
commit
b0b2026564
@ -15,8 +15,7 @@ export const getTelegramCIDRPromise = once(async () => {
|
|||||||
const date = lastModified ? new Date(lastModified) : new Date();
|
const date = lastModified ? new Date(lastModified) : new Date();
|
||||||
|
|
||||||
const ipcidr: string[] = [
|
const ipcidr: string[] = [
|
||||||
// Telegram secret backup CIDR, announced by AS62041
|
// Unused secret Telegram backup CIDR, announced by AS62041
|
||||||
// see also https://github.com/Telegram-FOSS-Team/Telegram-FOSS/blob/10da5406ed92d30c6add3b25d40b2b3b6995d873/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java#L1157
|
|
||||||
'95.161.64.0/20'
|
'95.161.64.0/20'
|
||||||
];
|
];
|
||||||
const ipcidr6: string[] = [];
|
const ipcidr6: string[] = [];
|
||||||
@ -32,6 +31,8 @@ export const getTelegramCIDRPromise = once(async () => {
|
|||||||
|
|
||||||
const backupIPs = new Set<string>();
|
const backupIPs = new Set<string>();
|
||||||
|
|
||||||
|
// https://github.com/tdlib/td/blob/master/td/telegram/ConfigManager.cpp
|
||||||
|
|
||||||
// Backup IP Source 1 (DoH)
|
// Backup IP Source 1 (DoH)
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
DNS2.DOHClient({
|
DNS2.DOHClient({
|
||||||
@ -43,19 +44,21 @@ export const getTelegramCIDRPromise = once(async () => {
|
|||||||
http: false
|
http: false
|
||||||
})
|
})
|
||||||
].map(async (client) => {
|
].map(async (client) => {
|
||||||
|
try {
|
||||||
// tapv3.stel.com was for testing server
|
// tapv3.stel.com was for testing server
|
||||||
const resp = await client('apv3.stel.com', 'TXT');
|
const resp = await client('apv3.stel.com', 'TXT');
|
||||||
const strings = resp.answers.map(i => i.data);
|
const strings = resp.answers.map(i => i.data);
|
||||||
|
|
||||||
const str = strings[0]!.length > strings[1]!.length
|
const str = strings[0]!.length > strings[1]!.length
|
||||||
? strings[0]! + strings[1]!
|
? strings[0]! + strings[1]!
|
||||||
: strings[1]! + strings[0]!;
|
: strings[1]! + strings[0]!;
|
||||||
|
|
||||||
const ips = getTelegramBackupIPFromBase64(str);
|
const ips = getTelegramBackupIPFromBase64(str);
|
||||||
ips.forEach(i => i && backupIPs.add(i.ip));
|
ips.forEach(i => i && backupIPs.add(i.ip));
|
||||||
|
} catch {}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// Backup IP Source 2: Firebase Storage
|
// Backup IP Source 2: Firebase Realtime Database
|
||||||
try {
|
try {
|
||||||
const text = await (await $$fetch('https://reserve-5a846.firebaseio.com/ipconfigv3.json')).json();
|
const text = await (await $$fetch('https://reserve-5a846.firebaseio.com/ipconfigv3.json')).json();
|
||||||
if (typeof text === 'string' && text.length === 344) {
|
if (typeof text === 'string' && text.length === 344) {
|
||||||
@ -80,6 +83,19 @@ export const getTelegramCIDRPromise = once(async () => {
|
|||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
|
// Backup IP Source 4: Google App Engine: https://dns-telegram.appspot.com https://dns-telegram.appspot.com/test
|
||||||
|
try {
|
||||||
|
const text = await (await $$fetch('https://dns-telegram.appspot.com')).text();
|
||||||
|
if (text.length === 344) {
|
||||||
|
const ips = getTelegramBackupIPFromBase64(text);
|
||||||
|
ips.forEach(i => i && backupIPs.add(i.ip));
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
// tcdnb.azureedge.net no longer works
|
||||||
|
|
||||||
|
console.log(`Found ${backupIPs.size} backup IPs:`, backupIPs);
|
||||||
|
|
||||||
ipcidr.push(...Array.from(backupIPs).map(i => i + '/32'));
|
ipcidr.push(...Array.from(backupIPs).map(i => i + '/32'));
|
||||||
|
|
||||||
return { date, ipcidr, ipcidr6 };
|
return { date, ipcidr, ipcidr6 };
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user