fix: Service checks
This commit is contained in:
parent
e452f68614
commit
c917135bd3
@ -52,7 +52,7 @@ export const post: RequestHandler = async (event) => {
|
|||||||
exposePort = Number(exposePort);
|
exposePort = Number(exposePort);
|
||||||
|
|
||||||
if (exposePort < 1024 || exposePort > 65535) {
|
if (exposePort < 1024 || exposePort > 65535) {
|
||||||
throw { message: `Expose Port needs to be between 1024 and 65535.` };
|
throw { message: `Exposed Port needs to be between 1024 and 65535.` };
|
||||||
}
|
}
|
||||||
|
|
||||||
const publicPort = await getPort({ port: exposePort });
|
const publicPort = await getPort({ port: exposePort });
|
||||||
|
@ -31,7 +31,10 @@
|
|||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
loading = true;
|
loading = true;
|
||||||
try {
|
try {
|
||||||
await post(`/services/${id}/check.json`, { fqdn: service.fqdn });
|
await post(`/services/${id}/check.json`, {
|
||||||
|
fqdn: service.fqdn,
|
||||||
|
exposePort: service.exposePort
|
||||||
|
});
|
||||||
await post(`/services/${id}/${service.type}.json`, { ...service });
|
await post(`/services/${id}/${service.type}.json`, { ...service });
|
||||||
return window.location.reload();
|
return window.location.reload();
|
||||||
} catch ({ error }) {
|
} catch ({ error }) {
|
||||||
|
@ -1,19 +1,40 @@
|
|||||||
import { asyncExecShell, getDomain, getEngine, getUserDetails } from '$lib/common';
|
import { asyncExecShell, getDomain, getEngine, getUserDetails } from '$lib/common';
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { ErrorHandler } from '$lib/database';
|
import { ErrorHandler } from '$lib/database';
|
||||||
|
import { t } from '$lib/translations';
|
||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
import getPort from 'get-port';
|
||||||
|
|
||||||
export const post: RequestHandler = async (event) => {
|
export const post: RequestHandler = async (event) => {
|
||||||
const { status, body } = await getUserDetails(event);
|
const { status, body } = await getUserDetails(event);
|
||||||
if (status === 401) return { status, body };
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
let { fqdn } = await event.request.json();
|
let { fqdn, exposePort } = await event.request.json();
|
||||||
|
|
||||||
if (fqdn) fqdn = fqdn.toLowerCase();
|
if (fqdn) fqdn = fqdn.toLowerCase();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const found = await db.isDomainConfigured({ id, fqdn });
|
const found = await db.isDomainConfigured({ id, fqdn });
|
||||||
|
if (found) {
|
||||||
|
throw {
|
||||||
|
message: t.get('application.domain_already_in_use', {
|
||||||
|
domain: getDomain(fqdn).replace('www.', '')
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (exposePort) {
|
||||||
|
exposePort = Number(exposePort);
|
||||||
|
|
||||||
|
if (exposePort < 1024 || exposePort > 65535) {
|
||||||
|
throw { message: `Exposed Port needs to be between 1024 and 65535.` };
|
||||||
|
}
|
||||||
|
|
||||||
|
const publicPort = await getPort({ port: exposePort });
|
||||||
|
if (publicPort !== exposePort) {
|
||||||
|
throw { message: `Port ${exposePort} is already in use.` };
|
||||||
|
}
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
status: found ? 500 : 200,
|
status: found ? 500 : 200,
|
||||||
body: {
|
body: {
|
||||||
|
Loading…
Reference in New Issue
Block a user