From bb6d1fd6a3b21dd380e839f8aec9003db03c4a25 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 23 Feb 2022 10:40:34 +0100 Subject: [PATCH 1/5] cleanup --- src/routes/settings/index.json.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/routes/settings/index.json.ts b/src/routes/settings/index.json.ts index a1182bb42d..e9e867499c 100644 --- a/src/routes/settings/index.json.ts +++ b/src/routes/settings/index.json.ts @@ -45,7 +45,6 @@ export const del: RequestHandler = async (event) => { const { fqdn } = await event.request.json(); let ip; - console.log(fqdn); try { ip = await dns.resolve(fqdn); } catch (error) { From 93aed52f88b41ecc543e91096d3d77bb8a7f2e03 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 23 Feb 2022 11:14:04 +0100 Subject: [PATCH 2/5] Login page description for demo page --- src/routes/login/index.svelte | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/routes/login/index.svelte b/src/routes/login/index.svelte index f337b853c3..88aa1fe43e 100644 --- a/src/routes/login/index.svelte +++ b/src/routes/login/index.svelte @@ -58,7 +58,7 @@ required /> -
+
+ {#if browser && window.location.host === 'demo.coolify.io'} +
+ Registration is open, just fill in an email (does not + need to be live email address for the demo instance) and a password. +
+
+ All users gets an own namespace, so you won't be able to + access other users data. +
+ {/if} {/if}
From ed01e78d77a9ce65c7c82ec77f96d748906c38c9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 23 Feb 2022 12:43:04 +0100 Subject: [PATCH 3/5] improvement: dns check --- src/routes/applications/[id]/check.json.ts | 29 +++++++++++++++++++--- src/routes/applications/[id]/index.svelte | 13 +++++++--- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/routes/applications/[id]/check.json.ts b/src/routes/applications/[id]/check.json.ts index 82fb487ed0..dc1b8ea987 100644 --- a/src/routes/applications/[id]/check.json.ts +++ b/src/routes/applications/[id]/check.json.ts @@ -1,24 +1,47 @@ -import { asyncExecShell, getDomain, getEngine, getUserDetails } from '$lib/common'; +import { dev } from '$app/env'; +import { getDomain, getUserDetails } from '$lib/common'; import * as db from '$lib/database'; import { ErrorHandler } from '$lib/database'; import type { RequestHandler } from '@sveltejs/kit'; +import { promises as dns } from 'dns'; export const post: RequestHandler = async (event) => { const { status, body } = await getUserDetails(event); if (status === 401) return { status, body }; const { id } = event.params; - - let { fqdn } = await event.request.json(); + let { fqdn, forceSave } = await event.request.json(); fqdn = fqdn.toLowerCase(); try { + const domain = getDomain(fqdn); const found = await db.isDomainConfigured({ id, fqdn }); if (found) { throw { message: `Domain ${getDomain(fqdn).replace('www.', '')} is already used.` }; } + if (!dev && !forceSave) { + let ip = []; + let localIp = []; + dns.setServers(['1.1.1.1', '8.8.8.8']); + + try { + localIp = await dns.resolve4(event.url.hostname); + } catch (error) {} + try { + ip = await dns.resolve4(domain); + } catch (error) {} + + if (localIp?.length > 0) { + if (ip?.length === 0 || !ip.includes(localIp[0])) { + throw { + message: `DNS not set or propogated for ${domain}.

Please check your DNS settings.` + }; + } + } + } + return { status: 200 }; diff --git a/src/routes/applications/[id]/index.svelte b/src/routes/applications/[id]/index.svelte index af1d6c2f68..54f7e945f5 100644 --- a/src/routes/applications/[id]/index.svelte +++ b/src/routes/applications/[id]/index.svelte @@ -50,6 +50,7 @@ let domainEl: HTMLInputElement; let loading = false; + let forceSave = false; let debug = application.settings.debug; let previews = application.settings.previews; let dualCerts = application.settings.dualCerts; @@ -78,10 +79,13 @@ async function handleSubmit() { loading = true; try { - await post(`/applications/${id}/check.json`, { fqdn: application.fqdn }); + await post(`/applications/${id}/check.json`, { fqdn: application.fqdn, forceSave }); await post(`/applications/${id}.json`, { ...application }); return window.location.reload(); } catch ({ error }) { + if (error.startsWith('DNS not set')) { + forceSave = true; + } return errorNotification(error); } finally { loading = false; @@ -167,8 +171,11 @@ {loading ? 'Saving...' : forceSave ? 'Are you sure to continue?' : 'Save'} {/if} @@ -249,7 +256,7 @@
Date: Wed, 23 Feb 2022 12:58:32 +0100 Subject: [PATCH 4/5] fix: Revert default network --- src/lib/database/users.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/database/users.ts b/src/lib/database/users.ts index ff10d2bc3a..9c09d0aaf3 100644 --- a/src/lib/database/users.ts +++ b/src/lib/database/users.ts @@ -79,7 +79,7 @@ export async function login({ email, password }) { create: { id: uid, name: uniqueName(), - destinationDocker: { connect: { network: cuid() } } + destinationDocker: { connect: { network: 'coolify' } } } }, permission: { create: { teamId: uid, permission: 'owner' } } From 6e324211729bff9d95f446a5ac64678fd152b753 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 23 Feb 2022 12:58:46 +0100 Subject: [PATCH 5/5] chore: Version++ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fd938191b4..b0b612f269 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "coolify", "description": "An open-source & self-hostable Heroku / Netlify alternative.", - "version": "2.0.19", + "version": "2.0.20", "license": "AGPL-3.0", "scripts": { "dev": "docker-compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev --host 0.0.0.0",