Lookup both A and AAAA records for node FQDNs (#4398)

Allows IPv6 addresses to be used, instead of IPv4 being required.

Closes <https://github.com/pterodactyl/panel/issues/4011>
This commit is contained in:
Matthew Penner 2022-10-04 20:03:52 -06:00 committed by GitHub
parent 815e1e4c4d
commit 7b91c38396
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 3 deletions

View file

@ -59,7 +59,13 @@ class MakeNodeCommand extends Command
$data['description'] = $this->option('description') ?? $this->ask('Enter a description to identify the node');
$data['location_id'] = $this->option('locationId') ?? $this->ask('Enter a valid location id');
$data['fqdn'] = $this->option('fqdn') ?? $this->ask('Enter a domain name (e.g node.example.com) to be used for connecting to the daemon. An IP address may only be used if you are not using SSL for this node');
if (!filter_var(gethostbyname($data['fqdn']), FILTER_VALIDATE_IP)) {
// Note, this function will also resolve CNAMEs for us automatically,
// there is no need to manually resolve them here.
//
// Using @ as workaround to fix https://bugs.php.net/bug.php?id=73149
$records = @dns_get_record($data['fqdn'], DNS_A + DNS_AAAA);
if (empty($records)) {
$this->error('The FQDN or IP address provided does not resolve to a valid IP address.');
return;