From 9a899deeb8e94fbdc721b9835bd58e3eecea70aa Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 7 Feb 2024 14:59:33 +0100 Subject: [PATCH] Fix DNS validation and error handling --- app/Livewire/Project/Application/General.php | 8 +++++--- bootstrap/helpers/shared.php | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index 0f6d61957..c11dbfe4b 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -243,9 +243,11 @@ class General extends Component return str($domain)->trim()->lower(); }); $domains = $domains->unique(); - foreach ($domains as $domain) { - if (!validate_dns_entry($domain, $this->application->destination->server)) { - $showToaster && $this->dispatch('error', "Validating DNS ($domain) failed.","Make sure you have added the DNS records correctly.

Check this documentation for further help."); + if ($this->application->additional_servers->count() === 0) { + foreach ($domains as $domain) { + if (!validate_dns_entry($domain, $this->application->destination->server)) { + $showToaster && $this->dispatch('error', "Validating DNS ($domain) failed.","Make sure you have added the DNS records correctly.

Check this documentation for further help."); + } } } check_fqdn_usage($this->application); diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index 23ee3fa06..7ffc6a72c 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -104,7 +104,7 @@ function handleError(?Throwable $error = null, ?Livewire\Component $livewire = n ray($error); if ($error instanceof TooManyRequestsException) { if (isset($livewire)) { - return $livewire->dispatch('error', "Too many requests.","Please try again in {$error->secondsUntilAvailable} seconds."); + return $livewire->dispatch('error', "Too many requests.", "Please try again in {$error->secondsUntilAvailable} seconds."); } return "Too many requests. Please try again in {$error->secondsUntilAvailable} seconds."; } @@ -1690,7 +1690,7 @@ function check_fqdn_usage(ServiceApplication|Application $own_resource) $naked_domain = str($domain)->replace('http://', '')->replace('https://', '')->value(); if ($domains->contains($naked_domain)) { if ($app->uuid !== $own_resource->uuid) { - throw new \RuntimeException("Domain $naked_domain is already in use by another resource."); + throw new \RuntimeException("Domain $naked_domain is already in use by another resource:
{$app->name}."); } } }