From 3c43f3aa18b3b11952609bac6a5bd6c16f7ce886 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Thu, 28 Mar 2024 17:01:09 -0400 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20need=20this=20anymore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Requests/Admin/Node/NodeFormRequest.php | 6 +- app/Rules/Fqdn.php | 80 ------------------- 2 files changed, 1 insertion(+), 85 deletions(-) delete mode 100644 app/Rules/Fqdn.php diff --git a/app/Http/Requests/Admin/Node/NodeFormRequest.php b/app/Http/Requests/Admin/Node/NodeFormRequest.php index c55e2d1b0..9fc27e99b 100644 --- a/app/Http/Requests/Admin/Node/NodeFormRequest.php +++ b/app/Http/Requests/Admin/Node/NodeFormRequest.php @@ -2,7 +2,6 @@ namespace App\Http\Requests\Admin\Node; -use App\Rules\Fqdn; use App\Models\Node; use App\Http\Requests\Admin\AdminFormRequest; @@ -17,9 +16,6 @@ class NodeFormRequest extends AdminFormRequest return Node::getRulesForUpdate($this->route()->parameter('node')); } - $data = Node::getRules(); - $data['fqdn'][] = Fqdn::make('scheme'); - - return $data; + return Node::getRules(); } } diff --git a/app/Rules/Fqdn.php b/app/Rules/Fqdn.php deleted file mode 100644 index e6b0d874f..000000000 --- a/app/Rules/Fqdn.php +++ /dev/null @@ -1,80 +0,0 @@ -data = $data; - - return $this; - } - - /** - * Validates that the value provided resolves to an IP address. If a scheme is - * specified when this rule is created additional checks will be applied. - * - * @param string $attribute - * @param mixed $value - */ - public function passes($attribute, $value): bool - { - if (filter_var($value, FILTER_VALIDATE_IP)) { - // Check if the scheme is set to HTTPS. - // - // Unless someone owns their IP blocks and decides to pay who knows how much for a - // custom SSL cert, IPs will not be able to use HTTPS. This should prevent most - // home users from making this mistake and wondering why their node is not working. - if ($this->schemeField && Arr::get($this->data, $this->schemeField) === 'https') { - $this->message = 'The :attribute must not be an IP address when HTTPS is enabled.'; - - return false; - } - - return true; - } - - // Lookup A and AAAA DNS records for the FQDN. Note, this function will also resolve CNAMEs - // for us automatically, there is no need to manually resolve them here. - // - // The error suppression is intentional, see https://bugs.php.net/bug.php?id=73149 - $records = @dns_get_record($value, DNS_A + DNS_AAAA); - // If no records were returned fall back to trying to resolve the value using the hosts DNS - // resolution. This will not work for IPv6 which is why we prefer to use `dns_get_record` - // first. - if (!empty($records) || filter_var(gethostbyname($value), FILTER_VALIDATE_IP)) { - return true; - } - - $this->message = 'The :attribute could not be resolved to a valid IP address.'; - - return false; - } - - public function message(): string - { - return $this->message; - } - - /** - * Returns a new instance of the rule with a defined scheme set. - */ - public static function make(string $schemeField = null): self - { - return tap(new self(), function ($fqdn) use ($schemeField) { - $fqdn->schemeField = $schemeField; - }); - } -}