[FEATURE] Live Modifications, Host Safety, Minor Tweaks (#19)
Co-authored-by: Dunemask <dunemask@gmail.com> Reviewed-on: https://gitea.dunemask.dev/elysium/minecluster/pulls/19
This commit is contained in:
parent
0a0f9c8463
commit
fc60df27ac
9 changed files with 154 additions and 31 deletions
|
@ -9,6 +9,8 @@ import {
|
|||
import ExpressClientError, { sendError } from "../util/ExpressClientError.js";
|
||||
import { toggleServer } from "../k8s/k8s-server-control.js";
|
||||
import { checkAuthorization } from "../database/queries/server-queries.js";
|
||||
import { WARN } from "../util/logging.js";
|
||||
import modifyServerResources from "../k8s/server-modify.js";
|
||||
|
||||
const dnsRegex = new RegExp(
|
||||
`^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$`,
|
||||
|
@ -69,6 +71,9 @@ function payloadFilter(req, res) {
|
|||
return res
|
||||
.status(400)
|
||||
.send("Extra ports must be a list of strings with length of 5!");
|
||||
if (host !== host.toLowerCase())
|
||||
WARN("CREATE", "Host automatically being lowercasified...");
|
||||
req.body.host = host.toLowerCase();
|
||||
return "filtered";
|
||||
}
|
||||
|
||||
|
@ -158,10 +163,15 @@ export async function getServer(req, res) {
|
|||
export async function modifyServer(req, res) {
|
||||
if (payloadFilter(req, res) !== "filtered") return;
|
||||
const serverSpec = req.body;
|
||||
if (!!serverSpec.host)
|
||||
WARN(
|
||||
"MODIFY",
|
||||
"Warning, hostname changing is not implimented yet! Please ask the developer if you'd like to see this added!",
|
||||
);
|
||||
try {
|
||||
await checkServerId(req.cairoId, serverSpec);
|
||||
const serverEntry = await modifyServerEntry(serverSpec);
|
||||
// await createServerResources(serverEntry);
|
||||
await modifyServerResources(serverEntry);
|
||||
res.sendStatus(200);
|
||||
} catch (e) {
|
||||
sendError(res)(e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue