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

@ -34,8 +34,12 @@ class NodeFormRequest extends AdminFormRequest
public function withValidator($validator)
{
$validator->after(function ($validator) {
// Check that the FQDN is a valid IP address.
if (!filter_var(gethostbyname($this->input('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($this->input('fqdn'), DNS_A + DNS_AAAA);
if (empty($records)) {
$validator->errors()->add('fqdn', trans('admin/node.validation.fqdn_not_resolvable'));
}