Compare commits
4 commits
master
...
ep/Jan21-2
Author | SHA1 | Date | |
---|---|---|---|
246a790bc2 | |||
cbadc54d86 | |||
ea54ee6239 | |||
eb53e56dc7 |
|
@ -1,31 +0,0 @@
|
||||||
# name: Deploy Edge Proxy
|
|
||||||
# run-name: ${{ gitea.actor }} Deploy Edge Proxy
|
|
||||||
# on:
|
|
||||||
# push:
|
|
||||||
# branches: [ master ]
|
|
||||||
|
|
||||||
# env:
|
|
||||||
# GARDEN_DEPLOY_ACTION: minecluster-proxy
|
|
||||||
|
|
||||||
# jobs:
|
|
||||||
# deploy-edge:
|
|
||||||
# steps:
|
|
||||||
# # Setup Oasis
|
|
||||||
# - name: Oasis Setup
|
|
||||||
# uses: https://gitea.dunemask.dev/elysium/elysium-actions@oasis-setup-auto
|
|
||||||
# with:
|
|
||||||
# deploy-env: edge
|
|
||||||
# infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }}
|
|
||||||
# # Deploy to Edge Cluster
|
|
||||||
# - name: Deploy to Edge Cluster
|
|
||||||
# run: garden deploy $GARDEN_DEPLOY_ACTION --force --force-build --env usw-edge
|
|
||||||
# working-directory: ${{ env.OASIS_WORKSPACE }}
|
|
||||||
# # Alert via Discord
|
|
||||||
# - name: Discord Alert
|
|
||||||
# if: always()
|
|
||||||
# uses: https://gitea.dunemask.dev/elysium/elysium-actions@discord-status
|
|
||||||
# with:
|
|
||||||
# status: ${{ job.status }}
|
|
||||||
# channel: deployments
|
|
||||||
# header: DEPLOY EDGE
|
|
||||||
# additional-content: "Minecluster Proxy"
|
|
|
@ -1,44 +0,0 @@
|
||||||
name: Deploy USW-MC
|
|
||||||
run-name: ${{ forgejo.actor }} Deploy USW-MC
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
|
|
||||||
env:
|
|
||||||
GARDEN_DEPLOY_ACTION: minecluster
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy-edge:
|
|
||||||
steps:
|
|
||||||
# Configure proper kubeconfig (Used when cluster does not match the edge environment)
|
|
||||||
- name: Get usw-mc deployment kubeconfig
|
|
||||||
uses: https://forgejo.dunemask.dev/elysium/elysium-actions@infisical-env
|
|
||||||
with:
|
|
||||||
infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }}
|
|
||||||
project-id: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }}
|
|
||||||
secret-envs: edge
|
|
||||||
secret-paths: /kubernetes/usw-mc
|
|
||||||
# Setup Oasis
|
|
||||||
- name: Oasis Setup
|
|
||||||
uses: https://forgejo.dunemask.dev/elysium/elysium-actions@oasis-setup-auto
|
|
||||||
with:
|
|
||||||
deploy-env: edge
|
|
||||||
infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }}
|
|
||||||
infisical-project: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }}
|
|
||||||
extra-secret-paths: /dashboard
|
|
||||||
extra-secret-envs: edge
|
|
||||||
# Deploy to Edge
|
|
||||||
- name: Deploy to Edge env
|
|
||||||
run: garden deploy $GARDEN_DEPLOY_ACTION --force --force-build --env usw-edge
|
|
||||||
working-directory: ${{ env.OASIS_WORKSPACE }}
|
|
||||||
env: # (Used when cluster does not match the edge environment)
|
|
||||||
MCL_KUBECONFIG: ${{ env.KUBERNETES_CONFIG_USW_MC }}
|
|
||||||
# Alert via Discord
|
|
||||||
- name: Discord Alert
|
|
||||||
if: always()
|
|
||||||
uses: https://forgejo.dunemask.dev/elysium/elysium-actions@discord-status
|
|
||||||
with:
|
|
||||||
status: ${{ job.status }}
|
|
||||||
channel: deployments
|
|
||||||
header: DEPLOY MC
|
|
||||||
additional-content: "Minecluster Server Manager Deployment"
|
|
|
@ -1,42 +0,0 @@
|
||||||
# name: QA API Tests
|
|
||||||
# run-name: ${{ gitea.actor }} QA API Test
|
|
||||||
# on:
|
|
||||||
# pull_request:
|
|
||||||
# branches: [ master ]
|
|
||||||
|
|
||||||
# env:
|
|
||||||
# REPO_DIR: ${{ gitea.workspace }}/minecluster
|
|
||||||
# GARDEN_LINK_ACTION: build.minecluster-image
|
|
||||||
|
|
||||||
# jobs:
|
|
||||||
# qa-api-tests:
|
|
||||||
# steps:
|
|
||||||
# # Setup Oasis
|
|
||||||
# - name: Oasis Setup
|
|
||||||
# uses: https://gitea.dunemask.dev/elysium/elysium-actions@oasis-setup-auto
|
|
||||||
# with:
|
|
||||||
# deploy-env: ci
|
|
||||||
# infisical-token: ${{ secrets.INFISICAL_ELYSIUM_CI_READ_TOKEN }}
|
|
||||||
# # Test Code
|
|
||||||
# - name: Checkout repository
|
|
||||||
# uses: actions/checkout@v3
|
|
||||||
# with:
|
|
||||||
# path: ${{ env.REPO_DIR }}
|
|
||||||
# # Garden link
|
|
||||||
# - name: Link Repo code to Garden
|
|
||||||
# run: garden link action $GARDEN_LINK_ACTION $REPO_DIR --env usw-ci --var cubit-projects=cairo,minecluster
|
|
||||||
# working-directory: ${{ env.OASIS_WORKSPACE }}
|
|
||||||
# # Cubit CI Tests
|
|
||||||
# - name: Run Cubit tests in CI env
|
|
||||||
# run: garden workflow qa-api-tests --env usw-ci --var ci-ttl=25m
|
|
||||||
# working-directory: ${{ env.OASIS_WORKSPACE }}
|
|
||||||
# # Discord Alert
|
|
||||||
# - name: Discord Alert
|
|
||||||
# if: always()
|
|
||||||
# uses: https://gitea.dunemask.dev/elysium/elysium-actions@discord-status
|
|
||||||
# with:
|
|
||||||
# status: ${{ job.status }}
|
|
||||||
# channel: ci
|
|
||||||
# header: QA API Tests
|
|
||||||
# additional-content: "CI Namespace: `${{env.CI_NAMESPACE}}`"
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
name: S3 Repo Backup
|
|
||||||
run-name: ${{ forgejo.actor }} S3 Repo Backup
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
s3-repo-backup:
|
|
||||||
steps:
|
|
||||||
- name: S3 Backup
|
|
||||||
uses: https://forgejo.dunemask.dev/elysium/elysium-actions@s3-backup
|
|
||||||
with:
|
|
||||||
infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }}
|
|
||||||
infisical-project: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }}
|
|
||||||
- name: Status Alert
|
|
||||||
if: always()
|
|
||||||
run: echo "The Job ended with status ${{ job.status }}."
|
|
31
.gitea/workflows/s3-repo-backup.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
name: S3 Repo Backup
|
||||||
|
run-name: ${{ gitea.actor }} S3 Repo Backup
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
env:
|
||||||
|
S3_BACKUP_ENDPOINT: https://s3.dunemask.dev
|
||||||
|
S3_BACKUP_KEY_ID: gitea-repo-backup
|
||||||
|
S3_BACKUP_KEY: ${{ secrets.S3_REPO_BACKUP_KEY }}
|
||||||
|
REPO_DIR: ${{ gitea.workspace }}/${{ gitea.respository }}
|
||||||
|
jobs:
|
||||||
|
s3-repo-backup:
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
path: ${{ env.REPO_DIR }}
|
||||||
|
- name: S3 Backup
|
||||||
|
uses: peter-evans/s3-backup@v1
|
||||||
|
env:
|
||||||
|
ACCESS_KEY_ID: ${{ env.S3_BACKUP_KEY_ID }}
|
||||||
|
SECRET_ACCESS_KEY: ${{ env.S3_BACKUP_KEY }}
|
||||||
|
MIRROR_SOURCE: ${{ env.REPO_DIR }}
|
||||||
|
MIRROR_TARGET: repository-backups/${{ gitea.repository }}
|
||||||
|
STORAGE_SERVICE_URL: ${{env.S3_BACKUP_ENDPOINT}}
|
||||||
|
with:
|
||||||
|
args: --overwrite --remove
|
||||||
|
- name: Status Alert
|
||||||
|
if: always()
|
||||||
|
run: echo "The Job ended with status ${{ job.status }}."
|
1
.gitignore
vendored
|
@ -1,3 +1,2 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
.env
|
|
||||||
|
|
||||||
|
|
2
dist/app.js
vendored
|
@ -8,4 +8,4 @@ const kc = new k8s.KubeConfig();
|
||||||
kc.loadFromDefault();
|
kc.loadFromDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch((e)=>{console.error(e)});
|
main().catch((e)=>{console.log(e)});
|
||||||
|
|
|
@ -4,15 +4,6 @@
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<meta name="description" content="Minecraft Servers in Kubernetes" />
|
<meta name="description" content="Minecraft Servers in Kubernetes" />
|
||||||
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png?v=feb4-24-mineblock">
|
|
||||||
<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png?v=feb4-24-mineblock">
|
|
||||||
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png?v=feb4-24-mineblock">
|
|
||||||
<link rel="manifest" href="/icons/site.webmanifest?v=feb4-24-mineblock">
|
|
||||||
<link rel="mask-icon" href="/icons/safari-pinned-tab.svg?v=feb4-24-mineblock" color="#00bd70">
|
|
||||||
<link rel="shortcut icon" href="/icons/favicon.ico?v=feb4-24-mineblock">
|
|
||||||
<meta name="msapplication-TileColor" content="#00aba9">
|
|
||||||
<meta name="msapplication-config" content="/icons/browserconfig.xml?v=feb4-24-mineblock">
|
|
||||||
<meta name="theme-color" content="#249c6b">
|
|
||||||
<title>Minecluster</title>
|
<title>Minecluster</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -4,17 +4,13 @@ import {
|
||||||
listServerFiles,
|
listServerFiles,
|
||||||
removeServerItem,
|
removeServerItem,
|
||||||
uploadServerItem,
|
uploadServerItem,
|
||||||
moveServerItems,
|
|
||||||
} from "../k8s/server-files.js";
|
} from "../k8s/server-files.js";
|
||||||
import { sendError } from "../util/ExpressClientError.js";
|
import { sendError } from "../util/ExpressClientError.js";
|
||||||
import { checkAuthorization } from "../database/queries/server-queries.js";
|
|
||||||
|
|
||||||
export async function listFiles(req, res) {
|
export async function listFiles(req, res) {
|
||||||
const serverSpec = req.body;
|
const serverSpec = req.body;
|
||||||
if (!serverSpec) return res.sendStatus(400);
|
if (!serverSpec) return res.sendStatus(400);
|
||||||
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
||||||
const authorized = await checkAuthorization(serverSpec.id, req.cairoId);
|
|
||||||
if (!authorized) return res.sendStatus(403);
|
|
||||||
listServerFiles(serverSpec)
|
listServerFiles(serverSpec)
|
||||||
.then((f) => {
|
.then((f) => {
|
||||||
const fileData = f.map((fi, i) => ({
|
const fileData = f.map((fi, i) => ({
|
||||||
|
@ -35,8 +31,6 @@ export async function createFolder(req, res) {
|
||||||
if (!serverSpec) return res.sendStatus(400);
|
if (!serverSpec) return res.sendStatus(400);
|
||||||
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
||||||
if (!serverSpec.path) return res.status(400).send("Path required!");
|
if (!serverSpec.path) return res.status(400).send("Path required!");
|
||||||
const authorized = await checkAuthorization(serverSpec.id, req.cairoId);
|
|
||||||
if (!authorized) return res.sendStatus(403);
|
|
||||||
createServerFolder(serverSpec)
|
createServerFolder(serverSpec)
|
||||||
.then(() => res.sendStatus(200))
|
.then(() => res.sendStatus(200))
|
||||||
.catch(sendError(res));
|
.catch(sendError(res));
|
||||||
|
@ -49,8 +43,6 @@ export async function deleteItem(req, res) {
|
||||||
if (!serverSpec.path) return res.status(400).send("Path required!");
|
if (!serverSpec.path) return res.status(400).send("Path required!");
|
||||||
if (serverSpec.isDir === undefined || serverSpec.isDir === null)
|
if (serverSpec.isDir === undefined || serverSpec.isDir === null)
|
||||||
return res.status(400).send("IsDIr required!");
|
return res.status(400).send("IsDIr required!");
|
||||||
const authorized = await checkAuthorization(serverSpec.id, req.cairoId);
|
|
||||||
if (!authorized) return res.sendStatus(403);
|
|
||||||
removeServerItem(serverSpec)
|
removeServerItem(serverSpec)
|
||||||
.then(() => res.sendStatus(200))
|
.then(() => res.sendStatus(200))
|
||||||
.catch(sendError(res));
|
.catch(sendError(res));
|
||||||
|
@ -60,8 +52,6 @@ export async function uploadItem(req, res) {
|
||||||
const serverSpec = req.body;
|
const serverSpec = req.body;
|
||||||
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
||||||
if (!serverSpec.path) return res.status(400).send("Path required!");
|
if (!serverSpec.path) return res.status(400).send("Path required!");
|
||||||
const authorized = await checkAuthorization(serverSpec.id, req.cairoId);
|
|
||||||
if (!authorized) return res.sendStatus(403);
|
|
||||||
uploadServerItem(serverSpec, req.file)
|
uploadServerItem(serverSpec, req.file)
|
||||||
.then(() => res.sendStatus(200))
|
.then(() => res.sendStatus(200))
|
||||||
.catch(sendError(res));
|
.catch(sendError(res));
|
||||||
|
@ -71,8 +61,6 @@ export async function getItem(req, res) {
|
||||||
const serverSpec = req.body;
|
const serverSpec = req.body;
|
||||||
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
||||||
if (!serverSpec.path) return res.status(400).send("Path required!");
|
if (!serverSpec.path) return res.status(400).send("Path required!");
|
||||||
const authorized = await checkAuthorization(serverSpec.id, req.cairoId);
|
|
||||||
if (!authorized) return res.sendStatus(403);
|
|
||||||
getServerItem(serverSpec, res)
|
getServerItem(serverSpec, res)
|
||||||
.then(({ ds, ftpTransfer }) => {
|
.then(({ ds, ftpTransfer }) => {
|
||||||
ds.pipe(res).on("error", sendError(res));
|
ds.pipe(res).on("error", sendError(res));
|
||||||
|
@ -80,18 +68,3 @@ export async function getItem(req, res) {
|
||||||
})
|
})
|
||||||
.catch(sendError(res));
|
.catch(sendError(res));
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function moveItems(req, res) {
|
|
||||||
const serverSpec = req.body;
|
|
||||||
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
|
||||||
if (!serverSpec.destination)
|
|
||||||
return res.status(400).send("Destination required!");
|
|
||||||
if (!serverSpec.origin) return res.status(400).send("Origin required!");
|
|
||||||
if (!serverSpec.files || !Array.isArray(serverSpec.files))
|
|
||||||
return res.status(400).send("Files required!");
|
|
||||||
const authorized = await checkAuthorization(serverSpec.id, req.cairoId);
|
|
||||||
if (!authorized) return res.sendStatus(403);
|
|
||||||
moveServerItems(serverSpec)
|
|
||||||
.then(() => res.sendStatus(200))
|
|
||||||
.catch(sendError(res));
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,9 +8,6 @@ import {
|
||||||
} from "../database/queries/server-queries.js";
|
} from "../database/queries/server-queries.js";
|
||||||
import ExpressClientError, { sendError } from "../util/ExpressClientError.js";
|
import ExpressClientError, { sendError } from "../util/ExpressClientError.js";
|
||||||
import { toggleServer } from "../k8s/k8s-server-control.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(
|
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]))*$`,
|
`^([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]))*$`,
|
||||||
|
@ -18,14 +15,8 @@ const dnsRegex = new RegExp(
|
||||||
|
|
||||||
function backupPayloadFilter(req, res) {
|
function backupPayloadFilter(req, res) {
|
||||||
const serverSpec = req.body;
|
const serverSpec = req.body;
|
||||||
const {
|
const { backupHost, backupBucket, backupId, backupKey, backupInterval } =
|
||||||
storage,
|
serverSpec;
|
||||||
backupHost,
|
|
||||||
backupBucket,
|
|
||||||
backupId,
|
|
||||||
backupKey,
|
|
||||||
backupInterval,
|
|
||||||
} = serverSpec;
|
|
||||||
// TODO: Impliment non creation time backups
|
// TODO: Impliment non creation time backups
|
||||||
if (
|
if (
|
||||||
!!backupHost ||
|
!!backupHost ||
|
||||||
|
@ -34,8 +25,6 @@ function backupPayloadFilter(req, res) {
|
||||||
!!backupKey ||
|
!!backupKey ||
|
||||||
!!backupInterval
|
!!backupInterval
|
||||||
) {
|
) {
|
||||||
if (storage === 0)
|
|
||||||
return res.status(400).send("Backups cannot be used if storage is zero!");
|
|
||||||
// If any keys are required, all are required
|
// If any keys are required, all are required
|
||||||
if (
|
if (
|
||||||
!(
|
!(
|
||||||
|
@ -71,19 +60,13 @@ function payloadFilter(req, res) {
|
||||||
return res
|
return res
|
||||||
.status(400)
|
.status(400)
|
||||||
.send("Extra ports must be a list of strings with length of 5!");
|
.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";
|
return "filtered";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function checkServerId(cairoId, serverSpec) {
|
function checkServerId(serverSpec) {
|
||||||
if (!serverSpec) throw new ExpressClientError({ c: 400 });
|
if (!serverSpec) throw new ExpressClientError({ c: 400 });
|
||||||
if (!serverSpec.id)
|
if (!serverSpec.id)
|
||||||
throw new ExpressClientError({ c: 400, m: "Server id missing!" });
|
throw new ExpressClientError({ c: 400, m: "Server id missing!" });
|
||||||
const authorized = await checkAuthorization(serverSpec.id, cairoId);
|
|
||||||
if (!authorized)
|
|
||||||
throw new ExpressClientError({ c: 403, m: "Access forbidden!" });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createServer(req, res) {
|
export async function createServer(req, res) {
|
||||||
|
@ -91,9 +74,9 @@ export async function createServer(req, res) {
|
||||||
if (backupPayloadFilter(req, res) !== "filtered") return;
|
if (backupPayloadFilter(req, res) !== "filtered") return;
|
||||||
const serverSpec = req.body;
|
const serverSpec = req.body;
|
||||||
try {
|
try {
|
||||||
const serverEntry = await createServerEntry(req.cairoId, serverSpec);
|
const serverEntry = await createServerEntry(serverSpec);
|
||||||
await createServerResources(serverEntry);
|
await createServerResources(serverEntry);
|
||||||
res.json(serverEntry);
|
res.sendStatus(200);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendError(res)(e);
|
sendError(res)(e);
|
||||||
}
|
}
|
||||||
|
@ -103,7 +86,7 @@ export async function deleteServer(req, res) {
|
||||||
// Ensure spec is safe
|
// Ensure spec is safe
|
||||||
const serverSpec = req.body;
|
const serverSpec = req.body;
|
||||||
try {
|
try {
|
||||||
await checkServerId(req.cairoId, serverSpec);
|
checkServerId(serverSpec);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return sendError(res)(e);
|
return sendError(res)(e);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +101,7 @@ export async function startServer(req, res) {
|
||||||
// Ensure spec is safe
|
// Ensure spec is safe
|
||||||
const serverSpec = req.body;
|
const serverSpec = req.body;
|
||||||
try {
|
try {
|
||||||
await checkServerId(req.cairoId, serverSpec);
|
checkServerId(serverSpec);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return sendError(res)(e);
|
return sendError(res)(e);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +115,7 @@ export async function stopServer(req, res) {
|
||||||
// Ensure spec is safe
|
// Ensure spec is safe
|
||||||
const serverSpec = req.body;
|
const serverSpec = req.body;
|
||||||
try {
|
try {
|
||||||
await checkServerId(req.cairoId, serverSpec);
|
checkServerId(serverSpec);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return sendError(res)(e);
|
return sendError(res)(e);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +129,7 @@ export async function getServer(req, res) {
|
||||||
// Ensure spec is safe
|
// Ensure spec is safe
|
||||||
const serverSpec = req.body;
|
const serverSpec = req.body;
|
||||||
try {
|
try {
|
||||||
await checkServerId(req.cairoId, serverSpec);
|
checkServerId(serverSpec);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return sendError(res)(e);
|
return sendError(res)(e);
|
||||||
}
|
}
|
||||||
|
@ -163,15 +146,10 @@ export async function getServer(req, res) {
|
||||||
export async function modifyServer(req, res) {
|
export async function modifyServer(req, res) {
|
||||||
if (payloadFilter(req, res) !== "filtered") return;
|
if (payloadFilter(req, res) !== "filtered") return;
|
||||||
const serverSpec = req.body;
|
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 {
|
try {
|
||||||
await checkServerId(req.cairoId, serverSpec);
|
checkServerId(serverSpec);
|
||||||
const serverEntry = await modifyServerEntry(serverSpec);
|
const serverEntry = await modifyServerEntry(serverSpec);
|
||||||
await modifyServerResources(serverEntry);
|
// await createServerResources(serverEntry);
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
sendError(res)(e);
|
sendError(res)(e);
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
import { S3, GetObjectCommand } from "@aws-sdk/client-s3";
|
|
||||||
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
|
||||||
import { basename } from "node:path";
|
|
||||||
import { getServerEntry } from "../database/queries/server-queries.js";
|
|
||||||
import { ERR } from "../util/logging.js";
|
|
||||||
import { checkAuthorization } from "../database/queries/server-queries.js";
|
|
||||||
const s3Region = "us-east-1";
|
|
||||||
|
|
||||||
async function getS3BackupData(serverId) {
|
|
||||||
const serverEntry = await getServerEntry(serverId);
|
|
||||||
if (!serverEntry?.backupHost) return undefined;
|
|
||||||
const s3Config = {
|
|
||||||
credentials: {
|
|
||||||
accessKeyId: serverEntry.backupId,
|
|
||||||
secretAccessKey: serverEntry.backupKey,
|
|
||||||
},
|
|
||||||
endpoint: `https://${serverEntry.backupHost}`,
|
|
||||||
forcePathStyle: true,
|
|
||||||
region: s3Region,
|
|
||||||
};
|
|
||||||
const pathParts = serverEntry.backupPath.split("/");
|
|
||||||
if (pathParts[0] === "") pathParts.shift();
|
|
||||||
const bucket = pathParts.shift();
|
|
||||||
const backupPrefix = pathParts.join("/");
|
|
||||||
return { s3Config, bucket, backupPrefix };
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function listS3Backups(req, res) {
|
|
||||||
const serverSpec = req.body;
|
|
||||||
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
|
||||||
const authorized = await checkAuthorization(serverSpec.id, req.cairoId);
|
|
||||||
if (!authorized)
|
|
||||||
return res
|
|
||||||
.status(403)
|
|
||||||
.send("You do not have permission to access that server!");
|
|
||||||
const s3Data = await getS3BackupData(serverSpec.id);
|
|
||||||
if (!s3Data) return res.status(409).send("Backup not configured!");
|
|
||||||
const { s3Config, bucket, backupPrefix } = s3Data;
|
|
||||||
const s3Client = new S3(s3Config);
|
|
||||||
try {
|
|
||||||
const listResponse = await s3Client.listObjectsV2({
|
|
||||||
Bucket: bucket,
|
|
||||||
Prefix: backupPrefix,
|
|
||||||
});
|
|
||||||
const files =
|
|
||||||
listResponse.Contents?.map((f) => ({
|
|
||||||
name: basename(f.Key),
|
|
||||||
lastModified: f.LastModified,
|
|
||||||
path: f.Key,
|
|
||||||
size: f.Size,
|
|
||||||
})) ?? [];
|
|
||||||
res.json(files);
|
|
||||||
} catch (e) {
|
|
||||||
ERR("S3", e);
|
|
||||||
res.sendStatus(500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getS3BackupUrl(req, res) {
|
|
||||||
const serverSpec = req.body;
|
|
||||||
if (!serverSpec.id) return res.status(400).send("Server id missing!");
|
|
||||||
if (!serverSpec.backupPath)
|
|
||||||
return res.status(400).send("Backup path missing!");
|
|
||||||
const authorized = await checkAuthorization(serverSpec.id, req.cairoId);
|
|
||||||
if (!authorized)
|
|
||||||
return res
|
|
||||||
.status(403)
|
|
||||||
.send("You do not have permission to access that server!");
|
|
||||||
const s3Data = await getS3BackupData(serverSpec.id);
|
|
||||||
if (!s3Data) return res.status(409).send("Backup not configured!");
|
|
||||||
const { s3Config, bucket } = s3Data;
|
|
||||||
const s3Client = new S3(s3Config);
|
|
||||||
try {
|
|
||||||
const command = new GetObjectCommand({
|
|
||||||
Bucket: bucket,
|
|
||||||
Key: serverSpec.backupPath,
|
|
||||||
});
|
|
||||||
const url = await getSignedUrl(s3Client, command, { expiresIn: 3600 });
|
|
||||||
res.json({ url });
|
|
||||||
} catch (e) {
|
|
||||||
ERR("S3", e);
|
|
||||||
res.sendStatus(500);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { getUserDeployments } from "../k8s/k8s-server-control.js";
|
import { getDeployments } from "../k8s/k8s-server-control.js";
|
||||||
import { getInstances } from "../k8s/server-status.js";
|
import { getInstances } from "../k8s/server-status.js";
|
||||||
import { sendError } from "../util/ExpressClientError.js";
|
import { sendError } from "../util/ExpressClientError.js";
|
||||||
|
|
||||||
export function serverList(req, res) {
|
export function serverList(req, res) {
|
||||||
getUserDeployments(req.cairoId)
|
getDeployments()
|
||||||
.then((sd) => res.json(sd.map((s) => s.metadata.name.substring(4))))
|
.then((sd) => res.json(sd.map((s) => s.metadata.name.substring(4))))
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
ERR("STATUS CONTROLLER", e);
|
ERR("STATUS CONTROLLER", e);
|
||||||
|
@ -12,7 +12,7 @@ export function serverList(req, res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function serverInstances(req, res) {
|
export function serverInstances(req, res) {
|
||||||
getInstances(req.cairoId)
|
getInstances()
|
||||||
.then((i) => res.json(i))
|
.then((i) => res.json(i))
|
||||||
.catch(sendError(res));
|
.catch(sendError(res));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,10 @@ import { Rcon as RconClient } from "rcon-client";
|
||||||
import stream from "stream";
|
import stream from "stream";
|
||||||
import { ERR, WARN } from "../../util/logging.js";
|
import { ERR, WARN } from "../../util/logging.js";
|
||||||
import { getServerEntry } from "../../database/queries/server-queries.js";
|
import { getServerEntry } from "../../database/queries/server-queries.js";
|
||||||
import kc from "../../k8s/k8s-config.js";
|
|
||||||
// Kubernetes Configuration
|
|
||||||
|
|
||||||
|
// Kubernetes Configuration
|
||||||
|
const kc = new k8s.KubeConfig();
|
||||||
|
kc.loadFromDefault();
|
||||||
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
|
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
|
||||||
const namespace = process.env.MCL_SERVER_NAMESPACE;
|
const namespace = process.env.MCL_SERVER_NAMESPACE;
|
||||||
|
|
||||||
|
@ -26,13 +27,9 @@ export async function webConsoleLogs(socket) {
|
||||||
|
|
||||||
const log = new k8s.Log(kc);
|
const log = new k8s.Log(kc);
|
||||||
const logStream = new stream.PassThrough();
|
const logStream = new stream.PassThrough();
|
||||||
var logstreamBuffer = "";
|
logStream.on("data", (chunk) =>
|
||||||
logStream.on("data", (chunk) => {
|
socket.emit("push", Buffer.from(chunk).toString()),
|
||||||
const bufferString = Buffer.from(chunk).toString();
|
);
|
||||||
if (!bufferString.includes("\n")) return (logstreamBuffer += bufferString);
|
|
||||||
const clientChunks = `${logstreamBuffer}${bufferString}`.split("\n");
|
|
||||||
for (var c of clientChunks) socket.emit("push", c);
|
|
||||||
});
|
|
||||||
log
|
log
|
||||||
.log(namespace, mcsPods[0], containerName, logStream, {
|
.log(namespace, mcsPods[0], containerName, logStream, {
|
||||||
follow: true,
|
follow: true,
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
CREATE SEQUENCE servers_id_seq;
|
CREATE SEQUENCE servers_id_seq;
|
||||||
CREATE TABLE servers (
|
CREATE TABLE servers (
|
||||||
id bigint NOT NULL DEFAULT nextval('servers_id_seq') PRIMARY KEY,
|
id bigint NOT NULL DEFAULT nextval('servers_id_seq') PRIMARY KEY,
|
||||||
owner_cairo_id varchar(63),
|
|
||||||
host varchar(255) DEFAULT NULL,
|
host varchar(255) DEFAULT NULL,
|
||||||
name varchar(255) DEFAULT NULL,
|
name varchar(255) DEFAULT NULL,
|
||||||
version varchar(63) DEFAULT 'latest',
|
version varchar(63) DEFAULT 'latest',
|
||||||
server_type varchar(63) DEFAULT 'VANILLA',
|
server_type varchar(63) DEFAULT 'VANILLA',
|
||||||
cpu varchar(63) DEFAULT '500',
|
cpu varchar(63) DEFAULT '500',
|
||||||
memory varchar(63) DEFAULT '512',
|
memory varchar(63) DEFAULT '512',
|
||||||
storage varchar(63) DEFAULT NULL,
|
|
||||||
backup_enabled BOOLEAN DEFAULT FALSE,
|
backup_enabled BOOLEAN DEFAULT FALSE,
|
||||||
backup_host varchar(255) DEFAULT NULL,
|
backup_host varchar(255) DEFAULT NULL,
|
||||||
backup_bucket_path varchar(255) DEFAULT NULL,
|
backup_bucket_path varchar(255) DEFAULT NULL,
|
||||||
|
|
|
@ -11,7 +11,7 @@ const {
|
||||||
MCL_POSTGRES_DATABASE: database,
|
MCL_POSTGRES_DATABASE: database,
|
||||||
MCL_POSTGRES_ENABLED: pgEnabled,
|
MCL_POSTGRES_ENABLED: pgEnabled,
|
||||||
MCL_POSTGRES_HOST: host,
|
MCL_POSTGRES_HOST: host,
|
||||||
MCL_POSTGRES_PASS: password,
|
MCL_POSTGRES_PASSWORD: password,
|
||||||
MCL_POSTGRES_PORT: port,
|
MCL_POSTGRES_PORT: port,
|
||||||
MCL_POSTGRES_USER: user,
|
MCL_POSTGRES_USER: user,
|
||||||
} = process.env;
|
} = process.env;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import pg from "../postgres.js";
|
||||||
import {
|
import {
|
||||||
deleteQuery,
|
deleteQuery,
|
||||||
insertQuery,
|
insertQuery,
|
||||||
selectWhereAllQuery,
|
selectWhereQuery,
|
||||||
updateWhereAllQuery,
|
updateWhereAllQuery,
|
||||||
} from "../pg-query.js";
|
} from "../pg-query.js";
|
||||||
import ExpressClientError from "../../util/ExpressClientError.js";
|
import ExpressClientError from "../../util/ExpressClientError.js";
|
||||||
|
@ -12,30 +12,15 @@ const asExpressClientError = (e) => {
|
||||||
throw new ExpressClientError({ m: e.message, c: 409 });
|
throw new ExpressClientError({ m: e.message, c: 409 });
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMclName = (host, id) =>
|
const getMclName = (host, id) => `${host.replaceAll(".", "-")}-${id}`;
|
||||||
`${host.toLowerCase().replaceAll(".", "-")}-${id}`;
|
|
||||||
|
|
||||||
export async function checkAuthorization(serverId, cairoId) {
|
export async function createServerEntry(serverSpec) {
|
||||||
console.log(
|
|
||||||
`Checking Authorization for user ${cairoId} for serverId ${serverId}`,
|
|
||||||
);
|
|
||||||
if (!cairoId) return false;
|
|
||||||
const q = selectWhereAllQuery(table, {
|
|
||||||
id: serverId,
|
|
||||||
owner_cairo_id: cairoId,
|
|
||||||
});
|
|
||||||
return (await pg.query(q)).length === 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createServerEntry(cairoId, serverSpec) {
|
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
host,
|
host,
|
||||||
version,
|
version,
|
||||||
serverType: server_type,
|
serverType: server_type,
|
||||||
cpu, // TODO: Ignored for now by the K8S manifests
|
|
||||||
memory,
|
memory,
|
||||||
storage: storage_val,
|
|
||||||
extraPorts: extra_ports,
|
extraPorts: extra_ports,
|
||||||
backupHost: backup_host,
|
backupHost: backup_host,
|
||||||
backupBucket: backup_bucket_path,
|
backupBucket: backup_bucket_path,
|
||||||
|
@ -43,16 +28,12 @@ export async function createServerEntry(cairoId, serverSpec) {
|
||||||
backupKey: backup_key,
|
backupKey: backup_key,
|
||||||
backupInterval: backup_interval,
|
backupInterval: backup_interval,
|
||||||
} = serverSpec;
|
} = serverSpec;
|
||||||
|
|
||||||
var q = insertQuery(table, {
|
var q = insertQuery(table, {
|
||||||
name,
|
name,
|
||||||
owner_cairo_id: cairoId,
|
|
||||||
host,
|
host,
|
||||||
version,
|
version,
|
||||||
server_type,
|
server_type,
|
||||||
cpu, // TODO: Ignored for now by the K8S manifests
|
|
||||||
memory,
|
memory,
|
||||||
storage: !storage_val || storage_val === "0" ? null : storage_val, // 0, undefined, null, or "0" becomes null
|
|
||||||
extra_ports,
|
extra_ports,
|
||||||
backup_enabled: !!backup_interval ? true : null, // We already verified the payload, so any backup key will work
|
backup_enabled: !!backup_interval ? true : null, // We already verified the payload, so any backup key will work
|
||||||
backup_host,
|
backup_host,
|
||||||
|
@ -66,14 +47,11 @@ export async function createServerEntry(cairoId, serverSpec) {
|
||||||
const entries = await pg.query(q);
|
const entries = await pg.query(q);
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
owner_cairo_id: ownerCairoId,
|
|
||||||
name,
|
name,
|
||||||
host,
|
host,
|
||||||
version,
|
version,
|
||||||
server_type: serverType,
|
server_type: serverType,
|
||||||
cpu, // TODO: Ignored for now by the K8S manifests
|
|
||||||
memory,
|
memory,
|
||||||
storage,
|
|
||||||
extra_ports: extraPorts,
|
extra_ports: extraPorts,
|
||||||
backup_enabled: backupEnabled,
|
backup_enabled: backupEnabled,
|
||||||
backup_host: backupHost,
|
backup_host: backupHost,
|
||||||
|
@ -87,13 +65,10 @@ export async function createServerEntry(cairoId, serverSpec) {
|
||||||
name,
|
name,
|
||||||
mclName,
|
mclName,
|
||||||
id,
|
id,
|
||||||
ownerCairoId,
|
|
||||||
host,
|
host,
|
||||||
version,
|
version,
|
||||||
serverType,
|
serverType,
|
||||||
cpu, // TODO: Ignored for now by the K8S manifests
|
|
||||||
memory,
|
memory,
|
||||||
storage,
|
|
||||||
extraPorts,
|
extraPorts,
|
||||||
backupEnabled,
|
backupEnabled,
|
||||||
backupHost,
|
backupHost,
|
||||||
|
@ -115,7 +90,7 @@ export async function deleteServerEntry(serverId) {
|
||||||
|
|
||||||
export async function getServerEntry(serverId) {
|
export async function getServerEntry(serverId) {
|
||||||
if (!serverId) asExpressClientError({ message: "Server ID Required!" });
|
if (!serverId) asExpressClientError({ message: "Server ID Required!" });
|
||||||
const q = selectWhereAllQuery(table, { id: serverId });
|
const q = selectWhereQuery(table, { id: serverId });
|
||||||
try {
|
try {
|
||||||
const serverSpecs = await pg.query(q);
|
const serverSpecs = await pg.query(q);
|
||||||
if (serverSpecs.length === 0) return [];
|
if (serverSpecs.length === 0) return [];
|
||||||
|
@ -123,14 +98,11 @@ export async function getServerEntry(serverId) {
|
||||||
throw Error("Multiple servers found with the same name!");
|
throw Error("Multiple servers found with the same name!");
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
owner_cairo_id: ownerCairoId,
|
|
||||||
name,
|
name,
|
||||||
host,
|
host,
|
||||||
version,
|
version,
|
||||||
server_type: serverType,
|
server_type: serverType,
|
||||||
cpu, // TODO: Ignored for now by the K8S manifests
|
|
||||||
memory,
|
memory,
|
||||||
storage,
|
|
||||||
extra_ports: extraPorts,
|
extra_ports: extraPorts,
|
||||||
backup_enabled: backupEnabled,
|
backup_enabled: backupEnabled,
|
||||||
backup_host: backupHost,
|
backup_host: backupHost,
|
||||||
|
@ -144,13 +116,10 @@ export async function getServerEntry(serverId) {
|
||||||
name,
|
name,
|
||||||
mclName,
|
mclName,
|
||||||
id,
|
id,
|
||||||
ownerCairoId,
|
|
||||||
host,
|
host,
|
||||||
version,
|
version,
|
||||||
serverType,
|
serverType,
|
||||||
cpu, // TODO: Ignored for now by the K8S manifests
|
|
||||||
memory,
|
memory,
|
||||||
storage,
|
|
||||||
extraPorts,
|
extraPorts,
|
||||||
backupEnabled,
|
backupEnabled,
|
||||||
backupHost,
|
backupHost,
|
||||||
|
@ -167,14 +136,11 @@ export async function getServerEntry(serverId) {
|
||||||
export async function modifyServerEntry(serverSpec) {
|
export async function modifyServerEntry(serverSpec) {
|
||||||
const {
|
const {
|
||||||
id,
|
id,
|
||||||
// ownerCairoId: owner_cairo_id, // DIsabled! If these becomes a reqest, please create a new function!
|
|
||||||
name,
|
name,
|
||||||
// host, // TODO: Can only be updated if service name is generic and non descriptive
|
host,
|
||||||
version,
|
version,
|
||||||
serverType: server_type,
|
serverType: server_type,
|
||||||
cpu, // TODO: Ignored for now by the K8S manifests
|
|
||||||
memory,
|
memory,
|
||||||
// storage, // DO NOT INCLUDE THIS KEY, Not all storage providers in kubernetes allow for dynamically resizable PVCs
|
|
||||||
extraPorts: extra_ports,
|
extraPorts: extra_ports,
|
||||||
backupEnabled: backup_enabled,
|
backupEnabled: backup_enabled,
|
||||||
backupHost: backup_host,
|
backupHost: backup_host,
|
||||||
|
@ -184,17 +150,14 @@ export async function modifyServerEntry(serverSpec) {
|
||||||
backupInterval: backup_interval,
|
backupInterval: backup_interval,
|
||||||
} = serverSpec;
|
} = serverSpec;
|
||||||
|
|
||||||
const q =
|
const q = updateWhereAllQuery(
|
||||||
updateWhereAllQuery(
|
|
||||||
table,
|
table,
|
||||||
{
|
{
|
||||||
name,
|
name,
|
||||||
// host, // TODO: Can only be updated if service name is generic and non descriptive
|
host,
|
||||||
version,
|
version,
|
||||||
server_type,
|
server_type,
|
||||||
cpu, // TODO: Ignored for now by the K8S manifests
|
|
||||||
memory,
|
memory,
|
||||||
// storage, // DO NOT INCLUDE THIS KEY, Not all storage providers in kubernetes allow for dynamically resizable PVCs
|
|
||||||
extra_ports,
|
extra_ports,
|
||||||
backup_enabled,
|
backup_enabled,
|
||||||
backup_host,
|
backup_host,
|
||||||
|
@ -204,46 +167,9 @@ export async function modifyServerEntry(serverSpec) {
|
||||||
backup_interval,
|
backup_interval,
|
||||||
},
|
},
|
||||||
{ id },
|
{ id },
|
||||||
) + ` RETURNING *;`;
|
);
|
||||||
try {
|
|
||||||
const entries = await pg.query(q);
|
|
||||||
const {
|
|
||||||
name,
|
|
||||||
host, // Should always read the database value
|
|
||||||
server_type: serverType,
|
|
||||||
storage,
|
|
||||||
extra_ports: extraPorts,
|
|
||||||
backup_enabled: backupEnabled,
|
|
||||||
backup_host: backupHost,
|
|
||||||
backup_bucket_path: backupPath,
|
|
||||||
backup_id: backupId,
|
|
||||||
backup_key: backupKey,
|
|
||||||
backup_interval: backupInterval,
|
|
||||||
} = entries[0];
|
|
||||||
|
|
||||||
const mclName = getMclName(host, id);
|
return pg.query(q);
|
||||||
|
|
||||||
return {
|
|
||||||
name, // Could change
|
|
||||||
mclName, // Shouldn't change
|
|
||||||
id, // Won't change
|
|
||||||
host, // TODO: Can only be updated if service name is generic and non descriptive, this returns the host from the database
|
|
||||||
version,
|
|
||||||
serverType,
|
|
||||||
cpu, // TODO: Ignored for now by the K8S manifests
|
|
||||||
memory,
|
|
||||||
storage,
|
|
||||||
extraPorts,
|
|
||||||
backupEnabled,
|
|
||||||
backupHost,
|
|
||||||
backupPath,
|
|
||||||
backupId,
|
|
||||||
backupKey,
|
|
||||||
backupInterval,
|
|
||||||
};
|
|
||||||
} catch (e) {
|
|
||||||
asExpressClientError(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getServerEntries() {
|
export async function getServerEntries() {
|
||||||
|
|
|
@ -6,7 +6,7 @@ env:
|
||||||
image: garethflowers/ftp-server
|
image: garethflowers/ftp-server
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
livenessProbe:
|
livenessProbe:
|
||||||
exec: { command: ["/bin/sh", "-c", "netstat -a | grep -q ftp"] }
|
exec: { command: ["echo"] }
|
||||||
failureThreshold: 20
|
failureThreshold: 20
|
||||||
initialDelaySeconds: 0
|
initialDelaySeconds: 0
|
||||||
periodSeconds: 5
|
periodSeconds: 5
|
||||||
|
@ -15,7 +15,7 @@ livenessProbe:
|
||||||
name: changeme-name-ftp
|
name: changeme-name-ftp
|
||||||
ports: [] # Programatically add all the ports for easier readability, Ports include: 20,21,40000-400009
|
ports: [] # Programatically add all the ports for easier readability, Ports include: 20,21,40000-400009
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
exec: { command: ["/bin/sh", "-c", "netstat -a | grep -q ftp"] }
|
exec: { command: ["echo"] }
|
||||||
failureThreshold: 20
|
failureThreshold: 20
|
||||||
initialDelaySeconds: 0
|
initialDelaySeconds: 0
|
||||||
periodSeconds: 5
|
periodSeconds: 5
|
||||||
|
|
|
@ -20,4 +20,4 @@ spec:
|
||||||
selector:
|
selector:
|
||||||
app: changeme-app
|
app: changeme-app
|
||||||
sessionAffinity: None
|
sessionAffinity: None
|
||||||
type: LoadBalancer
|
type: ClusterIP
|
||||||
|
|
|
@ -30,13 +30,11 @@ spec:
|
||||||
# runAsUser: 1000
|
# runAsUser: 1000
|
||||||
terminationGracePeriodSeconds: 30
|
terminationGracePeriodSeconds: 30
|
||||||
volumes:
|
volumes:
|
||||||
- emptyDir: {}
|
- name: datadir
|
||||||
name: datadir
|
persistentVolumeClaim:
|
||||||
|
claimName: changeme-pvc-name
|
||||||
- emptyDir: {}
|
- emptyDir: {}
|
||||||
name: backupdir
|
name: backupdir
|
||||||
# - name: datadir
|
|
||||||
# persistentVolumeClaim:
|
|
||||||
# claimName: changeme-pvc-name
|
|
||||||
# - name: rclone-config
|
# - name: rclone-config
|
||||||
# secret:
|
# secret:
|
||||||
# defaultMode: 420
|
# defaultMode: 420
|
||||||
|
|
|
@ -11,6 +11,8 @@ metadata:
|
||||||
namespace: changeme-namespace
|
namespace: changeme-namespace
|
||||||
spec:
|
spec:
|
||||||
internalTrafficPolicy: Cluster
|
internalTrafficPolicy: Cluster
|
||||||
|
ipFamilies:
|
||||||
|
- IPv4
|
||||||
ipFamilyPolicy: SingleStack
|
ipFamilyPolicy: SingleStack
|
||||||
ports: # Programatically add all FTP ports. Port range includes 20, 21, 40000-40001
|
ports: # Programatically add all FTP ports. Port range includes 20, 21, 40000-40001
|
||||||
- name: minecraft
|
- name: minecraft
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
import k8s from "@kubernetes/client-node";
|
|
||||||
const MCL_KUBECONFIG = process.env.MCL_KUBECONFIG;
|
|
||||||
const envConfig = MCL_KUBECONFIG ? MCL_KUBECONFIG : null;
|
|
||||||
const kc = new k8s.KubeConfig();
|
|
||||||
try {
|
|
||||||
if (!!envConfig)
|
|
||||||
kc.loadFromString(Buffer.from(envConfig, "base64").toString("utf8"));
|
|
||||||
else kc.loadFromDefault();
|
|
||||||
} catch (e) {
|
|
||||||
kc.loadFromDefault();
|
|
||||||
}
|
|
||||||
if(kc.contexts.length === 1) kc.setCurrentContext(kc.contexts[0].name);
|
|
||||||
if(!kc.currentContext) throw new Error("Could not infer current context! Please set it manually in the Kubeconfig!");
|
|
||||||
export default kc;
|
|
|
@ -7,8 +7,8 @@ import {
|
||||||
getCoreServerContainer,
|
getCoreServerContainer,
|
||||||
getBackupContainer,
|
getBackupContainer,
|
||||||
} from "./server-containers.js";
|
} from "./server-containers.js";
|
||||||
import { checkAuthorization } from "../database/queries/server-queries.js";
|
const kc = new k8s.KubeConfig();
|
||||||
import kc from "./k8s-config.js";
|
kc.loadFromDefault();
|
||||||
|
|
||||||
const k8sDeps = kc.makeApiClient(k8s.AppsV1Api);
|
const k8sDeps = kc.makeApiClient(k8s.AppsV1Api);
|
||||||
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
|
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
|
||||||
|
@ -25,20 +25,6 @@ const mineclusterManaged = (o) =>
|
||||||
export const serverMatch = (serverId) => (o) =>
|
export const serverMatch = (serverId) => (o) =>
|
||||||
o.metadata.annotations["minecluster.dunemask.net/id"] === serverId;
|
o.metadata.annotations["minecluster.dunemask.net/id"] === serverId;
|
||||||
|
|
||||||
export const cairoMatch = (cairoId) => (o) =>
|
|
||||||
checkAuthorization(
|
|
||||||
o.metadata.annotations["minecluster.dunemask.net/id"],
|
|
||||||
cairoId,
|
|
||||||
);
|
|
||||||
|
|
||||||
export async function getUserDeployments(cairoId) {
|
|
||||||
const authFIlter = cairoMatch(cairoId);
|
|
||||||
const allDeployments = await getDeployments();
|
|
||||||
const authChecks = allDeployments.map(authFIlter);
|
|
||||||
const authorizations = await Promise.all(authChecks);
|
|
||||||
return allDeployments.filter((_d, i) => authorizations[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getDeployments() {
|
export async function getDeployments() {
|
||||||
const deploymentRes = await k8sDeps.listNamespacedDeployment(namespace);
|
const deploymentRes = await k8sDeps.listNamespacedDeployment(namespace);
|
||||||
const serverDeployments = deploymentRes.body.items.filter(mineclusterManaged);
|
const serverDeployments = deploymentRes.body.items.filter(mineclusterManaged);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import yaml from "js-yaml";
|
||||||
const loadYaml = (f) => yaml.load(fs.readFileSync(path.resolve(f), "utf8"));
|
const loadYaml = (f) => yaml.load(fs.readFileSync(path.resolve(f), "utf8"));
|
||||||
|
|
||||||
export function getFtpContainer(serverSpec) {
|
export function getFtpContainer(serverSpec) {
|
||||||
const { mclName, storage } = serverSpec;
|
const { mclName } = serverSpec;
|
||||||
const ftpContainer = loadYaml("lib/k8s/configs/containers/ftp-server.yml");
|
const ftpContainer = loadYaml("lib/k8s/configs/containers/ftp-server.yml");
|
||||||
ftpContainer.name = `mcl-${mclName}-ftp`;
|
ftpContainer.name = `mcl-${mclName}-ftp`;
|
||||||
const ftpPortList = [
|
const ftpPortList = [
|
||||||
|
@ -18,12 +18,11 @@ export function getFtpContainer(serverSpec) {
|
||||||
name,
|
name,
|
||||||
protocol: "TCP",
|
protocol: "TCP",
|
||||||
}));
|
}));
|
||||||
if (!storage) delete ftpContainer.volumeMounts;
|
|
||||||
return ftpContainer;
|
return ftpContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCoreServerContainer(serverSpec) {
|
export function getCoreServerContainer(serverSpec) {
|
||||||
const { mclName, version, serverType, memory, storage } = serverSpec;
|
const { mclName, version, serverType, memory } = serverSpec;
|
||||||
const container = loadYaml("lib/k8s/configs/containers/minecraft-server.yml");
|
const container = loadYaml("lib/k8s/configs/containers/minecraft-server.yml");
|
||||||
// Container Updates
|
// Container Updates
|
||||||
container.name = `mcl-${mclName}-server`;
|
container.name = `mcl-${mclName}-server`;
|
||||||
|
@ -39,21 +38,12 @@ export function getCoreServerContainer(serverSpec) {
|
||||||
// RCON
|
// RCON
|
||||||
const rs = `mcl-${mclName}-rcon-secret`;
|
const rs = `mcl-${mclName}-rcon-secret`;
|
||||||
findEnv("RCON_PASSWORD").valueFrom.secretKeyRef.name = rs;
|
findEnv("RCON_PASSWORD").valueFrom.secretKeyRef.name = rs;
|
||||||
if (!storage) delete container.volumeMounts;
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getServerContainer(serverSpec) {
|
export function getServerContainer(serverSpec) {
|
||||||
const {
|
const { difficulty, gamemode, motd, maxPlayers, seed, ops, whitelist } =
|
||||||
difficulty,
|
serverSpec;
|
||||||
gamemode,
|
|
||||||
motd,
|
|
||||||
maxPlayers,
|
|
||||||
seed,
|
|
||||||
ops,
|
|
||||||
whitelist,
|
|
||||||
storage,
|
|
||||||
} = serverSpec;
|
|
||||||
const container = getCoreServerContainer(serverSpec);
|
const container = getCoreServerContainer(serverSpec);
|
||||||
|
|
||||||
const findEnv = (k) => container.env.find(({ name: n }) => n === k);
|
const findEnv = (k) => container.env.find(({ name: n }) => n === k);
|
||||||
|
@ -67,13 +57,12 @@ export function getServerContainer(serverSpec) {
|
||||||
updateEnv("SEED", seed);
|
updateEnv("SEED", seed);
|
||||||
updateEnv("OPS", ops);
|
updateEnv("OPS", ops);
|
||||||
updateEnv("WHITELIST", whitelist); */
|
updateEnv("WHITELIST", whitelist); */
|
||||||
if (!storage) delete container.volumeMounts;
|
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBackupContainer(serverSpec) {
|
export function getBackupContainer(serverSpec) {
|
||||||
const { mclName, backupEnabled, backupPath, storage } = serverSpec;
|
const { mclName, backupEnabled, backupPath } = serverSpec;
|
||||||
const container = loadYaml("lib/k8s/configs/containers/minecraft-backup.yml");
|
const container = loadYaml("lib/k8s/configs/containers/minecraft-backup.yml");
|
||||||
if (!backupEnabled) return;
|
if (!backupEnabled) return;
|
||||||
const findEnv = (k) => container.env.find(({ name: n }) => n === k);
|
const findEnv = (k) => container.env.find(({ name: n }) => n === k);
|
||||||
|
@ -84,7 +73,6 @@ export function getBackupContainer(serverSpec) {
|
||||||
// RCON
|
// RCON
|
||||||
const rs = `mcl-${mclName}-rcon-secret`;
|
const rs = `mcl-${mclName}-rcon-secret`;
|
||||||
findEnv("RCON_PASSWORD").valueFrom.secretKeyRef.name = rs;
|
findEnv("RCON_PASSWORD").valueFrom.secretKeyRef.name = rs;
|
||||||
if (!storage) delete container.volumeMounts;
|
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,15 @@ import {
|
||||||
getBackupContainer,
|
getBackupContainer,
|
||||||
} from "./server-containers.js";
|
} from "./server-containers.js";
|
||||||
|
|
||||||
import kc from "./k8s-config.js";
|
const kc = new k8s.KubeConfig();
|
||||||
|
kc.loadFromDefault();
|
||||||
const k8sDeps = kc.makeApiClient(k8s.AppsV1Api);
|
const k8sDeps = kc.makeApiClient(k8s.AppsV1Api);
|
||||||
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
|
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
|
||||||
const namespace = process.env.MCL_SERVER_NAMESPACE;
|
const namespace = process.env.MCL_SERVER_NAMESPACE;
|
||||||
|
|
||||||
const loadYaml = (f) => yaml.load(fs.readFileSync(path.resolve(f), "utf8"));
|
const loadYaml = (f) => yaml.load(fs.readFileSync(path.resolve(f), "utf8"));
|
||||||
|
|
||||||
export function createExtraService(serverSpec) {
|
function createExtraService(serverSpec) {
|
||||||
const { mclName, id, extraPorts } = serverSpec;
|
const { mclName, id, extraPorts } = serverSpec;
|
||||||
if (!extraPorts) return;
|
if (!extraPorts) return;
|
||||||
const serviceYaml = loadYaml("lib/k8s/configs/extra-svc.yml");
|
const serviceYaml = loadYaml("lib/k8s/configs/extra-svc.yml");
|
||||||
|
@ -49,7 +50,7 @@ export function createExtraService(serverSpec) {
|
||||||
return serviceYaml;
|
return serviceYaml;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createBackupSecret(serverSpec) {
|
function createBackupSecret(serverSpec) {
|
||||||
if (!serverSpec.backupEnabled) return; // If backup not defined, don't create RCLONE secret
|
if (!serverSpec.backupEnabled) return; // If backup not defined, don't create RCLONE secret
|
||||||
const { mclName, id, backupId, backupKey, backupHost } = serverSpec;
|
const { mclName, id, backupId, backupKey, backupHost } = serverSpec;
|
||||||
const backupYaml = loadYaml("lib/k8s/configs/backup-secret.yml");
|
const backupYaml = loadYaml("lib/k8s/configs/backup-secret.yml");
|
||||||
|
@ -66,8 +67,6 @@ export function createBackupSecret(serverSpec) {
|
||||||
`secret_access_key = ${backupKey}`,
|
`secret_access_key = ${backupKey}`,
|
||||||
`endpoint = ${backupHost}`,
|
`endpoint = ${backupHost}`,
|
||||||
`acl = private`,
|
`acl = private`,
|
||||||
`no_check_bucket = true`,
|
|
||||||
`no_check_container = true`,
|
|
||||||
].join("\n");
|
].join("\n");
|
||||||
backupYaml.data["rclone.conf"] = Buffer.from(rcloneConfig).toString("base64");
|
backupYaml.data["rclone.conf"] = Buffer.from(rcloneConfig).toString("base64");
|
||||||
return backupYaml;
|
return backupYaml;
|
||||||
|
@ -87,19 +86,18 @@ function createRconSecret(serverSpec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function createServerVolume(serverSpec) {
|
function createServerVolume(serverSpec) {
|
||||||
const { mclName, id, storage } = serverSpec;
|
const { mclName, id } = serverSpec;
|
||||||
if (!storage) return;
|
|
||||||
const volumeYaml = loadYaml("lib/k8s/configs/server-pvc.yml");
|
const volumeYaml = loadYaml("lib/k8s/configs/server-pvc.yml");
|
||||||
volumeYaml.metadata.labels.service = `mcl-${mclName}-server`;
|
volumeYaml.metadata.labels.service = `mcl-${mclName}-server`;
|
||||||
volumeYaml.metadata.name = `mcl-${mclName}-volume`;
|
volumeYaml.metadata.name = `mcl-${mclName}-volume`;
|
||||||
volumeYaml.metadata.namespace = namespace;
|
volumeYaml.metadata.namespace = namespace;
|
||||||
volumeYaml.metadata.annotations["minecluster.dunemask.net/id"] = id;
|
volumeYaml.metadata.annotations["minecluster.dunemask.net/id"] = id;
|
||||||
volumeYaml.spec.resources.requests.storage = `${storage}Gi`;
|
volumeYaml.spec.resources.requests.storage = "5Gi"; // TODO: Changeme
|
||||||
return volumeYaml;
|
return volumeYaml;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createServerDeploy(serverSpec) {
|
function createServerDeploy(serverSpec) {
|
||||||
const { mclName, id, backupEnabled, storage } = serverSpec;
|
const { mclName, id, backupEnabled } = serverSpec;
|
||||||
const deployYaml = loadYaml("lib/k8s/configs/server-deployment.yml");
|
const deployYaml = loadYaml("lib/k8s/configs/server-deployment.yml");
|
||||||
const { metadata } = deployYaml;
|
const { metadata } = deployYaml;
|
||||||
const serverContainer = getServerContainer(serverSpec);
|
const serverContainer = getServerContainer(serverSpec);
|
||||||
|
@ -121,18 +119,9 @@ function createServerDeploy(serverSpec) {
|
||||||
id;
|
id;
|
||||||
|
|
||||||
// Volumes
|
// Volumes
|
||||||
if (!!storage) {
|
deployYaml.spec.template.spec.volumes.find(
|
||||||
const dvi = deployYaml.spec.template.spec.volumes.findIndex(
|
|
||||||
({ name }) => name === "datadir",
|
({ name }) => name === "datadir",
|
||||||
);
|
).persistentVolumeClaim.claimName = `mcl-${mclName}-volume`;
|
||||||
delete deployYaml.spec.template.spec.volumes[dvi].emptyDir;
|
|
||||||
deployYaml.spec.template.spec.volumes[dvi] = {
|
|
||||||
...deployYaml.spec.template.spec.volumes[dvi],
|
|
||||||
persistentVolumeClaim: {
|
|
||||||
claimName: `mcl-${mclName}-volume`,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Backups
|
// Backups
|
||||||
if (backupEnabled) {
|
if (backupEnabled) {
|
||||||
|
@ -153,7 +142,7 @@ function createServerDeploy(serverSpec) {
|
||||||
return deployYaml;
|
return deployYaml;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createServerService(serverSpec) {
|
function createServerService(serverSpec) {
|
||||||
const { mclName, host, id } = serverSpec;
|
const { mclName, host, id } = serverSpec;
|
||||||
const serviceYaml = loadYaml("lib/k8s/configs/server-svc.yml");
|
const serviceYaml = loadYaml("lib/k8s/configs/server-svc.yml");
|
||||||
serviceYaml.metadata.annotations["ingress.qumine.io/hostname"] = host;
|
serviceYaml.metadata.annotations["ingress.qumine.io/hostname"] = host;
|
||||||
|
@ -205,7 +194,6 @@ export default async function createServerResources(createSpec) {
|
||||||
const rconService = createRconService(createSpec);
|
const rconService = createRconService(createSpec);
|
||||||
const extraService = createExtraService(createSpec);
|
const extraService = createExtraService(createSpec);
|
||||||
const serverResources = [];
|
const serverResources = [];
|
||||||
if (!!serverVolume)
|
|
||||||
serverResources.push(
|
serverResources.push(
|
||||||
k8sCore.createNamespacedPersistentVolumeClaim(namespace, serverVolume),
|
k8sCore.createNamespacedPersistentVolumeClaim(namespace, serverVolume),
|
||||||
);
|
);
|
||||||
|
|
|
@ -2,7 +2,8 @@ import k8s from "@kubernetes/client-node";
|
||||||
import { ERR } from "../util/logging.js";
|
import { ERR } from "../util/logging.js";
|
||||||
import { getServerAssets } from "./k8s-server-control.js";
|
import { getServerAssets } from "./k8s-server-control.js";
|
||||||
import ExpressClientError from "../util/ExpressClientError.js";
|
import ExpressClientError from "../util/ExpressClientError.js";
|
||||||
import kc from "./k8s-config.js";
|
const kc = new k8s.KubeConfig();
|
||||||
|
kc.loadFromDefault();
|
||||||
|
|
||||||
const k8sDeps = kc.makeApiClient(k8s.AppsV1Api);
|
const k8sDeps = kc.makeApiClient(k8s.AppsV1Api);
|
||||||
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
|
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
|
||||||
|
|
|
@ -2,8 +2,7 @@ import ftp from "basic-ftp";
|
||||||
import { ERR } from "../util/logging.js";
|
import { ERR } from "../util/logging.js";
|
||||||
import { getServerAssets } from "./k8s-server-control.js";
|
import { getServerAssets } from "./k8s-server-control.js";
|
||||||
import ExpressClientError from "../util/ExpressClientError.js";
|
import ExpressClientError from "../util/ExpressClientError.js";
|
||||||
import { Readable, Transform } from "node:stream";
|
import { Readable, Writable, Transform } from "node:stream";
|
||||||
import { dirname, basename } from "node:path";
|
|
||||||
|
|
||||||
const namespace = process.env.MCL_SERVER_NAMESPACE;
|
const namespace = process.env.MCL_SERVER_NAMESPACE;
|
||||||
|
|
||||||
|
@ -83,27 +82,16 @@ export async function uploadServerItem(serverSpec, file) {
|
||||||
const { path } = serverSpec;
|
const { path } = serverSpec;
|
||||||
pathSecurityCheck(path);
|
pathSecurityCheck(path);
|
||||||
await useServerFtp(serverSpec, async (c) => {
|
await useServerFtp(serverSpec, async (c) => {
|
||||||
await c.ensureDir(dirname(path));
|
await c.uploadFrom(fileStream, path);
|
||||||
await c.uploadFrom(fileStream, basename(path));
|
|
||||||
}).catch(handleError);
|
}).catch(handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getServerItem(serverSpec) {
|
export async function getServerItem(serverSpec, writableStream) {
|
||||||
const { path } = serverSpec;
|
const { path } = serverSpec;
|
||||||
const ds = new Transform({ transform: (c, _e, cb) => cb(null, c) });
|
const ds = new Transform({ transform: (c, e, cb) => cb(null, c) });
|
||||||
pathSecurityCheck(path);
|
pathSecurityCheck(path);
|
||||||
const ftpTransfer = useServerFtp(serverSpec, async (c) => {
|
const ftpTransfer = useServerFtp(serverSpec, async (c) => {
|
||||||
await c.downloadTo(ds, path);
|
await c.downloadTo(ds, path);
|
||||||
}).catch(handleError);
|
}).catch(handleError);
|
||||||
return { ds, ftpTransfer };
|
return { ds, ftpTransfer };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function moveServerItems(serverSpec) {
|
|
||||||
const { destination, origin, files } = serverSpec;
|
|
||||||
useServerFtp(serverSpec, async (c) =>
|
|
||||||
Promise.all(
|
|
||||||
files.map((f) => c.rename(`${origin}/${f}`, `${destination}/${f}`)),
|
|
||||||
),
|
|
||||||
).catch(handleError);
|
|
||||||
return files;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,59 +0,0 @@
|
||||||
import k8s from "@kubernetes/client-node";
|
|
||||||
import {
|
|
||||||
createExtraService,
|
|
||||||
createBackupSecret,
|
|
||||||
createServerService,
|
|
||||||
} from "./server-create.js";
|
|
||||||
import kc from "./k8s-config.js";
|
|
||||||
import { getServerAssets } from "./k8s-server-control.js";
|
|
||||||
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
|
|
||||||
const namespace = process.env.MCL_SERVER_NAMESPACE;
|
|
||||||
|
|
||||||
export default async function modifyServerResources(modifySpec) {
|
|
||||||
const { id: serverId } = modifySpec;
|
|
||||||
const serverAssets = await getServerAssets(serverId);
|
|
||||||
const serverService = createServerService(modifySpec);
|
|
||||||
const extraService = createExtraService(modifySpec);
|
|
||||||
const backupSecret = createBackupSecret(modifySpec);
|
|
||||||
const serverResources = [];
|
|
||||||
|
|
||||||
if (!!serverService)
|
|
||||||
// Will Always Exist
|
|
||||||
serverResources.push(
|
|
||||||
k8sCore.replaceNamespacedService(
|
|
||||||
serverAssets.service.metadata.name,
|
|
||||||
namespace,
|
|
||||||
serverService,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!!extraService && !!serverAssets.extraService)
|
|
||||||
// Might not exist
|
|
||||||
serverResources.push(
|
|
||||||
k8sCore.replaceNamespacedService(
|
|
||||||
serverAssets.extraService.metadata.name,
|
|
||||||
namespace,
|
|
||||||
extraService,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
else if (!!extraService)
|
|
||||||
serverResources.push(
|
|
||||||
k8sCore.createNamespacedService(namespace, extraService),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!!backupSecret && !!serverAssets.backupSecret)
|
|
||||||
// Might not exist
|
|
||||||
serverResources.push(
|
|
||||||
k8sCore.replaceNamespacedSecret(
|
|
||||||
serverAssets.backupSecret.metadata.name,
|
|
||||||
namespace,
|
|
||||||
backupSecret,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
else if (!!backupSecret)
|
|
||||||
serverResources.push(
|
|
||||||
k8sCore.createNamespacedSecret(namespace, backupSecret),
|
|
||||||
);
|
|
||||||
|
|
||||||
return await Promise.all(serverResources);
|
|
||||||
}
|
|
|
@ -1,7 +1,8 @@
|
||||||
import k8s from "@kubernetes/client-node";
|
import k8s from "@kubernetes/client-node";
|
||||||
import { getUserDeployments } from "./k8s-server-control.js";
|
import { getDeployments } from "./k8s-server-control.js";
|
||||||
import { getServerEntries } from "../database/queries/server-queries.js";
|
import { getServerEntries } from "../database/queries/server-queries.js";
|
||||||
import kc from "./k8s-config.js";
|
const kc = new k8s.KubeConfig();
|
||||||
|
kc.loadFromDefault();
|
||||||
|
|
||||||
const k8sMetrics = new k8s.Metrics(kc);
|
const k8sMetrics = new k8s.Metrics(kc);
|
||||||
const namespace = process.env.MCL_SERVER_NAMESPACE;
|
const namespace = process.env.MCL_SERVER_NAMESPACE;
|
||||||
|
@ -38,12 +39,12 @@ function getServerStatus(server) {
|
||||||
) !== undefined;
|
) !== undefined;
|
||||||
const serverAvailable = services.includes(`server`) && deploymentAvailable;
|
const serverAvailable = services.includes(`server`) && deploymentAvailable;
|
||||||
const ftpAvailable = services.includes("ftp"); // TODO this needs some handling for container creation
|
const ftpAvailable = services.includes("ftp"); // TODO this needs some handling for container creation
|
||||||
return { serverAvailable, ftpAvailable, services, deploymentAvailable };
|
return { serverAvailable, ftpAvailable, services };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getInstances(cairoId) {
|
export async function getInstances() {
|
||||||
const [serverDeployments, podMetricsRes, entries] = await Promise.all([
|
const [serverDeployments, podMetricsRes, entries] = await Promise.all([
|
||||||
getUserDeployments(cairoId),
|
getDeployments(),
|
||||||
k8sMetrics.getPodMetrics(namespace),
|
k8sMetrics.getPodMetrics(namespace),
|
||||||
getServerEntries(),
|
getServerEntries(),
|
||||||
]);
|
]);
|
||||||
|
@ -52,18 +53,15 @@ export async function getInstances(cairoId) {
|
||||||
const serverInstances = serverDeployments.map((s) => {
|
const serverInstances = serverDeployments.map((s) => {
|
||||||
serverId = s.metadata.annotations["minecluster.dunemask.net/id"];
|
serverId = s.metadata.annotations["minecluster.dunemask.net/id"];
|
||||||
const entry = entries.find((e) => e.id === serverId);
|
const entry = entries.find((e) => e.id === serverId);
|
||||||
const { ftpAvailable, serverAvailable, services, deploymentAvailable } =
|
const { ftpAvailable, serverAvailable, services } = getServerStatus(s);
|
||||||
getServerStatus(s);
|
|
||||||
metrics = getServerMetrics(podMetricsRes, serverId, serverAvailable);
|
metrics = getServerMetrics(podMetricsRes, serverId, serverAvailable);
|
||||||
return {
|
return {
|
||||||
name: !!entry ? entry.name : "Unknown",
|
name: !!entry ? entry.name : "Unknown",
|
||||||
host: !!entry ? entry.host : "Unkonwn",
|
|
||||||
id: serverId,
|
id: serverId,
|
||||||
metrics,
|
metrics,
|
||||||
services,
|
services,
|
||||||
serverAvailable,
|
serverAvailable,
|
||||||
ftpAvailable,
|
ftpAvailable,
|
||||||
deploymentAvailable,
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return serverInstances;
|
return serverInstances;
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { Router } from "express";
|
|
||||||
import cairoAuthMiddleware from "./middlewares/auth-middleware.js";
|
|
||||||
const router = Router();
|
|
||||||
|
|
||||||
const cairoProjectId = process.env.MCL_CAIRO_PROJECT;
|
|
||||||
if(!cairoProjectId) throw Error("Cairo Project Required!");
|
|
||||||
|
|
||||||
const ok = (_r, res) => res.sendStatus(200);
|
|
||||||
|
|
||||||
function cairoRedirect(req, res) {
|
|
||||||
res.redirect(
|
|
||||||
`${process.env.MCL_CAIRO_URL}/cairo/authenticate?redirectUri=${req.query.redirectUri}&projectId=${cairoProjectId}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
router.get("/verify", cairoAuthMiddleware, ok);
|
|
||||||
router.get("/redirect", cairoRedirect);
|
|
||||||
|
|
||||||
export default router;
|
|
|
@ -6,20 +6,16 @@ import {
|
||||||
listFiles,
|
listFiles,
|
||||||
uploadItem,
|
uploadItem,
|
||||||
getItem,
|
getItem,
|
||||||
moveItems,
|
|
||||||
} from "../controllers/file-controller.js";
|
} from "../controllers/file-controller.js";
|
||||||
|
|
||||||
import cairoAuthMiddleware from "./middlewares/auth-middleware.js";
|
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
router.use([jsonMiddleware(), cairoAuthMiddleware]);
|
router.use(jsonMiddleware());
|
||||||
const multerMiddleware = multer();
|
const multerMiddleware = multer();
|
||||||
|
|
||||||
router.post("/list", listFiles);
|
router.post("/list", listFiles);
|
||||||
router.post("/folder", createFolder);
|
router.post("/folder", createFolder);
|
||||||
router.delete("/item", deleteItem);
|
router.delete("/item", deleteItem);
|
||||||
router.post("/item", getItem);
|
router.post("/item", getItem);
|
||||||
router.post("/move", moveItems);
|
|
||||||
router.post("/upload", multerMiddleware.single("file"), uploadItem);
|
router.post("/upload", multerMiddleware.single("file"), uploadItem);
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
// Imports
|
|
||||||
import { Router } from "express";
|
|
||||||
import bearerTokenMiddleware from "express-bearer-token";
|
|
||||||
import { ERR, VERB } from "../../util/logging.js";
|
|
||||||
|
|
||||||
// Constants
|
|
||||||
const { MCL_CAIRO_URL, MCL_CAIRO_PROJECT } = process.env;
|
|
||||||
const cairoAuthMiddleware = Router();
|
|
||||||
|
|
||||||
const cairoAuthenticate = async (token) => {
|
|
||||||
const config = { headers: { Authorization: `Bearer ${token}` } };
|
|
||||||
return fetch(`${MCL_CAIRO_URL}/api/${MCL_CAIRO_PROJECT}/auth/credentials`, config).then(async (res) => {
|
|
||||||
if (res.status >= 300) {
|
|
||||||
const errorMessage = await res
|
|
||||||
.json()
|
|
||||||
.then((data) => JSON.stringify(data))
|
|
||||||
.catch(() => res.statusText);
|
|
||||||
throw Error(
|
|
||||||
`Could not authenticate with user, receieved message: ${errorMessage}`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res.json();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Middleware
|
|
||||||
const cairoAuthHandler = (req, res, next) => {
|
|
||||||
if (!req.token) return res.status(401).send("Cairo auth required!");
|
|
||||||
cairoAuthenticate(req.token)
|
|
||||||
.then((authData) => {
|
|
||||||
console.log(authData);
|
|
||||||
if (!authData?.user?.id)
|
|
||||||
throw Error(`Cairo didn't return the expected data! ${authData?.user?.id}`);
|
|
||||||
req.cairoId = authData?.user?.id;
|
|
||||||
})
|
|
||||||
.then(() => next())
|
|
||||||
.catch((err) => {
|
|
||||||
ERR("AUTH", err.response ? err.response.data : err.message);
|
|
||||||
if (!err.response) return res.status(500).send(`Auth failure ${err}`);
|
|
||||||
return res.status(err.response.status).send(err.response.data);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
cairoAuthMiddleware.use([bearerTokenMiddleware(), cairoAuthHandler]);
|
|
||||||
|
|
||||||
export default cairoAuthMiddleware;
|
|
|
@ -1,11 +0,0 @@
|
||||||
import { Router, json as jsonMiddleware } from "express";
|
|
||||||
import { getS3BackupUrl, listS3Backups } from "../controllers/s3-controller.js";
|
|
||||||
import cairoAuthMiddleware from "./middlewares/auth-middleware.js";
|
|
||||||
|
|
||||||
const router = Router();
|
|
||||||
router.use([cairoAuthMiddleware, jsonMiddleware()]);
|
|
||||||
|
|
||||||
router.post("/backups", listS3Backups);
|
|
||||||
router.post("/backup-url", getS3BackupUrl);
|
|
||||||
|
|
||||||
export default router;
|
|
|
@ -11,11 +11,8 @@ import {
|
||||||
serverInstances,
|
serverInstances,
|
||||||
serverList,
|
serverList,
|
||||||
} from "../controllers/status-controller.js";
|
} from "../controllers/status-controller.js";
|
||||||
|
|
||||||
import cairoAuthMiddleware from "./middlewares/auth-middleware.js";
|
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
router.use([jsonMiddleware(), cairoAuthMiddleware]);
|
router.use(jsonMiddleware());
|
||||||
// Routes
|
// Routes
|
||||||
router.post("/create", createServer);
|
router.post("/create", createServer);
|
||||||
router.delete("/delete", deleteServer);
|
router.delete("/delete", deleteServer);
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
import k8s from "@kubernetes/client-node";
|
import k8s from "@kubernetes/client-node";
|
||||||
import { WARN } from "../util/logging.js";
|
import { WARN } from "../util/logging.js";
|
||||||
import kc from "../k8s/k8s-config.js";
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
const kc = new k8s.KubeConfig();
|
||||||
import cairoAuthMiddleware from "./middlewares/auth-middleware.js";
|
kc.loadFromDefault();
|
||||||
router.use(cairoAuthMiddleware);
|
|
||||||
|
|
||||||
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
|
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
|
||||||
// Get Routes
|
// Get Routes
|
||||||
router.get("/available", (req, res) => {
|
router.get("/available", (req, res) => {
|
||||||
|
|
|
@ -3,12 +3,10 @@ import express from "express";
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
import vitals from "../routes/vitals-route.js";
|
import vitals from "../routes/vitals-route.js";
|
||||||
import authRoute from "../routes/auth-route.js";
|
|
||||||
import systemRoute from "../routes/system-route.js";
|
import systemRoute from "../routes/system-route.js";
|
||||||
import serverRoute from "../routes/server-route.js";
|
import serverRoute from "../routes/server-route.js";
|
||||||
import filesRoute from "../routes/files-route.js";
|
import filesRoute from "../routes/files-route.js";
|
||||||
import reactRoute from "../routes/react-route.js";
|
import reactRoute from "../routes/react-route.js";
|
||||||
import s3Route from "../routes/s3-route.js";
|
|
||||||
import {
|
import {
|
||||||
logErrors,
|
logErrors,
|
||||||
clientErrorHandler,
|
clientErrorHandler,
|
||||||
|
@ -24,11 +22,9 @@ export default function buildRoutes(pg, skio) {
|
||||||
// Middlewares
|
// Middlewares
|
||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
router.use("/api/auth", authRoute);
|
|
||||||
router.use("/api/system", systemRoute);
|
router.use("/api/system", systemRoute);
|
||||||
router.use("/api/server", serverRoute);
|
router.use("/api/server", serverRoute);
|
||||||
router.use("/api/files", filesRoute);
|
router.use("/api/files", filesRoute);
|
||||||
router.use("/api/s3", s3Route);
|
|
||||||
router.use(["/mcl", "/mcl/*"], reactRoute); // Static Build Route
|
router.use(["/mcl", "/mcl/*"], reactRoute); // Static Build Route
|
||||||
/*router.use(logErrors);
|
/*router.use(logErrors);
|
||||||
router.use(clientErrorHandler);
|
router.use(clientErrorHandler);
|
||||||
|
|
34
lib/storage/s3-integration.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import multer from "multer";
|
||||||
|
import multerS3 from "multer-s3";
|
||||||
|
import AWS from "aws-sdk";
|
||||||
|
|
||||||
|
// Environment Variables
|
||||||
|
const {
|
||||||
|
MCL_S3_ENDPOINT: s3Endpoint,
|
||||||
|
MCL_S3_ACCESS_KEY_ID: s3KeyId,
|
||||||
|
MCL_S3_ACCESS_KEY: s3Key,
|
||||||
|
} = process.env;
|
||||||
|
|
||||||
|
export const mcl = "mcl";
|
||||||
|
|
||||||
|
export const s3 = new AWS.S3({
|
||||||
|
endpoint: s3Endpoint,
|
||||||
|
accessKeyId: s3KeyId,
|
||||||
|
secretAccessKey: s3Key,
|
||||||
|
sslEnabled: true,
|
||||||
|
s3ForcePathStyle: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const storage = multerS3({
|
||||||
|
s3,
|
||||||
|
bucket,
|
||||||
|
contentType: multerS3.AUTO_CONTENT_TYPE,
|
||||||
|
metadata: (req, file, cb) => {
|
||||||
|
cb(null, { fieldName: file.fieldname });
|
||||||
|
},
|
||||||
|
key: (req, file, cb) => {
|
||||||
|
cb(null, Date.now().toString());
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const upload = multer({ storage });
|
2515
package-lock.json
generated
33
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "minecluster",
|
"name": "minecluster",
|
||||||
"version": "0.0.1-alpha.1",
|
"version": "0.0.1-alpha.0",
|
||||||
"description": "Minecraft Server management using Kubernetes",
|
"description": "Minecraft Server management using Kubernetes",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
"start": "node dist/app.js",
|
"start": "node dist/app.js",
|
||||||
"dev:server": "nodemon dist/app.js",
|
"dev:server": "nodemon dist/app.js",
|
||||||
"dev:react": "vite",
|
"dev:react": "vite",
|
||||||
"lint": "npx prettier -w src lib vite.config.js",
|
"kub": "nodemon lib/k8s.js",
|
||||||
"start:dev": "concurrently -k \"MCL_DEV_PORT=52025 npm run dev:server\" \" MCL_VITE_DEV_PORT=52000 MCL_VITE_BACKEND_URL=http://localhost:52025 npm run dev:react\" -n s,v -p -c green,yellow",
|
"start:dev": "concurrently -k \"MCL_DEV_PORT=52025 npm run dev:server\" \" MCL_VITE_DEV_PORT=52000 MCL_VITE_BACKEND_URL=http://localhost:52025 npm run dev:react\" -n s,v -p -c green,yellow",
|
||||||
"start:dev:garden": "concurrently -k \"npm run dev:server\" \"npm run dev:react\" -n s,v -p -c green,yellow"
|
"start:dev:garden": "concurrently -k \"npm run dev:server\" \"npm run dev:react\" -n s,v -p -c green,yellow"
|
||||||
},
|
},
|
||||||
|
@ -22,44 +22,41 @@
|
||||||
"author": "Dunemask",
|
"author": "Dunemask",
|
||||||
"license": "LGPL-2.1",
|
"license": "LGPL-2.1",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@emotion/react": "^11.11.3",
|
"@emotion/react": "^11.11.1",
|
||||||
"@emotion/styled": "^11.11.0",
|
"@emotion/styled": "^11.11.0",
|
||||||
"@mui/icons-material": "^5.15.9",
|
"@mui/icons-material": "^5.14.19",
|
||||||
"@mui/material": "^5.15.9",
|
"@mui/material": "^5.14.20",
|
||||||
"@tanstack/react-query": "^5.20.1",
|
"@tanstack/react-query": "^5.12.2",
|
||||||
"@vitejs/plugin-react": "^4.2.1",
|
"@vitejs/plugin-react": "^4.2.1",
|
||||||
"chonky": "^2.3.2",
|
"chonky": "^2.3.2",
|
||||||
"chonky-icon-fontawesome": "^2.3.2",
|
"chonky-icon-fontawesome": "^2.3.2",
|
||||||
"concurrently": "^8.2.2",
|
"concurrently": "^8.2.2",
|
||||||
"nodemon": "^3.0.3",
|
"nodemon": "^3.0.2",
|
||||||
"prettier": "^3.2.5",
|
"prettier": "^3.1.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-quill": "^2.0.0",
|
"react-quill": "^2.0.0",
|
||||||
"react-router-dom": "^6.22.0",
|
"react-router-dom": "^6.20.1",
|
||||||
"react-toastify": "^10.0.4",
|
"react-toastify": "^9.1.3",
|
||||||
"socket.io-client": "^4.7.4",
|
"socket.io-client": "^4.7.2",
|
||||||
"vite": "^5.1.1"
|
"vite": "^5.0.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.529.1",
|
|
||||||
"@aws-sdk/s3-request-presigner": "^3.529.1",
|
|
||||||
"@kubernetes/client-node": "^0.20.0",
|
"@kubernetes/client-node": "^0.20.0",
|
||||||
|
"aws-sdk": "^2.1514.0",
|
||||||
"basic-ftp": "^5.0.4",
|
"basic-ftp": "^5.0.4",
|
||||||
"bcrypt": "^5.1.1",
|
"bcrypt": "^5.1.1",
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"express-bearer-token": "^2.4.0",
|
|
||||||
"figlet": "^1.7.0",
|
"figlet": "^1.7.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.29.4",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"multer-s3": "^3.0.1",
|
"multer-s3": "^3.0.1",
|
||||||
"pg-promise": "^11.5.4",
|
"pg-promise": "^11.5.4",
|
||||||
"postgres-migrations": "^5.3.0",
|
"postgres-migrations": "^5.3.0",
|
||||||
"rcon-client": "^4.2.4",
|
"rcon-client": "^4.2.4",
|
||||||
"react-dropzone": "^14.2.3",
|
"socket.io": "^4.7.2",
|
||||||
"socket.io": "^4.7.4",
|
|
||||||
"uuid": "^9.0.1"
|
"uuid": "^9.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Before Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 8 KiB |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 8 KiB |
|
@ -1,9 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<browserconfig>
|
|
||||||
<msapplication>
|
|
||||||
<tile>
|
|
||||||
<square150x150logo src="/icons/mstile-150x150.png?v=feb4-24-mineblock"/>
|
|
||||||
<TileColor>#00aba9</TileColor>
|
|
||||||
</tile>
|
|
||||||
</msapplication>
|
|
||||||
</browserconfig>
|
|
Before Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 854 B |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 5 KiB |
|
@ -1,252 +0,0 @@
|
||||||
<?xml version="1.0" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
|
||||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
|
||||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
|
||||||
width="512.000000pt" height="512.000000pt" viewBox="0 0 512.000000 512.000000"
|
|
||||||
preserveAspectRatio="xMidYMid meet">
|
|
||||||
<metadata>
|
|
||||||
Created by potrace 1.14, written by Peter Selinger 2001-2017
|
|
||||||
</metadata>
|
|
||||||
<g transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)"
|
|
||||||
fill="#000000" stroke="none">
|
|
||||||
<path d="M0 2560 l0 -2560 2560 0 2560 0 0 2560 0 2560 -2560 0 -2560 0 0
|
|
||||||
-2560z m2622 2261 c10 5 18 7 18 3 0 -3 8 0 17 7 11 10 14 10 9 2 -4 -7 -2
|
|
||||||
-14 3 -14 6 -1 17 -2 24 -3 6 -1 11 -7 10 -14 -3 -14 19 -12 29 3 5 6 8 3 8
|
|
||||||
-7 0 -9 -6 -19 -12 -21 -8 -3 -6 -6 5 -6 9 -1 17 5 17 13 0 17 33 27 51 15 8
|
|
||||||
-5 10 -9 4 -9 -5 0 1 -7 13 -16 13 -9 26 -13 29 -10 3 3 15 -1 26 -9 13 -9 27
|
|
||||||
-11 43 -5 17 7 27 5 37 -5 8 -8 17 -11 21 -8 3 4 6 1 6 -5 0 -5 -5 -12 -12
|
|
||||||
-14 -6 -2 -8 -10 -4 -17 6 -8 11 -9 21 -1 9 7 21 7 40 0 15 -6 32 -7 38 -3 7
|
|
||||||
3 9 3 5 -1 -4 -5 2 -17 12 -29 16 -17 22 -18 35 -7 13 11 14 10 8 -6 -6 -17
|
|
||||||
-5 -18 12 -4 12 10 16 10 11 2 -10 -17 13 -44 32 -37 8 3 16 -3 19 -15 3 -11
|
|
||||||
9 -21 14 -21 5 -1 13 -2 19 -3 5 0 15 -7 22 -13 6 -7 18 -13 26 -13 7 0 11 -4
|
|
||||||
8 -9 -3 -5 10 -12 29 -15 19 -4 35 -11 35 -17 0 -6 -6 -7 -12 -4 -7 4 -5 0 5
|
|
||||||
-8 9 -8 17 -19 17 -24 0 -6 8 -10 18 -10 23 1 67 -18 67 -29 0 -5 3 -8 7 -7 5
|
|
||||||
2 8 -1 8 -5 0 -4 23 -16 50 -26 28 -10 50 -22 50 -28 0 -18 76 -83 94 -80 10
|
|
||||||
2 27 -5 38 -15 12 -10 18 -12 14 -5 -4 6 -2 12 3 12 6 0 11 -6 11 -13 0 -7 9
|
|
||||||
-18 20 -25 12 -7 20 -23 20 -40 0 -20 3 -23 9 -13 8 12 15 9 37 -17 16 -18 34
|
|
||||||
-32 41 -32 7 0 23 -12 37 -26 15 -17 30 -25 41 -21 9 4 14 3 10 -3 -3 -6 1
|
|
||||||
-10 9 -10 9 0 13 -7 11 -17 -2 -13 4 -18 22 -20 15 0 36 -13 49 -30 49 -57
|
|
||||||
104 -113 114 -113 6 0 15 -11 20 -25 5 -14 16 -25 25 -25 8 0 15 -9 15 -20 0
|
|
||||||
-11 5 -20 10 -20 6 0 9 -3 8 -7 -6 -29 50 -103 78 -103 17 0 17 -1 -2 -15 -12
|
|
||||||
-9 -14 -14 -6 -15 7 0 11 -4 7 -9 -3 -6 4 -15 15 -21 18 -10 19 -14 8 -28 -10
|
|
||||||
-12 -10 -14 0 -8 6 4 12 2 12 -3 0 -6 7 -11 15 -11 9 0 12 -6 9 -15 -4 -8 -1
|
|
||||||
-22 6 -30 6 -8 9 -19 6 -24 -4 -5 -2 -12 4 -16 6 -4 8 -11 5 -16 -4 -5 -2 -9
|
|
||||||
3 -9 6 0 8 -10 4 -22 -4 -16 -2 -19 8 -13 10 6 12 3 8 -13 -4 -12 -3 -22 1
|
|
||||||
-22 3 0 6 -22 5 -50 -1 -27 2 -50 7 -50 5 0 9 -10 9 -23 0 -13 5 -28 10 -33
|
|
||||||
13 -13 22 -57 11 -50 -4 3 -8 -8 -7 -24 1 -17 6 -30 13 -30 19 0 27 -21 12
|
|
||||||
-31 -11 -8 -10 -12 5 -24 20 -15 20 -15 0 -15 -16 0 -17 -2 -4 -10 10 -6 11
|
|
||||||
-10 3 -10 -7 0 -13 -5 -13 -11 0 -5 5 -7 11 -3 8 5 10 -1 7 -20 -3 -14 -1 -26
|
|
||||||
3 -26 5 0 9 8 9 18 0 14 2 15 10 2 5 -8 5 -17 1 -20 -7 -4 -8 -135 -1 -135 1
|
|
||||||
0 4 -23 5 -52 2 -28 6 -57 10 -64 5 -7 4 -10 -2 -6 -6 4 -17 -1 -24 -10 -8 -9
|
|
||||||
-9 -14 -2 -10 6 4 19 0 28 -9 15 -15 15 -18 -1 -35 -10 -11 -12 -19 -6 -19 6
|
|
||||||
0 9 -7 6 -15 -5 -11 -1 -14 12 -9 18 5 18 5 2 -6 -10 -6 -18 -18 -18 -25 0
|
|
||||||
-18 12 -19 27 -4 9 9 10 6 6 -10 -4 -15 -11 -20 -22 -16 -8 3 -12 3 -9 -1 4
|
|
||||||
-4 3 -15 -2 -25 -12 -22 8 -39 21 -18 7 11 9 10 9 -3 0 -10 -5 -18 -10 -18 -6
|
|
||||||
0 -9 -12 -7 -27 2 -16 0 -43 -4 -60 -4 -19 -3 -30 2 -27 5 3 17 0 26 -5 15 -8
|
|
||||||
15 -11 3 -12 -8 -1 -21 -1 -27 0 -7 1 -13 -3 -13 -9 0 -5 5 -10 10 -10 6 0 10
|
|
||||||
-5 10 -11 0 -5 -4 -8 -9 -5 -5 4 -7 -4 -3 -16 4 -16 2 -19 -8 -13 -9 5 -11 4
|
|
||||||
-6 -3 5 -9 15 -7 34 5 24 16 26 16 14 1 -10 -13 -11 -22 -2 -40 10 -22 10 -22
|
|
||||||
-4 -4 -9 10 -22 16 -31 13 -18 -7 -20 -27 -3 -27 9 0 9 -3 0 -12 -7 -7 -12
|
|
||||||
-19 -12 -27 0 -14 1 -14 10 -1 12 19 13 8 0 -24 -5 -15 -6 -28 0 -31 5 -3 7
|
|
||||||
-12 4 -20 -4 -8 -11 -12 -17 -8 -6 4 -7 1 -1 -8 4 -8 9 -21 11 -29 1 -8 10
|
|
||||||
-21 20 -29 16 -12 16 -13 1 -8 -12 4 -21 -1 -28 -13 -8 -15 -8 -20 1 -20 7 0
|
|
||||||
4 -9 -7 -22 -10 -12 -13 -18 -5 -13 9 5 8 0 -3 -18 -19 -29 -29 -70 -15 -62 5
|
|
||||||
4 7 10 4 15 -3 4 2 13 9 19 11 9 16 9 22 0 4 -8 3 -9 -4 -5 -7 4 -12 1 -12 -8
|
|
||||||
0 -8 -6 -21 -12 -28 -15 -15 -18 -78 -4 -78 4 0 -2 -9 -15 -21 -13 -11 -18
|
|
||||||
-18 -11 -14 15 8 15 0 2 -26 -7 -13 -7 -19 0 -19 5 0 10 -4 10 -10 0 -5 -7
|
|
||||||
-10 -15 -10 -8 0 -15 -4 -15 -10 0 -12 6 -13 29 -1 13 8 17 5 18 -12 0 -12 -1
|
|
||||||
-16 -4 -9 -3 6 -9 12 -14 12 -6 0 -8 -4 -5 -8 3 -5 -4 -16 -15 -25 -21 -19
|
|
||||||
-26 -47 -7 -47 6 0 3 -7 -8 -16 -10 -8 -13 -13 -6 -9 6 3 12 1 12 -4 0 -6 -4
|
|
||||||
-11 -10 -11 -5 0 -7 -7 -4 -15 4 -8 2 -21 -4 -28 -7 -8 -6 -18 3 -31 16 -21 9
|
|
||||||
-45 -17 -64 -19 -14 -25 -42 -9 -42 5 0 12 8 15 17 5 12 10 13 17 6 12 -12 3
|
|
||||||
-36 -11 -28 -4 3 -10 -2 -13 -9 -3 -8 -2 -17 4 -20 5 -2 4 -3 -3 -2 -7 2 -13
|
|
||||||
8 -13 14 0 6 -6 17 -13 24 -7 7 -13 9 -12 3 2 -5 1 -12 0 -15 -7 -16 -4 -66 5
|
|
||||||
-72 6 -5 3 -8 -7 -8 -9 0 -20 -5 -24 -12 -4 -6 -3 -8 4 -4 12 7 10 -20 -3 -31
|
|
||||||
-4 -4 -5 -2 -1 5 4 7 1 12 -8 12 -10 0 -16 -9 -16 -25 0 -14 -6 -25 -12 -25
|
|
||||||
-9 0 -8 -4 2 -10 10 -6 11 -10 3 -10 -7 0 -13 -8 -13 -17 0 -14 -2 -15 -9 -5
|
|
||||||
-6 10 -11 9 -22 -4 -8 -10 -9 -15 -2 -11 6 4 13 1 16 -5 6 -18 -3 -39 -14 -32
|
|
||||||
-5 3 -9 2 -8 -3 1 -4 1 -17 0 -28 -1 -15 -4 -16 -13 -7 -7 7 -17 12 -22 12 -6
|
|
||||||
0 -3 -5 7 -11 21 -12 22 -29 1 -29 -9 0 -12 5 -8 12 4 7 3 8 -4 4 -24 -15 -11
|
|
||||||
-28 23 -23 19 3 38 1 41 -4 3 -5 -5 -10 -18 -10 -17 -1 -18 -3 -5 -6 19 -5 23
|
|
||||||
-28 7 -38 -6 -4 -4 -12 5 -22 9 -8 14 -17 11 -20 -2 -3 -14 5 -25 16 -12 12
|
|
||||||
-16 21 -10 21 5 0 8 4 5 9 -4 5 -2 11 4 13 6 2 1 9 -10 16 -18 11 -20 10 -20
|
|
||||||
-9 0 -11 -4 -18 -9 -14 -5 3 -13 0 -17 -6 -4 -8 -3 -9 5 -5 8 6 10 0 5 -21 -3
|
|
||||||
-15 -5 -43 -4 -61 0 -21 -3 -31 -10 -27 -5 3 -10 -2 -11 -12 0 -10 -2 -25 -3
|
|
||||||
-33 -2 -8 -6 -48 -10 -89 -6 -75 -31 -120 -66 -121 -8 0 0 10 17 23 l33 22 0
|
|
||||||
687 c0 639 -1 688 -17 697 -12 6 -27 4 -48 -7 -16 -8 -43 -17 -59 -19 -15 -2
|
|
||||||
-49 -13 -75 -24 -25 -12 -56 -22 -67 -23 -12 -1 -32 -10 -43 -20 -12 -11 -31
|
|
||||||
-21 -43 -23 -12 -2 -26 -7 -32 -12 -27 -22 -157 -81 -166 -76 -6 4 -9 1 -8 -6
|
|
||||||
3 -13 -62 -50 -74 -42 -5 2 -8 0 -8 -5 0 -6 -10 -12 -23 -16 -13 -3 -29 -17
|
|
||||||
-35 -31 -6 -14 -16 -26 -22 -26 -11 -2 -25 -5 -37 -9 -5 -1 -11 -2 -15 -1 -5
|
|
||||||
0 -8 -3 -8 -9 0 -5 -5 -10 -11 -10 -7 0 -21 -9 -33 -21 -42 -42 -189 -129
|
|
||||||
-218 -129 -10 0 -18 -5 -18 -11 0 -5 -4 -8 -9 -4 -5 3 -12 1 -16 -5 -4 -6 -11
|
|
||||||
-8 -16 -5 -5 3 -39 -8 -76 -26 -38 -17 -84 -39 -103 -48 -19 -8 -39 -22 -43
|
|
||||||
-29 -5 -7 -12 -10 -18 -7 -5 4 -12 -1 -15 -9 -3 -9 -13 -16 -21 -16 -8 0 -27
|
|
||||||
-6 -41 -14 -44 -24 -111 -46 -137 -46 -33 0 -137 28 -149 40 -5 5 -17 10 -27
|
|
||||||
10 -9 0 -28 9 -42 20 -14 11 -32 20 -41 20 -9 0 -16 5 -16 10 0 6 -11 10 -25
|
|
||||||
10 -14 0 -44 9 -65 20 -22 11 -40 18 -40 15 0 -3 -10 1 -22 9 -13 8 -38 18
|
|
||||||
-56 21 -37 6 -192 84 -192 97 0 4 -7 8 -15 8 -8 0 -15 5 -15 11 0 6 -7 9 -15
|
|
||||||
5 -8 -3 -15 -1 -15 4 0 11 -64 54 -125 84 -22 11 -42 23 -45 28 -9 12 -120 69
|
|
||||||
-120 61 0 -4 -7 2 -16 13 -8 10 -12 13 -9 5 5 -9 -1 -8 -19 4 -14 10 -26 20
|
|
||||||
-26 24 0 4 -20 15 -45 25 -25 11 -45 23 -45 28 0 4 -8 8 -18 8 -10 0 -24 6
|
|
||||||
-31 13 -6 6 -15 12 -19 12 -4 1 -22 9 -39 18 -18 10 -33 15 -33 12 0 -4 -6 -3
|
|
||||||
-13 2 -18 11 -52 16 -182 26 -16 1 -35 9 -42 17 -10 13 -14 13 -30 -3 -17 -17
|
|
||||||
-18 -51 -15 -673 3 -538 1 -655 -10 -651 -7 2 -12 14 -11 26 2 15 -1 20 -10
|
|
||||||
15 -9 -6 -9 -5 0 8 7 8 10 18 6 22 -4 4 -8 28 -9 54 -3 79 -4 82 -15 82 -5 0
|
|
||||||
-7 -5 -3 -12 5 -7 3 -8 -6 -3 -10 6 -12 4 -7 -9 4 -11 3 -15 -4 -11 -6 4 -8
|
|
||||||
14 -5 22 4 9 1 22 -6 31 -10 12 -10 16 0 19 23 8 13 31 -10 26 -13 -3 -19 -2
|
|
||||||
-15 2 12 14 40 15 54 3 10 -8 12 -7 7 6 -4 9 -14 16 -23 15 -38 -3 -45 1 -26
|
|
||||||
15 18 13 18 14 -4 21 -15 4 -26 3 -31 -4 -6 -11 -8 9 -10 86 0 12 -5 25 -10
|
|
||||||
28 -6 4 -8 12 -4 18 3 7 -2 3 -11 -8 -17 -20 -17 -20 -11 2 6 18 3 21 -16 17
|
|
||||||
-13 -2 -17 -2 -10 2 6 3 9 11 5 17 -4 7 0 8 13 3 37 -15 49 -18 38 -9 -6 4
|
|
||||||
-10 16 -8 26 1 9 -2 15 -7 11 -5 -3 -7 -10 -4 -15 4 -5 1 -9 -5 -9 -6 0 -13 7
|
|
||||||
-16 15 -4 8 -10 12 -15 9 -5 -3 -9 2 -9 11 0 9 4 14 9 10 6 -3 9 4 8 15 -1 21
|
|
||||||
-17 28 -17 8 0 -9 -3 -8 -10 2 -5 8 -5 17 -1 20 4 3 11 13 14 24 6 14 3 17
|
|
||||||
-11 14 -11 -3 -19 0 -19 8 0 8 5 14 11 14 6 0 4 5 -4 10 -8 5 -10 10 -5 10 6
|
|
||||||
0 10 11 10 25 0 26 -25 42 -47 30 -7 -4 -2 2 11 13 20 16 21 20 7 25 -9 4 -16
|
|
||||||
2 -16 -4 0 -6 -5 -7 -10 -4 -19 12 1 25 27 19 18 -5 24 -3 19 5 -4 6 -15 11
|
|
||||||
-24 11 -15 0 -15 2 -2 10 13 9 13 10 0 10 -12 0 -12 2 -1 9 10 7 8 12 -10 24
|
|
||||||
-20 14 -20 17 -6 23 10 3 14 11 10 18 -4 6 -8 13 -9 16 -11 37 -18 48 -27 46
|
|
||||||
-7 -2 -9 -1 -4 1 4 3 4 10 1 15 -4 7 -2 8 4 4 7 -4 12 -3 12 3 0 5 -4 12 -8
|
|
||||||
15 -4 2 -7 17 -7 32 1 16 -7 36 -19 48 -12 12 -17 18 -12 14 16 -13 26 -9 20
|
|
||||||
7 -4 8 -14 16 -23 16 -14 1 -14 2 1 6 14 4 16 8 8 24 -8 13 -7 19 0 19 6 0 8
|
|
||||||
5 3 12 -4 7 -8 18 -9 24 -1 6 -5 22 -9 35 -5 19 -4 21 4 9 6 -8 11 -13 12 -10
|
|
||||||
0 3 2 13 4 23 2 9 -1 17 -6 17 -6 0 -7 5 -4 10 3 6 1 10 -5 10 -11 0 -10 37 3
|
|
||||||
57 4 6 2 13 -5 15 -8 3 -7 13 5 37 14 28 14 32 2 27 -12 -4 -14 0 -9 22 4 15
|
|
||||||
7 39 7 54 0 17 4 25 11 21 6 -4 4 2 -5 13 -9 10 -15 30 -13 43 3 14 -1 28 -8
|
|
||||||
33 -10 6 -10 8 1 8 10 0 11 3 2 14 -9 10 -8 16 4 26 11 9 12 15 5 20 -7 5 -8
|
|
||||||
15 -1 32 7 18 6 29 -2 37 -6 6 -7 11 -3 11 5 0 3 7 -4 16 -11 12 -11 15 -1 12
|
|
||||||
8 -2 15 5 16 15 2 9 -1 15 -6 11 -13 -8 -11 10 3 24 9 9 9 12 -3 12 -12 0 -12
|
|
||||||
2 0 9 12 7 12 13 3 24 -7 7 -8 18 -4 22 4 5 1 5 -5 1 -7 -4 -13 -2 -13 3 0 6
|
|
||||||
5 11 11 11 6 0 9 6 6 14 -3 7 -1 18 4 23 6 6 6 19 0 35 -5 14 -7 28 -4 31 3 4
|
|
||||||
6 31 6 61 1 43 5 57 18 61 13 4 16 19 17 73 0 44 4 66 11 64 6 -1 11 2 11 8 0
|
|
||||||
5 -5 10 -12 10 -6 0 -8 3 -5 6 3 4 2 15 -4 26 -9 16 -7 20 10 25 11 3 18 9 15
|
|
||||||
15 -3 5 -2 14 3 21 5 7 8 28 7 47 0 19 3 43 8 54 7 13 7 16 -1 12 -6 -4 -11
|
|
||||||
-3 -11 3 0 5 8 15 18 20 13 8 14 10 2 11 -13 0 -13 1 0 10 10 6 11 10 3 10 -7
|
|
||||||
0 -13 5 -13 11 0 6 7 8 16 5 8 -3 12 -2 9 4 -3 6 -3 10 2 10 8 0 9 6 15 97 2
|
|
||||||
29 7 55 11 59 4 4 7 16 7 26 0 11 5 29 12 41 6 12 13 37 14 55 1 18 10 45 20
|
|
||||||
60 10 15 17 34 16 42 -1 8 12 30 28 49 32 36 39 51 15 31 -13 -11 -14 -10 -9
|
|
||||||
4 3 9 12 16 19 16 17 0 56 35 48 44 -3 3 -1 6 5 6 6 0 9 6 6 13 -4 12 46 70
|
|
||||||
106 120 11 10 18 22 15 27 -4 6 0 10 8 10 17 0 77 67 68 76 -3 4 -1 4 5 1 6
|
|
||||||
-3 20 3 32 13 12 11 26 20 31 20 5 0 13 5 17 12 4 7 3 8 -4 4 -7 -4 -12 -3
|
|
||||||
-12 1 0 15 23 33 42 33 12 0 18 7 18 21 0 11 5 17 10 14 5 -3 10 -1 10 4 0 6
|
|
||||||
3 10 8 9 15 -3 42 15 42 29 0 8 5 11 10 8 6 -3 10 1 10 10 0 9 4 14 8 11 5 -3
|
|
||||||
28 13 52 35 46 42 103 72 116 61 4 -4 5 -2 1 3 -3 6 3 16 14 23 12 8 19 9 19
|
|
||||||
1 0 -5 5 -7 10 -4 6 4 8 11 5 16 -4 5 0 9 8 9 14 0 55 38 57 55 1 6 6 9 11 8
|
|
||||||
5 -2 9 2 9 8 0 8 5 7 15 -1 13 -11 14 -10 9 3 -4 11 0 16 13 16 43 1 51 5 45
|
|
||||||
19 -4 11 -1 13 8 7 10 -6 12 -4 7 8 -4 10 -2 14 6 11 7 -2 28 9 46 25 18 17
|
|
||||||
45 33 60 36 15 3 31 15 36 27 6 11 15 21 20 21 6 0 30 11 54 24 24 12 52 23
|
|
||||||
62 23 11 0 28 9 39 20 12 12 26 18 32 14 6 -4 8 -3 5 3 -8 13 70 56 88 49 8
|
|
||||||
-3 17 -1 21 5 3 6 10 6 17 1 16 -13 57 3 57 22 0 8 5 18 12 22 7 4 8 3 4 -5
|
|
||||||
-5 -8 10 -10 57 -9 36 2 63 6 60 11 -4 7 42 12 85 8 12 -1 22 3 22 9 0 7 8 5
|
|
||||||
22 -4 15 -11 26 -12 40 -5z m272 -29 c3 -5 -1 -9 -9 -9 -8 0 -12 4 -9 9 3 4 7
|
|
||||||
8 9 8 2 0 6 -4 9 -8z m-1334 -405 c0 -7 -8 -17 -18 -23 -13 -9 -21 -8 -32 4
|
|
||||||
-13 14 -12 15 3 9 10 -3 22 0 29 8 16 18 18 18 18 2z m2870 -1057 c0 -5 -2
|
|
||||||
-10 -4 -10 -3 0 -8 5 -11 10 -3 6 -1 10 4 10 6 0 11 -4 11 -10z m91 -567 c13
|
|
||||||
-16 12 -17 -3 -4 -17 13 -22 21 -14 21 2 0 10 -8 17 -17z m24 -93 c3 -6 -1 -7
|
|
||||||
-9 -4 -18 7 -21 14 -7 14 6 0 13 -4 16 -10z m8 -315 c-3 -9 -8 -14 -10 -11 -3
|
|
||||||
3 -2 9 2 15 9 16 15 13 8 -4z m-3933 -169 c0 -11 -19 -15 -25 -6 -3 5 1 10 9
|
|
||||||
10 9 0 16 -2 16 -4z m3820 -526 c0 -5 -5 -10 -11 -10 -5 0 -7 5 -4 10 3 6 8
|
|
||||||
10 11 10 2 0 4 -4 4 -10z m-3740 -80 c0 -5 -5 -10 -11 -10 -5 0 -7 5 -4 10 3
|
|
||||||
6 8 10 11 10 2 0 4 -4 4 -10z m3610 -375 c-7 -9 -15 -13 -19 -10 -3 3 1 10 9
|
|
||||||
15 21 14 24 12 10 -5z m-45 -85 c3 -5 1 -10 -4 -10 -6 0 -11 5 -11 10 0 6 2
|
|
||||||
10 4 10 3 0 8 -4 11 -10z m8 -27 c-7 -2 -19 -2 -25 0 -7 3 -2 5 12 5 14 0 19
|
|
||||||
-2 13 -5z m-3418 -102 c3 -5 2 -12 -3 -15 -5 -3 -9 1 -9 9 0 17 3 19 12 6z
|
|
||||||
m3366 -54 c-10 -9 -11 -8 -5 6 3 10 9 15 12 12 3 -3 0 -11 -7 -18z m-3092
|
|
||||||
-357 c164 -96 162 -94 160 -181 -2 -78 -17 -81 -22 -4 -2 27 -8 50 -15 53 -7
|
|
||||||
2 -9 8 -6 14 7 11 -27 39 -38 31 -5 -2 -11 3 -14 11 -3 9 -12 16 -20 16 -8 0
|
|
||||||
-14 5 -14 10 0 6 -7 10 -15 10 -8 0 -15 5 -15 10 0 6 -9 10 -20 10 -10 0 -23
|
|
||||||
8 -29 18 -5 9 -12 16 -16 14 -8 -4 -85 60 -85 71 0 6 5 6 13 0 6 -6 68 -43
|
|
||||||
136 -83z m2944 45 c-3 -9 -28 -28 -56 -43 -27 -15 -61 -33 -76 -41 -14 -8 -28
|
|
||||||
-17 -31 -21 -3 -4 -19 -13 -36 -20 -30 -13 -32 -18 -45 -104 l-14 -91 -3 75
|
|
||||||
c-4 95 1 113 35 131 16 8 33 18 38 22 25 20 171 106 182 106 7 1 10 -6 6 -14z"/>
|
|
||||||
<path d="M2800 3974 c-18 -5 -45 -62 -42 -86 3 -16 -8 -23 -30 -19 -5 0 -8 -4
|
|
||||||
-8 -11 0 -9 -3 -9 -11 -1 -7 7 -22 8 -46 1 -19 -5 -37 -7 -41 -4 -3 3 -11 1
|
|
||||||
-19 -5 -8 -8 -13 -8 -13 -1 0 11 -18 11 -37 -1 -7 -4 -23 -1 -37 8 -16 11 -26
|
|
||||||
13 -31 6 -3 -6 0 -12 7 -13 7 -1 -16 -4 -52 -7 -36 -3 -70 -5 -77 -3 -7 2 -19
|
|
||||||
26 -28 53 -16 48 -37 69 -69 69 -53 0 -204 -113 -176 -130 7 -5 27 -6 44 -4
|
|
||||||
59 7 67 -1 64 -64 -3 -55 -4 -58 -40 -75 -44 -20 -45 -26 -17 -83 32 -67 35
|
|
||||||
-67 133 -34 172 58 362 58 548 0 37 -11 66 -16 72 -10 5 5 17 33 27 62 l19 53
|
|
||||||
-32 27 c-34 30 -34 31 17 102 39 54 46 103 18 128 -10 9 -40 23 -66 32 -49 16
|
|
||||||
-51 17 -77 10z"/>
|
|
||||||
<path d="M3295 3625 c-16 -8 -46 -14 -65 -15 -62 -1 -79 -10 -90 -49 -5 -20
|
|
||||||
-10 -51 -10 -69 0 -18 -6 -41 -12 -52 -10 -15 -10 -24 -2 -37 107 -167 124
|
|
||||||
-199 139 -266 23 -97 30 -292 16 -398 -23 -175 -38 -207 -154 -338 -35 -38
|
|
||||||
-38 -45 -24 -58 8 -9 49 -19 93 -25 110 -14 121 -20 134 -70 27 -97 39 -105
|
|
||||||
104 -67 62 36 78 87 60 183 -5 29 -4 37 4 32 12 -7 17 11 13 43 -2 7 2 10 8 6
|
|
||||||
7 -4 11 5 11 23 0 16 6 35 14 41 18 15 120 18 138 4 7 -6 21 -9 31 -8 9 2 17
|
|
||||||
-1 17 -5 0 -5 9 -12 20 -15 11 -3 20 -13 20 -22 0 -22 93 -12 122 13 14 12 19
|
|
||||||
14 13 4 -7 -13 -6 -13 8 0 9 8 18 27 21 42 2 15 7 32 10 36 3 5 0 25 -6 45
|
|
||||||
-10 32 -17 38 -67 54 -65 20 -85 35 -69 51 6 6 12 26 13 45 1 19 5 39 9 46 4
|
|
||||||
6 1 11 -6 11 -9 0 -9 3 2 10 11 7 11 10 2 10 -7 0 -10 5 -7 10 11 17 24 11 20
|
|
||||||
-10 -2 -11 0 -20 6 -20 12 0 12 37 -2 45 -6 5 -4 12 8 22 10 8 13 12 6 9 -6
|
|
||||||
-4 -14 -2 -18 4 -3 5 0 10 7 10 9 0 9 3 -2 10 -12 7 -12 10 -1 10 7 0 11 6 8
|
|
||||||
14 -4 10 0 13 14 11 16 -3 18 -1 10 9 -8 10 -6 18 9 31 l20 18 -22 25 c-16 17
|
|
||||||
-19 23 -8 22 26 -4 40 0 40 10 0 6 -10 10 -22 11 -22 1 -22 1 2 9 14 4 18 8
|
|
||||||
11 9 -9 1 0 15 23 36 31 28 37 40 32 59 -3 14 -2 27 2 30 8 5 7 44 -1 142 -2
|
|
||||||
23 -11 51 -20 64 -8 12 -13 29 -10 36 6 16 3 16 -82 20 -70 2 -81 -4 -96 -58
|
|
||||||
-8 -32 -14 -39 -29 -35 -11 3 -29 -4 -42 -14 -12 -11 -28 -17 -35 -14 -8 2
|
|
||||||
-12 1 -9 -4 8 -12 -43 -33 -94 -38 -61 -5 -78 -8 -85 -15 -9 -8 -55 3 -49 13
|
|
||||||
3 5 -13 27 -36 50 -45 46 -43 56 14 79 34 13 54 45 51 80 -1 8 -3 28 -3 43 -2
|
|
||||||
35 -43 77 -74 76 -13 0 -36 -7 -53 -14z"/>
|
|
||||||
<path d="M1709 3613 c-46 -19 -61 -123 -23 -160 8 -8 14 -19 14 -24 0 -5 6 -9
|
|
||||||
14 -9 7 0 16 -11 18 -24 4 -18 0 -26 -15 -30 -12 -3 -16 -9 -11 -18 5 -9 2 -8
|
|
||||||
-11 2 -17 14 -17 13 -10 -10 4 -14 4 -22 0 -18 -5 4 -14 3 -22 -4 -11 -8 -12
|
|
||||||
-7 -7 6 9 24 -11 20 -30 -6 -9 -13 -14 -18 -11 -11 7 15 -35 27 -70 21 -14 -3
|
|
||||||
-25 -1 -25 4 0 5 -4 6 -10 3 -5 -3 -10 -1 -10 6 0 7 -7 4 -16 -7 -14 -17 -15
|
|
||||||
-17 -10 -1 3 10 2 15 -3 12 -5 -3 -12 -1 -16 5 -3 5 -15 10 -26 10 -11 0 -18
|
|
||||||
4 -15 9 3 5 -7 22 -22 39 -22 24 -40 32 -85 37 -96 12 -126 -6 -130 -80 -1
|
|
||||||
-18 -4 -32 -7 -30 -3 2 -5 -19 -5 -46 0 -27 3 -49 7 -49 7 0 4 -24 -7 -52 -4
|
|
||||||
-11 -3 -18 4 -18 6 0 11 -8 11 -17 0 -9 3 -14 6 -10 4 3 12 1 20 -6 7 -7 21
|
|
||||||
-18 29 -26 9 -7 14 -20 10 -29 -3 -8 -2 -18 2 -21 14 -10 44 -61 36 -60 -20 3
|
|
||||||
-24 -2 -13 -16 7 -8 18 -15 24 -15 6 0 4 5 -4 10 -9 6 -10 10 -3 10 19 0 26
|
|
||||||
-20 9 -26 -9 -3 -16 -13 -16 -21 0 -8 5 -11 10 -8 6 3 10 1 10 -4 0 -6 -6 -11
|
|
||||||
-12 -11 -9 0 -8 -3 2 -10 17 -11 20 -30 7 -47 -6 -9 -5 -13 2 -13 7 0 9 -4 6
|
|
||||||
-10 -3 -5 -1 -10 5 -10 6 0 10 -8 8 -17 -2 -10 3 -17 9 -16 7 2 12 0 11 -5 -1
|
|
||||||
-4 1 -17 6 -29 4 -12 2 -31 -4 -43 -8 -15 -8 -20 2 -20 9 0 9 -3 -2 -10 -11
|
|
||||||
-7 -11 -10 -2 -10 7 0 10 -4 7 -10 -3 -5 -14 -10 -24 -10 -10 0 -26 -9 -36
|
|
||||||
-20 -10 -11 -23 -19 -29 -17 -5 2 -22 -8 -37 -22 -22 -21 -26 -32 -23 -67 3
|
|
||||||
-50 34 -86 84 -99 3 0 22 -7 42 -14 32 -11 43 -10 68 2 20 10 30 12 30 4 0 -6
|
|
||||||
7 -2 16 9 8 10 13 14 10 7 -4 -6 -2 -14 4 -18 5 -3 10 -1 10 5 0 6 5 8 13 3
|
|
||||||
20 -12 37 -12 37 0 0 7 5 6 11 -3 8 -11 12 -12 16 -2 7 19 22 14 18 -6 -3 -16
|
|
||||||
3 -18 31 -17 19 2 34 -2 34 -7 0 -5 6 -6 13 -2 9 6 9 5 0 -7 -12 -15 -14 -91
|
|
||||||
-2 -83 4 2 8 -4 8 -13 -1 -37 19 -91 40 -114 9 -10 33 -20 53 -22 42 -5 62 12
|
|
||||||
91 76 18 40 36 50 107 61 26 4 57 18 73 32 l29 25 -61 64 c-81 88 -108 137
|
|
||||||
-130 241 -27 126 -34 245 -21 371 13 135 31 190 88 277 48 73 49 79 33 190
|
|
||||||
-14 99 -40 123 -134 128 -39 2 -82 -2 -98 -9z m-84 -1183 c3 -6 -1 -7 -9 -4
|
|
||||||
-18 7 -21 14 -7 14 6 0 13 -4 16 -10z"/>
|
|
||||||
<path d="M2402 3560 c-49 -9 -160 -44 -169 -54 -7 -7 58 -114 140 -230 l69
|
|
||||||
-98 -73 -76 c-70 -72 -57 -62 65 51 27 25 35 27 120 27 51 0 97 -4 104 -10 8
|
|
||||||
-7 9 -7 3 1 -6 7 16 50 63 123 103 158 122 194 109 207 -5 5 -42 21 -82 35
|
|
||||||
-81 28 -257 40 -349 24z"/>
|
|
||||||
<path d="M1656 3365 c4 -8 8 -15 10 -15 2 0 4 7 4 15 0 8 -4 15 -10 15 -5 0
|
|
||||||
-7 -7 -4 -15z"/>
|
|
||||||
<path d="M3155 3150 c-16 -4 -92 -37 -167 -74 -76 -36 -141 -66 -144 -66 -3 0
|
|
||||||
-35 32 -71 70 -36 39 -70 70 -75 70 -6 0 22 -34 61 -76 l71 -76 0 -105 0 -105
|
|
||||||
-67 -69 c-95 -98 -121 -113 -207 -113 -69 -1 -73 0 -131 43 -33 25 -79 64
|
|
||||||
-102 88 l-43 42 0 111 c0 77 -3 110 -12 110 -6 0 -90 34 -185 76 -96 42 -178
|
|
||||||
73 -182 68 -15 -17 -31 -116 -31 -188 0 -65 35 -334 45 -344 2 -2 25 6 52 18
|
|
||||||
115 53 279 120 293 120 15 0 182 -134 188 -150 2 -5 -41 -75 -95 -157 -54 -81
|
|
||||||
-99 -151 -101 -154 -7 -16 108 -43 228 -54 133 -12 360 27 360 62 0 9 -38 78
|
|
||||||
-85 154 -47 75 -85 143 -85 149 0 7 38 50 85 96 l86 83 174 -90 c95 -49 176
|
|
||||||
-86 179 -81 2 4 10 66 16 138 13 135 8 273 -13 360 -12 49 -13 50 -42 44z"/>
|
|
||||||
<path d="M3815 2790 c-3 -5 1 -10 10 -10 9 0 13 5 10 10 -3 6 -8 10 -10 10 -2
|
|
||||||
0 -7 -4 -10 -10z"/>
|
|
||||||
<path d="M2159 2214 l-22 -37 21 -18 c40 -32 20 -98 -36 -120 -34 -13 -48 -51
|
|
||||||
-32 -89 7 -16 17 -30 23 -30 5 0 33 -14 61 -32 46 -28 116 -46 116 -29 0 3 16
|
|
||||||
23 35 44 25 27 30 37 17 32 -15 -4 -19 -1 -17 17 3 32 3 31 21 13 14 -13 19
|
|
||||||
-14 25 -3 7 11 11 10 19 -2 7 -11 10 -11 10 -2 0 7 4 11 9 7 5 -3 12 -1 15 4
|
|
||||||
4 5 18 8 32 5 19 -3 24 -1 18 8 -5 10 -4 10 5 2 14 -13 54 -7 45 7 -3 5 2 9
|
|
||||||
10 9 22 0 31 -4 29 -12 -2 -4 11 -2 28 4 24 8 33 7 48 -7 13 -11 21 -13 26 -5
|
|
||||||
5 8 12 5 22 -7 8 -10 11 -12 7 -4 -5 10 -3 12 7 5 27 -16 40 -14 29 6 -18 34
|
|
||||||
-10 36 10 2 11 -18 20 -43 20 -57 0 -49 63 -55 163 -17 82 32 91 42 88 102 -2
|
|
||||||
68 -14 84 -62 77 -46 -6 -59 16 -29 48 23 25 23 27 9 78 -12 44 -19 45 -109
|
|
||||||
13 -105 -38 -251 -52 -378 -37 -94 12 -195 35 -243 55 -12 5 -23 -3 -40 -30z"/>
|
|
||||||
<path d="M4385 1510 c-4 -6 -12 -8 -18 -4 -7 3 -3 -2 7 -10 16 -13 16 -16 5
|
|
||||||
-16 -9 0 -16 -7 -16 -15 0 -20 6 -19 28 7 22 24 24 32 7 22 -8 -5 -9 -2 -5 9
|
|
||||||
7 19 2 23 -8 7z"/>
|
|
||||||
<path d="M850 1128 c0 -4 6 -8 14 -8 8 0 17 4 20 8 2 4 -4 8 -15 8 -10 0 -19
|
|
||||||
-4 -19 -8z"/>
|
|
||||||
<path d="M910 945 c-7 -8 -11 -15 -9 -16 32 -6 39 -5 39 6 0 21 -16 26 -30 10z"/>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 18 KiB |
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"name": "Minecluster",
|
|
||||||
"short_name": "Minecluster",
|
|
||||||
"icons": [
|
|
||||||
{
|
|
||||||
"src": "/icons/android-chrome-192x192.png?v=feb4-24-mineblock",
|
|
||||||
"sizes": "192x192",
|
|
||||||
"type": "image/png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"src": "/icons/android-chrome-512x512.png?v=feb4-24-mineblock",
|
|
||||||
"sizes": "512x512",
|
|
||||||
"type": "image/png"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"theme_color": "#249c6b",
|
|
||||||
"background_color": "#249c6b",
|
|
||||||
"display": "standalone"
|
|
||||||
}
|
|
42
src/components/files/ChonkyStyledFileBrowser.jsx
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
// ChonkyFullFileBrowser.tsx
|
||||||
|
import { forwardRef, memo } from "react";
|
||||||
|
import {
|
||||||
|
StylesProvider,
|
||||||
|
createGenerateClassName,
|
||||||
|
} from "@material-ui/core/styles";
|
||||||
|
|
||||||
|
import {
|
||||||
|
FileBrowser,
|
||||||
|
FileList,
|
||||||
|
FileContextMenu,
|
||||||
|
FileNavbar,
|
||||||
|
FileToolbar,
|
||||||
|
setChonkyDefaults,
|
||||||
|
FileBrowserHandle,
|
||||||
|
FileBrowserProps,
|
||||||
|
} from "chonky";
|
||||||
|
|
||||||
|
import { ChonkyIconFA } from "chonky-icon-fontawesome";
|
||||||
|
|
||||||
|
setChonkyDefaults({ iconComponent: ChonkyIconFA });
|
||||||
|
|
||||||
|
const muiJSSClassNameGenerator = createGenerateClassName({
|
||||||
|
// Seed property is used to add a prefix classes generated by material ui.
|
||||||
|
seed: "chonky",
|
||||||
|
});
|
||||||
|
|
||||||
|
export default memo(
|
||||||
|
forwardRef((props, ref) => {
|
||||||
|
const { onScroll } = props;
|
||||||
|
return (
|
||||||
|
<StylesProvider generateClassName={muiJSSClassNameGenerator}>
|
||||||
|
<FileBrowser ref={ref} {...props}>
|
||||||
|
<FileNavbar />
|
||||||
|
<FileToolbar />
|
||||||
|
<FileList onScroll={onScroll} />
|
||||||
|
<FileContextMenu />
|
||||||
|
</FileBrowser>
|
||||||
|
</StylesProvider>
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect, memo } from "react";
|
||||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
|
@ -7,20 +7,10 @@ import DialogContent from "@mui/material/DialogContent";
|
||||||
import DialogActions from "@mui/material/DialogActions";
|
import DialogActions from "@mui/material/DialogActions";
|
||||||
import Dialog from "@mui/material/Dialog";
|
import Dialog from "@mui/material/Dialog";
|
||||||
import Toolbar from "@mui/material/Toolbar";
|
import Toolbar from "@mui/material/Toolbar";
|
||||||
import TextEditor from "./TextEditor.jsx";
|
|
||||||
import { cairoAuthHeader } from "@mcl/util/auth.js";
|
|
||||||
|
|
||||||
const textFileTypes = [
|
import TextEditor from "./TextEditor.jsx";
|
||||||
"properties",
|
|
||||||
"txt",
|
const textFileTypes = ["properties", "txt", "yaml", "yml", "json", "env"];
|
||||||
"yaml",
|
|
||||||
"yml",
|
|
||||||
"json",
|
|
||||||
"env",
|
|
||||||
"toml",
|
|
||||||
"tml",
|
|
||||||
"text",
|
|
||||||
];
|
|
||||||
const imageFileTypes = ["png", "jpeg", "jpg"];
|
const imageFileTypes = ["png", "jpeg", "jpg"];
|
||||||
|
|
||||||
export const supportedFileTypes = [...textFileTypes, ...imageFileTypes];
|
export const supportedFileTypes = [...textFileTypes, ...imageFileTypes];
|
||||||
|
@ -54,7 +44,6 @@ export default function FilePreview(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onSave() {
|
async function onSave() {
|
||||||
if (!isTextFile) return;
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
const blob = new Blob([modifiedText], { type: "plain/text" });
|
const blob = new Blob([modifiedText], { type: "plain/text" });
|
||||||
formData.append("file", blob, name);
|
formData.append("file", blob, name);
|
||||||
|
@ -63,7 +52,6 @@ export default function FilePreview(props) {
|
||||||
await fetch("/api/files/upload", {
|
await fetch("/api/files/upload", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
headers: cairoAuthHeader(),
|
|
||||||
});
|
});
|
||||||
dialogToggle();
|
dialogToggle();
|
||||||
}
|
}
|
||||||
|
@ -88,7 +76,7 @@ export default function FilePreview(props) {
|
||||||
<Toolbar sx={{ display: { sm: "none" } }} />
|
<Toolbar sx={{ display: { sm: "none" } }} />
|
||||||
<DialogTitle>{name}</DialogTitle>
|
<DialogTitle>{name}</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
{isTextFile && <TextEditor text={fileText} onChange={editorChange} />}
|
<TextEditor text={fileText} onChange={editorChange} />
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button autoFocus onClick={dialogToggle}>
|
<Button autoFocus onClick={dialogToggle}>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { useState, useEffect, useMemo, useRef } from "react";
|
import { useState, useEffect, useMemo, useRef } from "react";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Dropzone from "react-dropzone";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
FileBrowser,
|
FileBrowser,
|
||||||
FileContextMenu,
|
FileContextMenu,
|
||||||
|
@ -18,10 +16,8 @@ import {
|
||||||
createServerFolder,
|
createServerFolder,
|
||||||
deleteServerItem,
|
deleteServerItem,
|
||||||
getServerItem,
|
getServerItem,
|
||||||
moveServerItems,
|
|
||||||
previewServerItem,
|
|
||||||
} from "@mcl/queries";
|
} from "@mcl/queries";
|
||||||
import { cairoAuthHeader } from "@mcl/util/auth.js";
|
import { previewServerItem } from "../../util/queries";
|
||||||
|
|
||||||
import { supportedFileTypes } from "./FilePreview.jsx";
|
import { supportedFileTypes } from "./FilePreview.jsx";
|
||||||
|
|
||||||
|
@ -35,7 +31,6 @@ export default function MineclusterFiles(props) {
|
||||||
ChonkyActions.DownloadFiles,
|
ChonkyActions.DownloadFiles,
|
||||||
ChonkyActions.CopyFiles,
|
ChonkyActions.CopyFiles,
|
||||||
ChonkyActions.DeleteFiles,
|
ChonkyActions.DeleteFiles,
|
||||||
ChonkyActions.MoveFiles,
|
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
@ -101,26 +96,19 @@ export default function MineclusterFiles(props) {
|
||||||
function uploadFileSelection(e) {
|
function uploadFileSelection(e) {
|
||||||
if (!e.target.files || e.target.files.length === 0) return;
|
if (!e.target.files || e.target.files.length === 0) return;
|
||||||
const { files } = e.target;
|
const { files } = e.target;
|
||||||
uploadMultipleFiles(files);
|
|
||||||
}
|
|
||||||
|
|
||||||
function uploadMultipleFiles(files) {
|
|
||||||
Promise.all([...files].map((f) => uploadFile(f)))
|
Promise.all([...files].map((f) => uploadFile(f)))
|
||||||
.catch((e) => console.log("Error uploading a file", e))
|
.catch((e) => console.log("Error uploading a file", e))
|
||||||
.then(updateFiles);
|
.then(updateFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function uploadFile(file) {
|
async function uploadFile(file) {
|
||||||
const filePath = file.path.startsWith("/") ? file.path : `/${file.path}`;
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file", file);
|
formData.append("file", file);
|
||||||
formData.append("id", serverId);
|
formData.append("id", serverId);
|
||||||
const path = `${[...dirStack].join("/")}${filePath}`;
|
formData.append("path", [...dirStack, file.name].join("/"));
|
||||||
formData.append("path", path);
|
|
||||||
await fetch("/api/files/upload", {
|
await fetch("/api/files/upload", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: formData,
|
body: formData,
|
||||||
headers: cairoAuthHeader(),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,15 +130,6 @@ export default function MineclusterFiles(props) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveFile(movePayload) {
|
|
||||||
const { files: filePayload, destination: destinationPayload } = movePayload;
|
|
||||||
if (!destinationPayload.isDir || filePayload.length === 0) return;
|
|
||||||
const files = filePayload.map((f) => f.name);
|
|
||||||
const dest = destinationPayload.id;
|
|
||||||
const origin = dirStack.join("/");
|
|
||||||
moveServerItems(serverId, files, dest, origin).then(updateFiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
function fileClick(chonkyEvent) {
|
function fileClick(chonkyEvent) {
|
||||||
const { id: clickEvent, payload } = chonkyEvent;
|
const { id: clickEvent, payload } = chonkyEvent;
|
||||||
if (clickEvent === "open_parent_folder") return openParentFolder();
|
if (clickEvent === "open_parent_folder") return openParentFolder();
|
||||||
|
@ -160,19 +139,11 @@ export default function MineclusterFiles(props) {
|
||||||
return downloadFiles(chonkyEvent.state.selectedFilesForAction);
|
return downloadFiles(chonkyEvent.state.selectedFilesForAction);
|
||||||
if (clickEvent === "delete_files")
|
if (clickEvent === "delete_files")
|
||||||
return deleteItems(chonkyEvent.state.selectedFilesForAction);
|
return deleteItems(chonkyEvent.state.selectedFilesForAction);
|
||||||
if (clickEvent === "move_files") return moveFile(payload);
|
|
||||||
if (clickEvent !== "open_files") return; // console.log(clickEvent);
|
if (clickEvent !== "open_files") return; // console.log(clickEvent);
|
||||||
openItem(payload);
|
openItem(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropzone onDrop={uploadMultipleFiles}>
|
<Box className="minecluster-files" sx={{ height: "calc(100vh - 6rem)" }}>
|
||||||
{({ getRootProps }) => (
|
|
||||||
<Box
|
|
||||||
className="minecluster-files"
|
|
||||||
sx={{ height: "calc(100vh - 6rem)" }}
|
|
||||||
onDrop={getRootProps().onDrop}
|
|
||||||
>
|
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
id="file"
|
id="file"
|
||||||
|
@ -190,11 +161,10 @@ export default function MineclusterFiles(props) {
|
||||||
>
|
>
|
||||||
<FileNavbar />
|
<FileNavbar />
|
||||||
<FileToolbar />
|
<FileToolbar />
|
||||||
|
|
||||||
<FileList />
|
<FileList />
|
||||||
<FileContextMenu />
|
<FileContextMenu />
|
||||||
</FileBrowser>
|
</FileBrowser>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
|
||||||
</Dropzone>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ export default function BackupHostOption(props) {
|
||||||
<TextField
|
<TextField
|
||||||
label="Backup Host"
|
label="Backup Host"
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
value={value ?? ""}
|
value={value}
|
||||||
helperText="Example: s3.mydomain.com"
|
helperText="Example: s3.mydomain.com"
|
||||||
FormHelperTextProps={{ sx: { ml: 0 } }}
|
FormHelperTextProps={{ sx: { ml: 0 } }}
|
||||||
required
|
required
|
||||||
|
|
|
@ -5,7 +5,7 @@ export default function BackupIdOption(props) {
|
||||||
return (
|
return (
|
||||||
<TextField
|
<TextField
|
||||||
label="S3 Access Key ID"
|
label="S3 Access Key ID"
|
||||||
value={value ?? ""}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
helperText="Example: s3-access-key-id"
|
helperText="Example: s3-access-key-id"
|
||||||
FormHelperTextProps={{ sx: { ml: 0 } }}
|
FormHelperTextProps={{ sx: { ml: 0 } }}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
export default function BackupKeyOption(props) {
|
export default function BackupKeyOption(props) {
|
||||||
const { value, onChange } = props;
|
const { onChange } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TextField
|
<TextField
|
||||||
label="S3 Access Key"
|
label="S3 Access Key"
|
||||||
value={value ?? ""}
|
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
helperText="Example: s3-access-key"
|
helperText="Example: s3-access-key"
|
||||||
FormHelperTextProps={{ sx: { ml: 0 } }}
|
FormHelperTextProps={{ sx: { ml: 0 } }}
|
||||||
|
|
|
@ -3,8 +3,7 @@ import TextField from "@mui/material/TextField";
|
||||||
import Autocomplete from "@mui/material/Autocomplete";
|
import Autocomplete from "@mui/material/Autocomplete";
|
||||||
import Chip from "@mui/material/Chip";
|
import Chip from "@mui/material/Chip";
|
||||||
|
|
||||||
const validatePort = (p) =>
|
const validatePort = (p) => p !== "25565" && p !== "25575" && p.length < 6;
|
||||||
p !== "25565" && p !== "25575" && p.length < 6 && parseInt(p) < 60_000;
|
|
||||||
|
|
||||||
export default function ExtraPortsOption(props) {
|
export default function ExtraPortsOption(props) {
|
||||||
const { extraPorts: initExtraPorts } = props;
|
const { extraPorts: initExtraPorts } = props;
|
||||||
|
@ -31,14 +30,7 @@ export default function ExtraPortsOption(props) {
|
||||||
value={extraPorts}
|
value={extraPorts}
|
||||||
onChange={portChange}
|
onChange={portChange}
|
||||||
freeSolo
|
freeSolo
|
||||||
renderInput={(p) => (
|
renderInput={(p) => <TextField {...p} label="Extra Ports" />}
|
||||||
<TextField
|
|
||||||
{...p}
|
|
||||||
label="Extra Ports"
|
|
||||||
helperText="Remember to press enter to add the port!"
|
|
||||||
FormHelperTextProps={{ sx: { ml: 0 } }}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
renderTags={(value, getTagProps) =>
|
renderTags={(value, getTagProps) =>
|
||||||
value.map((option, index) => {
|
value.map((option, index) => {
|
||||||
const defaultChipProps = getTagProps({ index });
|
const defaultChipProps = getTagProps({ index });
|
||||||
|
|
|
@ -1,21 +1,15 @@
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
export default function HostOption(props) {
|
export default function HostOption(props) {
|
||||||
const { value, onChange, disabled } = props;
|
const { value, onChange } = props;
|
||||||
|
|
||||||
function onTextChange(e) {
|
|
||||||
e.target.value = e.target.value.toLowerCase();
|
|
||||||
onChange(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TextField
|
<TextField
|
||||||
label="Host"
|
label="Host"
|
||||||
value={value ?? ""}
|
value={value ?? ""}
|
||||||
onChange={onTextChange}
|
onChange={onChange}
|
||||||
helperText="Example: host.mydomain.com"
|
helperText="Example: host.mydomain.com"
|
||||||
FormHelperTextProps={{ sx: { ml: 0 } }}
|
FormHelperTextProps={{ sx: { ml: 0 } }}
|
||||||
required
|
required
|
||||||
disabled={disabled}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import TextField from "@mui/material/TextField";
|
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
|
||||||
|
|
||||||
const maxStorageSupported = 80;
|
|
||||||
export const storageOptions = new Array(2 * maxStorageSupported)
|
|
||||||
.fill(0)
|
|
||||||
.map((v, i) => (i + 1) * 0.5);
|
|
||||||
|
|
||||||
export default function StorageOption(props) {
|
|
||||||
const { value, onChange } = props;
|
|
||||||
return (
|
|
||||||
<TextField
|
|
||||||
label="Storage"
|
|
||||||
onChange={onChange}
|
|
||||||
value={value ?? null}
|
|
||||||
select
|
|
||||||
required
|
|
||||||
SelectProps={{ MenuProps: { sx: { maxHeight: "20rem" } } }}
|
|
||||||
>
|
|
||||||
<MenuItem value={0}>No Storage</MenuItem>
|
|
||||||
{storageOptions.map((o, i) => (
|
|
||||||
<MenuItem value={o} key={i}>{`${o} GB`}</MenuItem>
|
|
||||||
))}
|
|
||||||
</TextField>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,88 +0,0 @@
|
||||||
import { useEffect, useState } from "react";
|
|
||||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
||||||
import { useTheme } from "@mui/material/styles";
|
|
||||||
import Button from "@mui/material/Button";
|
|
||||||
import DialogTitle from "@mui/material/DialogTitle";
|
|
||||||
import DialogContent from "@mui/material/DialogContent";
|
|
||||||
import DialogActions from "@mui/material/DialogActions";
|
|
||||||
import Dialog from "@mui/material/Dialog";
|
|
||||||
import IconButton from "@mui/material/IconButton";
|
|
||||||
import Toolbar from "@mui/material/Toolbar";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import Stack from "@mui/material/Stack";
|
|
||||||
import DownloadIcon from "@mui/icons-material/Download";
|
|
||||||
import { getBackupUrl, getServerBackups } from "../../util/queries";
|
|
||||||
|
|
||||||
export function useBackupDialog(isOpen = false) {
|
|
||||||
const [open, setOpen] = useState(isOpen);
|
|
||||||
const dialogToggle = () => setOpen(!open);
|
|
||||||
return [open, dialogToggle];
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function BackupDialog(props) {
|
|
||||||
const { serverId, open, dialogToggle } = props;
|
|
||||||
const theme = useTheme();
|
|
||||||
const fullScreen = useMediaQuery(theme.breakpoints.down("md"));
|
|
||||||
const [backups, setBackups] = useState([]);
|
|
||||||
|
|
||||||
function refreshUpdateList() {
|
|
||||||
getServerBackups(serverId).then(setBackups);
|
|
||||||
}
|
|
||||||
useEffect(() => {
|
|
||||||
if (!serverId) return;
|
|
||||||
refreshUpdateList();
|
|
||||||
}, [serverId, open]);
|
|
||||||
|
|
||||||
function normalizeLastModified(lastModified) {
|
|
||||||
const d = new Date(Date.parse(lastModified));
|
|
||||||
return `${d.getFullYear()}-${d.getMonth()}-${d.getDate()} ${d.getHours()}:${d.getMinutes()}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
const downloadBackup = (backup) =>
|
|
||||||
async function openBackupLink() {
|
|
||||||
const { url } = await getBackupUrl(serverId, backup.path);
|
|
||||||
window.open(url, "_blank").focus();
|
|
||||||
};
|
|
||||||
|
|
||||||
const normalizedSize = (size) => `${(size / Math.pow(1024, 3)).toFixed(2)}GB`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Dialog
|
|
||||||
fullWidth
|
|
||||||
maxWidth="lg"
|
|
||||||
open={open}
|
|
||||||
fullScreen={fullScreen}
|
|
||||||
PaperProps={!fullScreen ? { sx: { height: "60%" } } : undefined}
|
|
||||||
>
|
|
||||||
<Toolbar sx={{ display: { md: "none" } }} />
|
|
||||||
<DialogTitle>Backups</DialogTitle>
|
|
||||||
<DialogContent sx={{ height: "100%" }}>
|
|
||||||
{backups.map((backup, i) => (
|
|
||||||
<Stack key={i} sx={{ width: "100%" }} direction="row">
|
|
||||||
<Typography variant="subtitle2" sx={{ m: "auto 0", width: "40%" }}>
|
|
||||||
{backup.name}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="subtitle2" sx={{ m: "auto 0", width: "20%" }}>
|
|
||||||
{normalizeLastModified(backup.lastModified)}
|
|
||||||
</Typography>
|
|
||||||
<Typography variant="subtitle2" sx={{ m: "auto 0", width: "40%" }}>
|
|
||||||
{normalizedSize(backup.size)}
|
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<IconButton
|
|
||||||
sx={{ marginLeft: "auto" }}
|
|
||||||
onClick={downloadBackup(backup)}
|
|
||||||
>
|
|
||||||
<DownloadIcon />
|
|
||||||
</IconButton>
|
|
||||||
</Stack>
|
|
||||||
))}
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions>
|
|
||||||
<Button autoFocus onClick={dialogToggle}>
|
|
||||||
Close
|
|
||||||
</Button>
|
|
||||||
</DialogActions>
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { useState } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import useMediaQuery from "@mui/material/useMediaQuery";
|
import useMediaQuery from "@mui/material/useMediaQuery";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
|
@ -19,19 +19,22 @@ export default function RconDialog(props) {
|
||||||
const { server, open, dialogToggle } = props;
|
const { server, open, dialogToggle } = props;
|
||||||
const { name: serverName, id: serverId } = server ?? {};
|
const { name: serverName, id: serverId } = server ?? {};
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const fullScreen = useMediaQuery(theme.breakpoints.down("md"));
|
const fullScreen = useMediaQuery(theme.breakpoints.down("sm"));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
fullWidth
|
sx={
|
||||||
maxWidth="lg"
|
fullScreen
|
||||||
|
? {}
|
||||||
|
: { "& .mcl-MuiDialog-paper": { width: "80%", maxHeight: 555 } }
|
||||||
|
}
|
||||||
|
maxWidth="xs"
|
||||||
open={open}
|
open={open}
|
||||||
fullScreen={fullScreen}
|
fullScreen={fullScreen}
|
||||||
PaperProps={!fullScreen ? { sx: { height: "60%" } } : undefined}
|
|
||||||
>
|
>
|
||||||
<Toolbar sx={{ display: { md: "none" } }} />
|
<Toolbar sx={{ display: { sm: "none" } }} />
|
||||||
<DialogTitle>RCON - {serverName}</DialogTitle>
|
<DialogTitle>RCON - {serverName}</DialogTitle>
|
||||||
<DialogContent sx={{ height: "100%" }}>
|
<DialogContent>
|
||||||
<RconView serverId={serverId} />
|
<RconView serverId={serverId} />
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
|
|
|
@ -8,7 +8,6 @@ export default class RconSocket {
|
||||||
this.sk.on("rcon-error", this.onRconError.bind(this));
|
this.sk.on("rcon-error", this.onRconError.bind(this));
|
||||||
this.sk.on("error", () => console.log("WHOOSPSIE I GUESS?"));
|
this.sk.on("error", () => console.log("WHOOSPSIE I GUESS?"));
|
||||||
this.rconLive = false;
|
this.rconLive = false;
|
||||||
this.rconError = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onPush(p) {
|
onPush(p) {
|
||||||
|
@ -23,8 +22,7 @@ export default class RconSocket {
|
||||||
|
|
||||||
onRconError(v) {
|
onRconError(v) {
|
||||||
this.rconLive = false;
|
this.rconLive = false;
|
||||||
this.rconError = true;
|
console.log("Server sent" + v);
|
||||||
console.log("Server sent: ", v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onConnect() {
|
onConnect() {
|
||||||
|
|
|
@ -2,21 +2,9 @@ import { useState, useEffect, useRef } from "react";
|
||||||
import Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
import Skeleton from "@mui/material/Skeleton";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import RconSocket from "./RconSocket.js";
|
import RconSocket from "./RconSocket.js";
|
||||||
import "@mcl/css/rcon.css";
|
import "@mcl/css/rcon.css";
|
||||||
|
|
||||||
function RconLogSkeleton() {
|
|
||||||
return (
|
|
||||||
<Skeleton
|
|
||||||
variant="text"
|
|
||||||
width="100%"
|
|
||||||
sx={{ backgroundColor: "rgba(255,255,255,.25)" }}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function RconView(props) {
|
export default function RconView(props) {
|
||||||
const { serverId } = props;
|
const { serverId } = props;
|
||||||
const logsRef = useRef(0);
|
const logsRef = useRef(0);
|
||||||
|
@ -51,47 +39,26 @@ export default function RconView(props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ height: "100%", display: "flex", flexWrap: "wrap" }}>
|
<Box>
|
||||||
<Box
|
<div className="rconLogsWrapper" ref={logsRef}>
|
||||||
className="rconLogsWrapper"
|
{logs.map((v, k) => (
|
||||||
ref={logsRef}
|
|
||||||
style={{
|
|
||||||
padding: "1rem",
|
|
||||||
backgroundColor: "rgba(0,0,0,.815)",
|
|
||||||
color: "white",
|
|
||||||
borderRadius: "4px",
|
|
||||||
width: "100%",
|
|
||||||
height: "100%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{logs.length === 0 &&
|
|
||||||
[...Array(20).keys()].map((_v, i) => <RconLogSkeleton key={i} />)}
|
|
||||||
{logs.length > 0 &&
|
|
||||||
logs.map((v, k) => (
|
|
||||||
<Box key={k}>
|
<Box key={k}>
|
||||||
<Typography variant="subtitle2">{v}</Typography>
|
{v}
|
||||||
|
<br />
|
||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</div>
|
||||||
<Box
|
<Box className="rconActions">
|
||||||
className="rconActions"
|
|
||||||
sx={{ marginTop: "auto", paddingTop: "1rem", width: "100%" }}
|
|
||||||
>
|
|
||||||
<TextField
|
<TextField
|
||||||
id="outlined-basic"
|
id="outlined-basic"
|
||||||
label="Command"
|
label="Command"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={cmd}
|
value={cmd}
|
||||||
onChange={updateCmd}
|
onChange={updateCmd}
|
||||||
disabled={!(rcon && rcon.rconLive && !rcon.rconError)}
|
disabled={!(rcon && rcon.rconLive)}
|
||||||
sx={{ width: "100%" }}
|
|
||||||
/>
|
/>
|
||||||
{rcon && rcon.rconLive && !rcon.rconError && (
|
{rcon && rcon.rconLive && <Button onClick={sendCommand}>Send</Button>}
|
||||||
<Button onClick={sendCommand} sx={{ padding: "0 2rem" }}>
|
{!(rcon && rcon.rconLive) && (
|
||||||
Send
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
{!(rcon && rcon.rconLive && !rcon.rconError) && (
|
|
||||||
<Button color="secondary">Not Connected</Button>
|
<Button color="secondary">Not Connected</Button>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
@ -14,11 +14,10 @@ import PlayArrowIcon from "@mui/icons-material/PlayArrow";
|
||||||
import DeleteForeverIcon from "@mui/icons-material/DeleteForever";
|
import DeleteForeverIcon from "@mui/icons-material/DeleteForever";
|
||||||
import EditIcon from "@mui/icons-material/Edit";
|
import EditIcon from "@mui/icons-material/Edit";
|
||||||
import FolderIcon from "@mui/icons-material/Folder";
|
import FolderIcon from "@mui/icons-material/Folder";
|
||||||
import BackupIcon from "@mui/icons-material/Backup";
|
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
export default function ServerCard(props) {
|
export default function ServerCard(props) {
|
||||||
const { server, openRcon, openBackups } = props;
|
const { server, openRcon } = props;
|
||||||
const { name, id, metrics, ftpAvailable, serverAvailable, services } = server;
|
const { name, id, metrics, ftpAvailable, serverAvailable, services } = server;
|
||||||
const startServer = useStartServer(id);
|
const startServer = useStartServer(id);
|
||||||
const stopServer = useStopServer(id);
|
const stopServer = useStopServer(id);
|
||||||
|
@ -118,14 +117,6 @@ export default function ServerCard(props) {
|
||||||
>
|
>
|
||||||
<EditIcon />
|
<EditIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton
|
|
||||||
color="info"
|
|
||||||
aria-label="Backups"
|
|
||||||
size="large"
|
|
||||||
onClick={openBackups}
|
|
||||||
>
|
|
||||||
<BackupIcon />
|
|
||||||
</IconButton>
|
|
||||||
<IconButton
|
<IconButton
|
||||||
color="info"
|
color="info"
|
||||||
aria-label="Files"
|
aria-label="Files"
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
.rconLogsWrapper {
|
.rconLogsWrapper {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
max-height: calc(100% - 6rem);
|
max-height: 20rem;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
.rconActions {
|
.rconActions {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
|
|
@ -10,7 +10,6 @@ const defaultSettings = {
|
||||||
simplifiedControls: false,
|
simplifiedControls: false,
|
||||||
logAppDetails: true,
|
logAppDetails: true,
|
||||||
defaultPage: "home",
|
defaultPage: "home",
|
||||||
cairoAuth: null,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const settings = localSettings ? JSON.parse(localSettings) : defaultSettings;
|
const settings = localSettings ? JSON.parse(localSettings) : defaultSettings;
|
||||||
|
@ -28,7 +27,6 @@ const settingsUpdater = (oldState, settingsUpdate) => {
|
||||||
if (settingsUpdate[k] === undefined) continue;
|
if (settingsUpdate[k] === undefined) continue;
|
||||||
settingsToUpdate[k] = settingsUpdate[k];
|
settingsToUpdate[k] = settingsUpdate[k];
|
||||||
}
|
}
|
||||||
console.log("SAVING", settingsToUpdate);
|
|
||||||
localStorage.setItem("settings", JSON.stringify(settingsToUpdate));
|
localStorage.setItem("settings", JSON.stringify(settingsToUpdate));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
|
import Box from "@mui/material/Box";
|
||||||
import Toolbar from "@mui/material/Toolbar";
|
import Toolbar from "@mui/material/Toolbar";
|
||||||
import MCLPortal from "./MCLPortal.jsx";
|
import MCLPortal from "./MCLPortal.jsx";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
import SpeedDialIcon from "@mui/material/SpeedDialIcon";
|
||||||
// Import Navbar
|
// Import Navbar
|
||||||
/*import Navbar from "./Navbar.jsx";*/
|
/*import Navbar from "./Navbar.jsx";*/
|
||||||
import { useCairoAuth } from "@mcl/util/auth.js";
|
|
||||||
import MCLMenu from "./MCLMenu.jsx";
|
import MCLMenu from "./MCLMenu.jsx";
|
||||||
import Auth from "@mcl/pages/Auth.jsx";
|
|
||||||
|
|
||||||
export default function Views() {
|
export default function Views() {
|
||||||
const auth = useCairoAuth();
|
|
||||||
if (!auth) return <Auth />;
|
|
||||||
return (
|
return (
|
||||||
<div className="view">
|
<div className="view">
|
||||||
<MCLMenu />
|
<MCLMenu />
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
import { useState, useEffect } from "react";
|
|
||||||
import { useSearchParams, useNavigate } from "react-router-dom";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Button from "@mui/material/Button";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
|
|
||||||
export default function Auth() {
|
|
||||||
const [searchParams] = useSearchParams();
|
|
||||||
const currentServer = searchParams.get("token");
|
|
||||||
|
|
||||||
const nav = useNavigate();
|
|
||||||
|
|
||||||
const cairoLogin = () =>
|
|
||||||
(window.location.href = `/api/auth/redirect?redirectUri=${window.location.href}`);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box
|
|
||||||
className="auth"
|
|
||||||
sx={{
|
|
||||||
height: "100%",
|
|
||||||
backgroundColor: (theme) => theme.palette.primary.main,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box className="auth-display" sx={{ display: "flex", height: "95vh" }}>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
height: "50%",
|
|
||||||
width: "50%",
|
|
||||||
m: "auto",
|
|
||||||
display: "flex",
|
|
||||||
flexWrap: "wrap",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
backgroundColor: "white",
|
|
||||||
display: "inline-flex",
|
|
||||||
m: "auto",
|
|
||||||
borderRadius: "8px",
|
|
||||||
height: "5rem",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
color="secondary"
|
|
||||||
variant="outlined"
|
|
||||||
onClick={cairoLogin}
|
|
||||||
sx={{ p: "1.5rem" }}
|
|
||||||
endIcon={
|
|
||||||
<img
|
|
||||||
src="https://cairo.dunemask.net/cairo/icons/apple-touch-icon-120x120.png"
|
|
||||||
width="48px"
|
|
||||||
style={{ borderRadius: "4px" }}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Login with Cairo
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -22,7 +22,6 @@ import MemoryOption, {
|
||||||
memoryOptions,
|
memoryOptions,
|
||||||
} from "@mcl/components/server-options/MemoryOption.jsx";
|
} from "@mcl/components/server-options/MemoryOption.jsx";
|
||||||
import ExtraPortsOption from "@mcl/components/server-options/ExtraPortsOption.jsx";
|
import ExtraPortsOption from "@mcl/components/server-options/ExtraPortsOption.jsx";
|
||||||
import StorageOption from "@mcl/components/server-options/StorageOption.jsx";
|
|
||||||
|
|
||||||
import BackupHostOption from "@mcl/components/server-options/BackupHostOption.jsx";
|
import BackupHostOption from "@mcl/components/server-options/BackupHostOption.jsx";
|
||||||
import BackupBucketOption from "@mcl/components/server-options/BackupBucketOption.jsx";
|
import BackupBucketOption from "@mcl/components/server-options/BackupBucketOption.jsx";
|
||||||
|
@ -37,7 +36,6 @@ const defaultServer = {
|
||||||
serverType: serverTypeOptions[0],
|
serverType: serverTypeOptions[0],
|
||||||
cpu: cpuOptions[0],
|
cpu: cpuOptions[0],
|
||||||
memory: memoryOptions[2], // 1.5GB
|
memory: memoryOptions[2], // 1.5GB
|
||||||
storage: 0,
|
|
||||||
extraPorts: [],
|
extraPorts: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,9 +99,7 @@ export default function CreateCoreOptions() {
|
||||||
/>
|
/>
|
||||||
<CpuOption value={spec.cpu} onChange={coreUpdate("cpu")} />
|
<CpuOption value={spec.cpu} onChange={coreUpdate("cpu")} />
|
||||||
<MemoryOption value={spec.memory} onChange={coreUpdate("memory")} />
|
<MemoryOption value={spec.memory} onChange={coreUpdate("memory")} />
|
||||||
<StorageOption value={spec.storage} onChange={coreUpdate("storage")} />
|
|
||||||
<ExtraPortsOption onChange={updateSpec} />
|
<ExtraPortsOption onChange={updateSpec} />
|
||||||
{spec.storage !== 0 && (
|
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
control={
|
control={
|
||||||
<Switch
|
<Switch
|
||||||
|
@ -116,8 +112,7 @@ export default function CreateCoreOptions() {
|
||||||
labelPlacement="start"
|
labelPlacement="start"
|
||||||
sx={{ mr: "auto" }}
|
sx={{ mr: "auto" }}
|
||||||
/>
|
/>
|
||||||
)}
|
{backupEnabled && (
|
||||||
{backupEnabled && spec.storage !== 0 && (
|
|
||||||
<FormControl
|
<FormControl
|
||||||
fullWidth
|
fullWidth
|
||||||
sx={{ mt: "2rem", display: "flex", gap: ".5rem" }}
|
sx={{ mt: "2rem", display: "flex", gap: ".5rem" }}
|
||||||
|
|
|
@ -35,7 +35,6 @@ export default function EditCoreOptions(props) {
|
||||||
const { serverId } = props;
|
const { serverId } = props;
|
||||||
const [spec, setSpec] = useState();
|
const [spec, setSpec] = useState();
|
||||||
const modifyServer = useModifyServer(spec);
|
const modifyServer = useModifyServer(spec);
|
||||||
const nav = useNavigate();
|
|
||||||
const { isLoading, data: serverBlueprint } = useGetServer(serverId);
|
const { isLoading, data: serverBlueprint } = useGetServer(serverId);
|
||||||
|
|
||||||
useEffect(() => setSpec(serverBlueprint), [serverBlueprint]);
|
useEffect(() => setSpec(serverBlueprint), [serverBlueprint]);
|
||||||
|
@ -48,7 +47,9 @@ export default function EditCoreOptions(props) {
|
||||||
|
|
||||||
const coreUpdate = (attr) => (e) => updateSpec(attr, e.target.value);
|
const coreUpdate = (attr) => (e) => updateSpec(attr, e.target.value);
|
||||||
|
|
||||||
const upsertSpec = () => modifyServer().then(() => nav("/"));
|
const upsertSpec = () => {
|
||||||
|
modifyServer(spec);
|
||||||
|
};
|
||||||
|
|
||||||
const toggleBackupEnabled = () =>
|
const toggleBackupEnabled = () =>
|
||||||
updateSpec("backupEnabled", !spec.backupEnabled);
|
updateSpec("backupEnabled", !spec.backupEnabled);
|
||||||
|
@ -73,11 +74,7 @@ export default function EditCoreOptions(props) {
|
||||||
>
|
>
|
||||||
<FormControl fullWidth sx={{ mt: "2rem", display: "flex", gap: ".5rem" }}>
|
<FormControl fullWidth sx={{ mt: "2rem", display: "flex", gap: ".5rem" }}>
|
||||||
<NameOption value={spec.name} onChange={coreUpdate("name")} />
|
<NameOption value={spec.name} onChange={coreUpdate("name")} />
|
||||||
<HostOption
|
<HostOption value={spec.host} onChange={coreUpdate("host")} />
|
||||||
value={spec.host}
|
|
||||||
onChange={coreUpdate("host")}
|
|
||||||
disabled={true}
|
|
||||||
/>
|
|
||||||
<VersionOption value={spec.version} onChange={coreUpdate("version")} />
|
<VersionOption value={spec.version} onChange={coreUpdate("version")} />
|
||||||
<ServerTypeOption
|
<ServerTypeOption
|
||||||
value={spec.serverType}
|
value={spec.serverType}
|
||||||
|
|
|
@ -12,16 +12,12 @@ import SpeedDialIcon from "@mui/material/SpeedDialIcon";
|
||||||
import "@mcl/css/server-card.css";
|
import "@mcl/css/server-card.css";
|
||||||
import "@mcl/css/overview.css";
|
import "@mcl/css/overview.css";
|
||||||
import { useServerInstances } from "@mcl/queries";
|
import { useServerInstances } from "@mcl/queries";
|
||||||
import BackupDialog, {
|
|
||||||
useBackupDialog,
|
|
||||||
} from "../components/servers/BackupsDialog";
|
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const clusterMetrics = { cpu: 0, memory: 0 };
|
const clusterMetrics = { cpu: 0, memory: 0 };
|
||||||
const [server, setServer] = useState();
|
const [server, setServer] = useState();
|
||||||
const [servers, setServers] = useState([]);
|
const [servers, setServers] = useState([]);
|
||||||
const [rdOpen, rconToggle] = useRconDialog();
|
const [rdOpen, rconToggle] = useRconDialog();
|
||||||
const [bkOpen, backupsToggle] = useBackupDialog();
|
|
||||||
const { isLoading, data: serversData } = useServerInstances();
|
const { isLoading, data: serversData } = useServerInstances();
|
||||||
const serverInstances = serversData ?? [];
|
const serverInstances = serversData ?? [];
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -35,11 +31,6 @@ export default function Home() {
|
||||||
rconToggle();
|
rconToggle();
|
||||||
};
|
};
|
||||||
|
|
||||||
const openBackups = (s) => () => {
|
|
||||||
setServer(s);
|
|
||||||
backupsToggle();
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className="home">
|
<Box className="home">
|
||||||
<Overview clusterMetrics={clusterMetrics} />
|
<Overview clusterMetrics={clusterMetrics} />
|
||||||
|
@ -60,20 +51,10 @@ export default function Home() {
|
||||||
<Box className="servers">
|
<Box className="servers">
|
||||||
{!isLoading &&
|
{!isLoading &&
|
||||||
servers.map((s, k) => (
|
servers.map((s, k) => (
|
||||||
<ServerCard
|
<ServerCard key={k} server={s} openRcon={openRcon(s)} />
|
||||||
key={k}
|
|
||||||
server={s}
|
|
||||||
openRcon={openRcon(s)}
|
|
||||||
openBackups={openBackups(s)}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
<RconDialog open={rdOpen} dialogToggle={rconToggle} server={server} />
|
<RconDialog open={rdOpen} dialogToggle={rconToggle} server={server} />
|
||||||
<BackupDialog
|
|
||||||
open={bkOpen}
|
|
||||||
dialogToggle={backupsToggle}
|
|
||||||
serverId={server?.id}
|
|
||||||
/>
|
|
||||||
<Button
|
<Button
|
||||||
component={Link}
|
component={Link}
|
||||||
to="/mcl/create"
|
to="/mcl/create"
|
||||||
|
|
|
@ -1,47 +0,0 @@
|
||||||
import { useState, useEffect } from "react";
|
|
||||||
import { useSearchParams } from "react-router-dom";
|
|
||||||
|
|
||||||
const tokenStorageName = "cairoUserToken";
|
|
||||||
const tokenQuery = "cairoUserToken";
|
|
||||||
|
|
||||||
const verifyAuth = (authToken) =>
|
|
||||||
fetch("/api/auth/verify", {
|
|
||||||
headers: { Authorization: `Bearer ${authToken}` },
|
|
||||||
})
|
|
||||||
.then((res) => res.status === 200)
|
|
||||||
.catch(() => false);
|
|
||||||
|
|
||||||
export function useCairoAuth() {
|
|
||||||
const [authToken, setAuthToken] = useState(
|
|
||||||
localStorage.getItem(tokenStorageName),
|
|
||||||
);
|
|
||||||
const [auth, setAuth] = useState(false);
|
|
||||||
const [searchParams, setSearchParams] = useSearchParams();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!authToken) return;
|
|
||||||
verifyAuth(authToken).then((authorized) => {
|
|
||||||
if (!authorized) localStorage.removeItem(tokenStorageName);
|
|
||||||
setAuth(authorized);
|
|
||||||
});
|
|
||||||
}, [authToken]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const webToken = searchParams.get(tokenQuery);
|
|
||||||
if (!webToken) return;
|
|
||||||
localStorage.setItem(tokenStorageName, webToken);
|
|
||||||
searchParams.delete(tokenQuery);
|
|
||||||
setAuthToken(webToken);
|
|
||||||
setSearchParams(searchParams);
|
|
||||||
}, [searchParams]);
|
|
||||||
|
|
||||||
return auth;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAuthTokenFromStorage() {
|
|
||||||
return localStorage.getItem(tokenStorageName);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function cairoAuthHeader() {
|
|
||||||
return { Authorization: `Bearer ${getAuthTokenFromStorage()}` };
|
|
||||||
}
|
|
|
@ -1,17 +1,12 @@
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { cairoAuthHeader } from "@mcl/util/auth.js";
|
|
||||||
|
|
||||||
const fetchApi = (subPath) => async () =>
|
const fetchApi = (subPath) => async () =>
|
||||||
fetch(`/api${subPath}`, { headers: cairoAuthHeader() }).then((res) =>
|
fetch(`/api${subPath}`).then((res) => res.json());
|
||||||
res.json(),
|
|
||||||
);
|
|
||||||
|
|
||||||
const fetchApiCore = async (subPath, json, method = "POST", jsonify = false) =>
|
const fetchApiCore = async (subPath, json, method = "POST", jsonify = false) =>
|
||||||
fetch(`/api${subPath}`, {
|
fetch(`/api${subPath}`, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
...cairoAuthHeader(),
|
|
||||||
},
|
},
|
||||||
body: JSON.stringify(json),
|
body: JSON.stringify(json),
|
||||||
}).then((res) => (jsonify ? res.json() : res));
|
}).then((res) => (jsonify ? res.json() : res));
|
||||||
|
@ -21,7 +16,6 @@ const fetchApiPost = (subPath, json) => async () =>
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
...cairoAuthHeader(),
|
|
||||||
},
|
},
|
||||||
body: JSON.stringify(json),
|
body: JSON.stringify(json),
|
||||||
}).then((res) => res.json());
|
}).then((res) => res.json());
|
||||||
|
@ -54,11 +48,6 @@ export const useGetServer = (serverId) =>
|
||||||
queryFn: fetchApiPost("/server/blueprint", { id: serverId }),
|
queryFn: fetchApiPost("/server/blueprint", { id: serverId }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getServerBackups = (serverId) =>
|
|
||||||
fetchApiCore("/s3/backups", { id: serverId }, "POST", true);
|
|
||||||
export const getBackupUrl = (serverId, backupPath) =>
|
|
||||||
fetchApiCore("/s3/backup-url", { id: serverId, backupPath }, "POST", true);
|
|
||||||
|
|
||||||
export const getServerFiles = async (serverId, path) =>
|
export const getServerFiles = async (serverId, path) =>
|
||||||
fetchApiCore("/files/list", { id: serverId, path }, "POST", true);
|
fetchApiCore("/files/list", { id: serverId, path }, "POST", true);
|
||||||
export const createServerFolder = async (serverId, path) =>
|
export const createServerFolder = async (serverId, path) =>
|
||||||
|
@ -69,13 +58,6 @@ export const createServerFolder = async (serverId, path) =>
|
||||||
export const deleteServerItem = async (serverId, path, isDir) =>
|
export const deleteServerItem = async (serverId, path, isDir) =>
|
||||||
fetchApiCore("/files/item", { id: serverId, path, isDir }, "DELETE");
|
fetchApiCore("/files/item", { id: serverId, path, isDir }, "DELETE");
|
||||||
|
|
||||||
export const moveServerItems = async (serverId, files, destination, origin) =>
|
|
||||||
fetchApiCore(
|
|
||||||
"/files/move",
|
|
||||||
{ id: serverId, files, destination, origin },
|
|
||||||
"POST",
|
|
||||||
);
|
|
||||||
|
|
||||||
export async function previewServerItem(serverId, path) {
|
export async function previewServerItem(serverId, path) {
|
||||||
const resp = await fetchApiCore("/files/item", { id: serverId, path });
|
const resp = await fetchApiCore("/files/item", { id: serverId, path });
|
||||||
if (resp.status !== 200) return console.log("AHHHH");
|
if (resp.status !== 200) return console.log("AHHHH");
|
||||||
|
@ -135,7 +117,6 @@ const postJsonApi = (subPath, body, invalidate, method = "POST") => {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
...cairoAuthHeader(),
|
|
||||||
},
|
},
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
{{- if and (.Values.serviceAccount.create) (.Values.serviceAccount.clusterWide) -}}
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: ClusterRoleBinding
|
|
||||||
metadata:
|
|
||||||
name: {{ include "minecluster.serviceAccountName" . }}
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: {{ include "minecluster.serviceAccountName" . }}
|
|
||||||
namespace: {{ .Values.mcl.deploymentNamespace | default .Release.Namespace }}
|
|
||||||
roleRef:
|
|
||||||
kind: ClusterRole
|
|
||||||
name: {{ include "minecluster.serviceAccountName" . }}
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
{{- end }}
|
|
|
@ -1,27 +0,0 @@
|
||||||
{{- if and (.Values.serviceAccount.create) (.Values.serviceAccount.clusterWide) -}}
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: ClusterRole
|
|
||||||
metadata:
|
|
||||||
name: {{ include "minecluster.serviceAccountName" . }}
|
|
||||||
rules:
|
|
||||||
- apiGroups: ["apps"]
|
|
||||||
resources:
|
|
||||||
- deployments
|
|
||||||
verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources:
|
|
||||||
- nodes
|
|
||||||
verbs: ["list"]
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources:
|
|
||||||
- services
|
|
||||||
- pods
|
|
||||||
- pods/log
|
|
||||||
- containers
|
|
||||||
- persistentvolumeclaims
|
|
||||||
- secrets
|
|
||||||
verbs: ["get", "list", "watch", "create", "patch", "update", "delete"]
|
|
||||||
- apiGroups: ["metrics.k8s.io"]
|
|
||||||
resources: ["pods"]
|
|
||||||
verbs: ["list"]
|
|
||||||
{{- end }}
|
|
|
@ -15,7 +15,6 @@ nameOverride: ""
|
||||||
fullnameOverride: ""
|
fullnameOverride: ""
|
||||||
|
|
||||||
serviceAccount:
|
serviceAccount:
|
||||||
clusterWide: false
|
|
||||||
# Specifies whether a service account should be created
|
# Specifies whether a service account should be created
|
||||||
create: true
|
create: true
|
||||||
# Annotations to add to the service account
|
# Annotations to add to the service account
|
||||||
|
|