fix: dns validation + duplicated fqdns
This commit is contained in:
parent
73d0948734
commit
3ae9501814
@ -245,9 +245,10 @@ class General extends Component
|
||||
$domains = $domains->unique();
|
||||
foreach ($domains as $domain) {
|
||||
if (!validate_dns_entry($domain, $this->application->destination->server)) {
|
||||
$showToaster && $this->dispatch('error', "Validating DNS settings for: $domain failed.<br>Make sure you have added the DNS records correctly.<br><br>Check this <a target='_blank' class='underline' href='https://coolify.io/docs/dns-settings'>documentation</a> for further help.");
|
||||
$showToaster && $this->dispatch('error', "Validating DNS ($domain) failed.","Make sure you have added the DNS records correctly.<br><br>Check this <a target='_blank' class='text-white underline' href='https://coolify.io/docs/dns-settings'>documentation</a> for further help.");
|
||||
}
|
||||
}
|
||||
check_fqdn_usage($this->application);
|
||||
$this->application->fqdn = $domains->implode(',');
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ class Application extends Component
|
||||
public function submit()
|
||||
{
|
||||
try {
|
||||
check_fqdn_usage($this->application);
|
||||
$this->validate();
|
||||
$this->application->save();
|
||||
updateCompose($this->application);
|
||||
|
@ -1116,4 +1116,12 @@ class Application extends BaseModel
|
||||
$this->save();
|
||||
return $customLabels;
|
||||
}
|
||||
public function fqdns(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn () => is_null($this->fqdn)
|
||||
? []
|
||||
: explode(',', $this->fqdn),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ class ServiceApplication extends BaseModel
|
||||
get: fn () => is_null($this->fqdn)
|
||||
? []
|
||||
: explode(',', $this->fqdn),
|
||||
|
||||
);
|
||||
}
|
||||
public function getFilesFromServer(bool $isInit = false)
|
||||
|
@ -1660,3 +1660,33 @@ function ip_match($ip, $cidrs, &$match = null)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function check_fqdn_usage(ServiceApplication|Application $own_resource)
|
||||
{
|
||||
$domains = collect($own_resource->fqdns)->map(function ($domain) {
|
||||
return Url::fromString($domain)->getHost();
|
||||
});
|
||||
$apps = Application::all();
|
||||
foreach ($apps as $app) {
|
||||
$list_of_domains = collect(explode(',', $app->fqdn))->filter(fn ($fqdn) => $fqdn !== '');
|
||||
foreach ($list_of_domains as $domain) {
|
||||
$naked_domain = Url::fromString($domain)->getHost();
|
||||
if ($domains->contains($naked_domain)) {
|
||||
if ($app->uuid !== $own_resource->uuid ) {
|
||||
throw new \RuntimeException("Domain $naked_domain is already in use by another resource.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$apps = ServiceApplication::all();
|
||||
foreach ($apps as $app) {
|
||||
$list_of_domains = collect(explode(',', $app->fqdn))->filter(fn ($fqdn) => $fqdn !== '');
|
||||
foreach ($list_of_domains as $domain) {
|
||||
$naked_domain = Url::fromString($domain)->getHost();
|
||||
if ($domains->contains($naked_domain)) {
|
||||
if ($app->uuid !== $own_resource->uuid) {
|
||||
throw new \RuntimeException("Domain $naked_domain is already in use by another resource.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -369,14 +369,14 @@ window.customToastHTML = `
|
||||
}, 5);
|
||||
}, 4000);"
|
||||
@mouseover="toastHovered=true" @mouseout="toastHovered=false"
|
||||
class="absolute w-full duration-300 ease-out select-none sm:max-w-xs"
|
||||
class="absolute w-full duration-200 ease-out select-none sm:max-w-xs"
|
||||
:class="{ 'toast-no-description': !toast.description }">
|
||||
<span
|
||||
class="relative flex flex-col items-start shadow-[0_5px_15px_-3px_rgb(0_0_0_/_0.08)] w-full transition-all duration-300 ease-out bg-coolgray-200 border border-coolgray-100 sm:rounded-md sm:max-w-xs group"
|
||||
class="relative flex flex-col items-start shadow-[0_5px_15px_-3px_rgb(0_0_0_/_0.08)] w-full transition-all duration-200 ease-out bg-coolgray-200 border border-coolgray-100 sm:rounded-md sm:max-w-xs group"
|
||||
:class="{ 'p-4': !toast.html, 'p-0': toast.html }">
|
||||
<template x-if="!toast.html">
|
||||
<div class="relative">
|
||||
<div class="flex items-center"
|
||||
<div class="flex items-start"
|
||||
:class="{ 'text-green-500': toast.type=='success', 'text-blue-500': toast.type=='info', 'text-orange-400': toast.type=='warning', 'text-red-500': toast.type=='danger', 'text-gray-800': toast.type=='default' }">
|
||||
|
||||
<svg x-show="toast.type=='success'" class="w-[18px] h-[18px] mr-1.5 -ml-1"
|
||||
@ -403,12 +403,12 @@ window.customToastHTML = `
|
||||
d="M2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12ZM11.9996 7C12.5519 7 12.9996 7.44772 12.9996 8V12C12.9996 12.5523 12.5519 13 11.9996 13C11.4474 13 10.9996 12.5523 10.9996 12V8C10.9996 7.44772 11.4474 7 11.9996 7ZM12.001 14.99C11.4488 14.9892 11.0004 15.4363 10.9997 15.9886L10.9996 15.9986C10.9989 16.5509 11.446 16.9992 11.9982 17C12.5505 17.0008 12.9989 16.5537 12.9996 16.0014L12.9996 15.9914C13.0004 15.4391 12.5533 14.9908 12.001 14.99Z"
|
||||
fill="currentColor"></path>
|
||||
</svg>
|
||||
<p class="font-medium leading-none text-neutral-200"
|
||||
<p class="font-bold leading-2 text-neutral-200"
|
||||
x-html="toast.message">
|
||||
</p>
|
||||
</div>
|
||||
<p x-show="toast.description" :class="{ 'pl-5': toast.type!='default' }"
|
||||
class="mt-1.5 text-xs leading-none opacity-70" x-html="toast.description"></p>
|
||||
class="mt-1.5 text-xs leading-2 opacity-90" x-html="toast.description"></p>
|
||||
</div>
|
||||
</template>
|
||||
<template x-if="toast.html">
|
||||
|
Loading…
x
Reference in New Issue
Block a user