Skip to content

Commit

Permalink
Add bin/discover-dns.php script
Browse files Browse the repository at this point in the history
  • Loading branch information
carlbennett committed Mar 14, 2021
1 parent 6011400 commit 06fd2a4
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions bin/discover-dns.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env php
<?php /* vim: set colorcolumn=: */
/**
* @project bnetdocs-web <https://github.com/BNETDocs/bnetdocs-web/>
*
* Dec 5 2020 - Generate strings that might resolve, for Blizzard Classic Battle.net servers and other interesting servers.
*/
declare(strict_types=1);

$regions = [ 'account', 'apac', 'api', 'bot', 'cn', 'emea', 'eu', 'eur', 'forever', 'kor', 'kr', 'na', 'par', 'use', 'usw' ];
$envs = [ 'live', 'ptr' ];
$domains = [ 'classic.blizzard.com', 'blizzard.com' ];

$patterns = [
'connect.{domain}',
'connect-{env}.{domain}',
'connect-{region}.{domain}',
'connect-{env}-{region}-[ab].{domain}',
];

$names = [];

foreach ($patterns as $pattern)
{
foreach ($domains as $domain)
{
foreach ($regions as $region)
{
foreach ($envs as $env)
{
$name = $pattern;

$name = str_replace('{domain}', $domain, $name);
$name = str_replace('{region}', $region, $name);
$name = str_replace('{env}', $env, $name);

if (stripos($name, '[ab]') !== false)
{
$names[str_ireplace('[ab]', 'a', $name)] = true;
$names[str_ireplace('[ab]', 'b', $name)] = true;
$name = str_ireplace('-[ab]', '', $name);
}

$names[$name] = true;
}
}
}
}

$names = array_keys($names);
sort($names);

echo json_encode($names, JSON_PRETTY_PRINT) . PHP_EOL;

0 comments on commit 06fd2a4

Please sign in to comment.