fix: dns checking

This commit is contained in:
Andras Bacsai
2022-08-06 09:21:16 +00:00
parent 3d488da5ab
commit de77cbb9d8
6 changed files with 10 additions and 9 deletions

View File

@@ -0,0 +1,2 @@
-- DropIndex
DROP INDEX "Application_fqdn_key";

View File

@@ -82,7 +82,7 @@ model TeamInvitation {
model Application { model Application {
id String @id @default(cuid()) id String @id @default(cuid())
name String name String
fqdn String? @unique fqdn String?
repository String? repository String?
configHash String? configHash String?
branch String? branch String?

View File

@@ -318,12 +318,12 @@ export async function isDomainConfigured({
id, id,
fqdn, fqdn,
checkOwn = false, checkOwn = false,
dockerId = undefined remoteIpAddress = undefined
}: { }: {
id: string; id: string;
fqdn: string; fqdn: string;
checkOwn?: boolean; checkOwn?: boolean;
dockerId?: string; remoteIpAddress?: string;
}): Promise<boolean> { }): Promise<boolean> {
const domain = getDomain(fqdn); const domain = getDomain(fqdn);
const nakedDomain = domain.replace('www.', ''); const nakedDomain = domain.replace('www.', '');
@@ -335,7 +335,7 @@ export async function isDomainConfigured({
], ],
id: { not: id }, id: { not: id },
destinationDocker: { destinationDocker: {
id: dockerId remoteIpAddress,
} }
}, },
select: { fqdn: true } select: { fqdn: true }
@@ -350,7 +350,7 @@ export async function isDomainConfigured({
], ],
id: { not: checkOwn ? undefined : id }, id: { not: checkOwn ? undefined : id },
destinationDocker: { destinationDocker: {
id: dockerId remoteIpAddress
} }
}, },
select: { fqdn: true } select: { fqdn: true }

View File

@@ -387,7 +387,7 @@ export async function checkDNS(request: FastifyRequest<CheckDNS>) {
const { destinationDocker: { id: dockerId, remoteIpAddress, remoteEngine }, exposePort: configuredPort } = await prisma.application.findUnique({ where: { id }, include: { destinationDocker: true } }) const { destinationDocker: { id: dockerId, remoteIpAddress, remoteEngine }, exposePort: configuredPort } = await prisma.application.findUnique({ where: { id }, include: { destinationDocker: true } })
const { isDNSCheckEnabled } = await prisma.setting.findFirst({}); const { isDNSCheckEnabled } = await prisma.setting.findFirst({});
const found = await isDomainConfigured({ id, fqdn, dockerId }); const found = await isDomainConfigured({ id, fqdn, remoteIpAddress });
if (found) { if (found) {
throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` } throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` }
} }

View File

@@ -368,13 +368,13 @@ export async function checkService(request: FastifyRequest<CheckService>) {
const { destinationDocker: { id: dockerId, remoteIpAddress, remoteEngine }, exposePort: configuredPort } = await prisma.service.findUnique({ where: { id }, include: { destinationDocker: true } }) const { destinationDocker: { id: dockerId, remoteIpAddress, remoteEngine }, exposePort: configuredPort } = await prisma.service.findUnique({ where: { id }, include: { destinationDocker: true } })
const { isDNSCheckEnabled } = await prisma.setting.findFirst({}); const { isDNSCheckEnabled } = await prisma.setting.findFirst({});
let found = await isDomainConfigured({ id, fqdn, dockerId }); let found = await isDomainConfigured({ id, fqdn, remoteIpAddress });
if (found) { if (found) {
throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` } throw { status: 500, message: `Domain ${getDomain(fqdn).replace('www.', '')} is already in use!` }
} }
if (otherFqdns && otherFqdns.length > 0) { if (otherFqdns && otherFqdns.length > 0) {
for (const ofqdn of otherFqdns) { for (const ofqdn of otherFqdns) {
found = await isDomainConfigured({ id, fqdn: ofqdn, dockerId }); found = await isDomainConfigured({ id, fqdn: ofqdn,remoteIpAddress });
if (found) { if (found) {
throw { status: 500, message: `Domain ${getDomain(ofqdn).replace('www.', '')} is already in use!` } throw { status: 500, message: `Domain ${getDomain(ofqdn).replace('www.', '')} is already in use!` }
} }

View File

@@ -23,7 +23,6 @@
class="flex justify-center" class="flex justify-center"
> >
<div <div
type="button"
on:click on:click
aria-pressed="false" aria-pressed="false"
class="relative mx-20 inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out" class="relative mx-20 inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out"