Skip to content

Instantly share code, notes, and snippets.

@AndyIsHereBoi
Last active September 3, 2024 16:59
Show Gist options
  • Save AndyIsHereBoi/eed5853873e8296a249f7136fc8ad040 to your computer and use it in GitHub Desktop.
Save AndyIsHereBoi/eed5853873e8296a249f7136fc8ad040 to your computer and use it in GitHub Desktop.
Scans Discord for its voice servers.
import dns from 'node:dns';
import fetch from 'node-fetch';
import regions from "./regions.json" assert { type: "json" };
import fs from 'node:fs';
const IPINFO_API_KEY = "key here";
const loops = 15000;
var regionscomplete = {};
async function processDomains() {
for (const region of regions) {
for (let i = 0; i < loops; i++) {
const domain = `${region}${i + 1}.discord.gg`;
console.log(domain)
try {
const address = await resolveDNS(domain);
await resolveData(address, domain, region);
} catch (error) {
// console.error(`Error resolving ${domain}:`, error);
}
}
}
}
function resolveDNS(domain) {
return new Promise((resolve, reject) => {
dns.lookup(domain, (err, address) => {
if (err) {
reject(err);
} else {
resolve(address);
}
});
});
};
async function resolveData(ip, dnsDomain, region) {
console.log('getting ip info');
try {
const response = await fetch(`https://ipinfo.io/${ip}/json?token=${IPINFO_API_KEY}`);
const responseData = await response.json();
const completeObject = {
"ip": ip,
"dns": dnsDomain,
"city": responseData.city,
"region": responseData.region,
"country": responseData.country,
"org": responseData.org
};
console.log(completeObject);
pushRegionData(region, completeObject)
} catch (error) {
console.error(`Error fetching IP info for ${dnsDomain}:`, error);
};
};
function pushRegionData(region, data) {
if (!regionscomplete.hasOwnProperty(region)) {
regionscomplete[region] = []; // initialize an empty array for the region if it doesn't exist already
};
regionscomplete[region].push(data); // add the resolved data to the region array
};
processDomains();
process.on('exit', beforeProcessExit);
function beforeProcessExit() {
const jsonContent = JSON.stringify(regionscomplete);
fs.writeFileSync('./output.json', jsonContent, (err) => {
if (err) {
console.error('Error writing JSON file:', err);
} else {
console.log('JSON file saved successfully!');
}
});
console.log("Before process exit");
console.log(regionscomplete);
// Write the JSON string to a file
};
{
"name": "discord-voice-servers",
"version": "0.0.1",
"description": "Resolve all discord voice server IPS",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "AndyIsHereBoi",
"license": "ISC",
"dependencies": {
"axios": "^1.6.5",
"node-fetch": "^3.3.2"
}
}
[
"atlanta",
"brazil",
"bucharest",
"buenos-aires",
"dammam",
"dubai",
"finland",
"frankfurt",
"hongkong",
"india",
"jakarta",
"japan",
"madrid",
"milan",
"montreal",
"newark",
"oregon",
"rotterdam",
"russia",
"santa-clara",
"santiago",
"seattle",
"singapore",
"south-korea",
"southafrica",
"st-pete",
"stage-scale",
"stockholm",
"sydney",
"tel-aviv",
"us-central",
"us-east",
"us-south",
"us-west",
"warsaw"
]
@bhdrozgn
Copy link

bhdrozgn commented Sep 2, 2024

Thank you. I found that there are other regions other than regions in regions.json:

"atlanta", "brazil", "bucharest", "buenos-aires", "dammam", "dubai", 
"finland", "frankfurt", "hongkong", "india", "jakarta", "japan", 
"madrid", "milan", "montreal", "newark", "oregon", "rotterdam", 
"russia", "santa-clara", "santiago", "seattle", "singapore", 
"south-korea", "southafrica", "st-pete", "stage-scale", "stockholm", 
"sydney", "tel-aviv", "us-central", "us-east", "us-south", "us-west", "warsaw"

@AndyIsHereBoi
Copy link
Author

ill scan for updates ones later, ganna take exponentially longer with how many it is lol

@AndyIsHereBoi
Copy link
Author

@bhdrozgn i updated the regions, will do a scan now. will take a few hours probabyl

@bhdrozgn
Copy link

bhdrozgn commented Sep 3, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment