fix: DNS check
This commit is contained in:
parent
9e009bebaa
commit
af0652f6b2
@ -64,6 +64,8 @@
|
|||||||
let autodeploy = application.settings.autodeploy;
|
let autodeploy = application.settings.autodeploy;
|
||||||
|
|
||||||
let nonWWWDomain = application.fqdn && getDomain(application.fqdn).replace(/^www\./, '');
|
let nonWWWDomain = application.fqdn && getDomain(application.fqdn).replace(/^www\./, '');
|
||||||
|
let isNonWWWDomainOK = false;
|
||||||
|
let isWWWDomainOK = false;
|
||||||
|
|
||||||
let wsgis = [
|
let wsgis = [
|
||||||
{
|
{
|
||||||
@ -143,6 +145,17 @@
|
|||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
if (error?.startsWith($t('application.dns_not_set_partial_error'))) {
|
if (error?.startsWith($t('application.dns_not_set_partial_error'))) {
|
||||||
forceSave = true;
|
forceSave = true;
|
||||||
|
if (dualCerts) {
|
||||||
|
isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
|
||||||
|
isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
|
||||||
|
} else {
|
||||||
|
const isWWW = getDomain(application.fqdn).includes('www.');
|
||||||
|
if (isWWW) {
|
||||||
|
isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
|
||||||
|
} else {
|
||||||
|
isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
} finally {
|
} finally {
|
||||||
@ -160,12 +173,17 @@
|
|||||||
application.baseBuildImage = event.detail.value;
|
application.baseBuildImage = event.detail.value;
|
||||||
await handleSubmit();
|
await handleSubmit();
|
||||||
}
|
}
|
||||||
async function isDNSValid(domain) {
|
|
||||||
|
async function isDNSValid(domain, isWWW) {
|
||||||
try {
|
try {
|
||||||
await get(`/applications/${id}/check.json?domain=${domain}`);
|
await get(`/applications/${id}/check.json?domain=${domain}`);
|
||||||
toast.push('Domain is valid in DNS.');
|
toast.push('DNS configuration is valid.');
|
||||||
|
isWWW ? (isWWWDomainOK = true) : (isNonWWWDomainOK = true);
|
||||||
|
return true;
|
||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
return errorNotification(error);
|
errorNotification(error);
|
||||||
|
isWWW ? (isWWWDomainOK = false) : (isNonWWWDomainOK = false);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -412,18 +430,36 @@
|
|||||||
placeholder="eg: https://coollabs.io"
|
placeholder="eg: https://coollabs.io"
|
||||||
/>
|
/>
|
||||||
{#if forceSave}
|
{#if forceSave}
|
||||||
<div class="pt-4">
|
<div class="flex-col space-y-2 pt-4 text-center">
|
||||||
|
{#if isNonWWWDomainOK}
|
||||||
<button
|
<button
|
||||||
class="bg-coollabs hover:bg-coollabs-100"
|
class="bg-green-600 hover:bg-green-500"
|
||||||
on:click|preventDefault={() => isDNSValid(getDomain(nonWWWDomain))}
|
on:click|preventDefault={() => isDNSValid(getDomain(nonWWWDomain), false)}
|
||||||
>Check {nonWWWDomain} DNS Record</button
|
>DNS settings for {nonWWWDomain} is OK, click to recheck.</button
|
||||||
>
|
>
|
||||||
|
{:else}
|
||||||
|
<button
|
||||||
|
class="bg-red-600 hover:bg-red-500"
|
||||||
|
on:click|preventDefault={() => isDNSValid(getDomain(nonWWWDomain), false)}
|
||||||
|
>DNS settings for {nonWWWDomain} is invalid, click to recheck.</button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
{#if dualCerts}
|
{#if dualCerts}
|
||||||
|
{#if isWWWDomainOK}
|
||||||
<button
|
<button
|
||||||
class="bg-coollabs hover:bg-coollabs-100"
|
class="bg-green-600 hover:bg-green-500"
|
||||||
on:click|preventDefault={() => isDNSValid(getDomain(`www.${nonWWWDomain}`))}
|
on:click|preventDefault={() =>
|
||||||
>Check www.{nonWWWDomain} DNS Record</button
|
isDNSValid(getDomain(`www.${nonWWWDomain}`), true)}
|
||||||
|
>DNS settings for www.{nonWWWDomain} is OK, click to recheck.</button
|
||||||
>
|
>
|
||||||
|
{:else}
|
||||||
|
<button
|
||||||
|
class="bg-red-600 hover:bg-red-500"
|
||||||
|
on:click|preventDefault={() =>
|
||||||
|
isDNSValid(getDomain(`www.${nonWWWDomain}`), true)}
|
||||||
|
>DNS settings for www.{nonWWWDomain} is invalid, click to recheck.</button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -44,7 +44,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (isDNSCheckEnabled && !dev && !forceSave) {
|
if (isDNSCheckEnabled && !forceSave) {
|
||||||
return await checkDomainsIsValidInDNS({ event, fqdn, dualCerts });
|
return await checkDomainsIsValidInDNS({ event, fqdn, dualCerts });
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
let forceSave = false;
|
let forceSave = false;
|
||||||
let fqdn = settings.fqdn;
|
let fqdn = settings.fqdn;
|
||||||
let nonWWWDomain = fqdn && getDomain(fqdn).replace(/^www\./, '');
|
let nonWWWDomain = fqdn && getDomain(fqdn).replace(/^www\./, '');
|
||||||
|
let isNonWWWDomainOK = false;
|
||||||
|
let isWWWDomainOK = false;
|
||||||
let isFqdnSet = !!settings.fqdn;
|
let isFqdnSet = !!settings.fqdn;
|
||||||
let loading = {
|
let loading = {
|
||||||
save: false,
|
save: false,
|
||||||
@ -71,6 +73,7 @@
|
|||||||
}
|
}
|
||||||
async function changeSettings(name) {
|
async function changeSettings(name) {
|
||||||
try {
|
try {
|
||||||
|
resetView();
|
||||||
if (name === 'isRegistrationEnabled') {
|
if (name === 'isRegistrationEnabled') {
|
||||||
isRegistrationEnabled = !isRegistrationEnabled;
|
isRegistrationEnabled = !isRegistrationEnabled;
|
||||||
}
|
}
|
||||||
@ -98,6 +101,7 @@
|
|||||||
try {
|
try {
|
||||||
loading.save = true;
|
loading.save = true;
|
||||||
nonWWWDomain = fqdn && getDomain(fqdn).replace(/^www\./, '');
|
nonWWWDomain = fqdn && getDomain(fqdn).replace(/^www\./, '');
|
||||||
|
|
||||||
if (fqdn !== settings.fqdn) {
|
if (fqdn !== settings.fqdn) {
|
||||||
await post(`/settings/check.json`, { fqdn, forceSave, dualCerts, isDNSCheckEnabled });
|
await post(`/settings/check.json`, { fqdn, forceSave, dualCerts, isDNSCheckEnabled });
|
||||||
await post(`/settings.json`, { fqdn });
|
await post(`/settings.json`, { fqdn });
|
||||||
@ -112,6 +116,17 @@
|
|||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
if (error?.startsWith($t('application.dns_not_set_partial_error'))) {
|
if (error?.startsWith($t('application.dns_not_set_partial_error'))) {
|
||||||
forceSave = true;
|
forceSave = true;
|
||||||
|
if (dualCerts) {
|
||||||
|
isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
|
||||||
|
isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
|
||||||
|
} else {
|
||||||
|
const isWWW = getDomain(settings.fqdn).includes('www.');
|
||||||
|
if (isWWW) {
|
||||||
|
isWWWDomainOK = await isDNSValid(getDomain(`www.${nonWWWDomain}`), true);
|
||||||
|
} else {
|
||||||
|
isNonWWWDomainOK = await isDNSValid(getDomain(nonWWWDomain), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
} finally {
|
} finally {
|
||||||
@ -126,14 +141,21 @@
|
|||||||
return errorNotification(error);
|
return errorNotification(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function isDNSValid(domain) {
|
async function isDNSValid(domain, isWWW) {
|
||||||
try {
|
try {
|
||||||
await get(`/settings/check.json?domain=${domain}`);
|
await get(`/settings/check.json?domain=${domain}`);
|
||||||
toast.push('Domain is valid in DNS.');
|
toast.push('DNS configuration is valid.');
|
||||||
|
isWWW ? (isWWWDomainOK = true) : (isNonWWWDomainOK = true);
|
||||||
|
return true;
|
||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
return errorNotification(error);
|
errorNotification(error);
|
||||||
|
isWWW ? (isWWWDomainOK = false) : (isNonWWWDomainOK = false);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function resetView() {
|
||||||
|
forceSave = false;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex space-x-1 p-6 font-bold">
|
<div class="flex space-x-1 p-6 font-bold">
|
||||||
@ -182,6 +204,7 @@
|
|||||||
bind:value={fqdn}
|
bind:value={fqdn}
|
||||||
readonly={!$session.isAdmin || isFqdnSet}
|
readonly={!$session.isAdmin || isFqdnSet}
|
||||||
disabled={!$session.isAdmin || isFqdnSet}
|
disabled={!$session.isAdmin || isFqdnSet}
|
||||||
|
on:input={resetView}
|
||||||
name="fqdn"
|
name="fqdn"
|
||||||
id="fqdn"
|
id="fqdn"
|
||||||
pattern="^https?://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{'{'}2,{'}'}$"
|
pattern="^https?://([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{'{'}2,{'}'}$"
|
||||||
@ -189,18 +212,36 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{#if forceSave}
|
{#if forceSave}
|
||||||
<div class="pt-4">
|
<div class="flex-col space-y-2 pt-4 text-center">
|
||||||
|
{#if isNonWWWDomainOK}
|
||||||
<button
|
<button
|
||||||
class="bg-coollabs hover:bg-coollabs-100"
|
class="bg-green-600 hover:bg-green-500"
|
||||||
on:click|preventDefault={() => isDNSValid(getDomain(nonWWWDomain))}
|
on:click|preventDefault={() => isDNSValid(getDomain(nonWWWDomain), false)}
|
||||||
>Check {nonWWWDomain} DNS Record</button
|
>DNS settings for {nonWWWDomain} is OK, click to recheck.</button
|
||||||
>
|
>
|
||||||
|
{:else}
|
||||||
|
<button
|
||||||
|
class="bg-red-600 hover:bg-red-500"
|
||||||
|
on:click|preventDefault={() => isDNSValid(getDomain(nonWWWDomain), false)}
|
||||||
|
>DNS settings for {nonWWWDomain} is invalid, click to recheck.</button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
{#if dualCerts}
|
{#if dualCerts}
|
||||||
|
{#if isWWWDomainOK}
|
||||||
<button
|
<button
|
||||||
class="bg-coollabs hover:bg-coollabs-100"
|
class="bg-green-600 hover:bg-green-500"
|
||||||
on:click|preventDefault={() => isDNSValid(getDomain(`www.${nonWWWDomain}`))}
|
on:click|preventDefault={() =>
|
||||||
>Check www.{nonWWWDomain} DNS Record</button
|
isDNSValid(getDomain(`www.${nonWWWDomain}`), true)}
|
||||||
|
>DNS settings for www.{nonWWWDomain} is OK, click to recheck.</button
|
||||||
>
|
>
|
||||||
|
{:else}
|
||||||
|
<button
|
||||||
|
class="bg-red-600 hover:bg-red-500"
|
||||||
|
on:click|preventDefault={() =>
|
||||||
|
isDNSValid(getDomain(`www.${nonWWWDomain}`), true)}
|
||||||
|
>DNS settings for www.{nonWWWDomain} is invalid, click to recheck.</button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user