-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 82697f2
Showing
4 changed files
with
527 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import ping from 'ping'; | ||
import fetch from 'node-fetch'; | ||
import logUpdate from 'log-update'; | ||
import color from 'colors'; | ||
const url = 'https://steamcdn-a.akamaihd.net/apps/sdr/network_config.json'; | ||
|
||
(async function () { | ||
logUpdate(color.yellow('Fetching Servers')); | ||
const servers = await fetchServers(); | ||
logUpdate(color.green(`Fetched ${servers.length} Servers`)); | ||
logUpdate.done(); | ||
for (const server of servers) { | ||
logUpdate(color.green('Pinging'), color.bgWhite(server.name)); | ||
let ping = await pingServer(server.relays[ 0 ]); | ||
if (ping === 'unknown') { logUpdate(color.red(`${server.name} did not respond`)) } | ||
else { logUpdate(color.bold(`${server.name}`), color.italic(`${ping}ms`)); } | ||
logUpdate.done(); | ||
} | ||
})(); | ||
|
||
async function pingServer(ip) { | ||
return (await ping.promise.probe(ip)).time; | ||
} | ||
|
||
async function fetchServers() { | ||
const { pops } = await fetch(url).then(res => res.json()); | ||
const servers = []; | ||
Object.keys(pops).forEach(a => { | ||
const pop = pops[ a ]; | ||
if (!pop.relays || !pop.relays.length) | ||
return; | ||
servers.push({ | ||
name: pop.desc, | ||
relays: pop.relays.map(b => b.ipv4) | ||
}); | ||
}); | ||
return servers; | ||
} |
Oops, something went wrong.