2021-09-13 20:37:35 -04:00
|
|
|
import React, { useState } from "react";
|
|
|
|
|
2021-09-16 19:23:03 -04:00
|
|
|
import Accordion from "@mui/material/Accordion";
|
|
|
|
import AccordionSummary from "@mui/material/AccordionSummary";
|
|
|
|
import AccordionDetails from "@mui/material/AccordionDetails";
|
|
|
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
2021-09-13 20:37:35 -04:00
|
|
|
|
2021-09-30 20:06:40 -04:00
|
|
|
import Typography from "@mui/material/Typography";
|
2021-09-16 19:23:03 -04:00
|
|
|
import Button from "@mui/material/Button";
|
|
|
|
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
2021-10-07 16:56:01 -04:00
|
|
|
import { GetServer, GetAllServers } from "../../Server/AllServers";
|
2021-10-07 16:04:04 -04:00
|
|
|
import { Server } from "../../Server/Server";
|
2021-09-16 19:23:03 -04:00
|
|
|
import MenuItem from "@mui/material/MenuItem";
|
2021-09-13 20:37:35 -04:00
|
|
|
|
2023-06-27 04:29:44 +02:00
|
|
|
export function ServersDev(): React.ReactElement {
|
2021-09-13 20:37:35 -04:00
|
|
|
const [server, setServer] = useState("home");
|
2023-05-05 03:55:59 -04:00
|
|
|
function setServerDropdown(event: SelectChangeEvent): void {
|
2022-05-28 21:35:20 -05:00
|
|
|
setServer(event.target.value);
|
2021-09-13 20:37:35 -04:00
|
|
|
}
|
|
|
|
function rootServer(): void {
|
2021-10-07 16:56:01 -04:00
|
|
|
const s = GetServer(server);
|
2021-09-13 20:37:35 -04:00
|
|
|
if (s === null) return;
|
2021-10-07 16:04:04 -04:00
|
|
|
if (!(s instanceof Server)) return;
|
2021-09-13 20:37:35 -04:00
|
|
|
s.hasAdminRights = true;
|
|
|
|
s.sshPortOpen = true;
|
|
|
|
s.ftpPortOpen = true;
|
|
|
|
s.smtpPortOpen = true;
|
|
|
|
s.httpPortOpen = true;
|
|
|
|
s.sqlPortOpen = true;
|
|
|
|
s.openPortCount = 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
function rootAllServers(): void {
|
2021-10-07 16:04:04 -04:00
|
|
|
for (const s of GetAllServers()) {
|
|
|
|
if (!(s instanceof Server)) return;
|
2021-09-13 20:37:35 -04:00
|
|
|
s.hasAdminRights = true;
|
|
|
|
s.sshPortOpen = true;
|
|
|
|
s.ftpPortOpen = true;
|
|
|
|
s.smtpPortOpen = true;
|
|
|
|
s.httpPortOpen = true;
|
|
|
|
s.sqlPortOpen = true;
|
|
|
|
s.openPortCount = 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-18 04:23:47 -08:00
|
|
|
function backdoorServer(): void {
|
|
|
|
const s = GetServer(server);
|
|
|
|
if (s === null) return;
|
|
|
|
if (!(s instanceof Server)) return;
|
|
|
|
s.backdoorInstalled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function backdoorAllServers(): void {
|
|
|
|
for (const s of GetAllServers()) {
|
|
|
|
if (!(s instanceof Server)) return;
|
|
|
|
s.backdoorInstalled = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-13 20:37:35 -04:00
|
|
|
function minSecurity(): void {
|
2021-10-07 16:56:01 -04:00
|
|
|
const s = GetServer(server);
|
2021-09-13 20:37:35 -04:00
|
|
|
if (s === null) return;
|
2021-10-07 16:04:04 -04:00
|
|
|
if (!(s instanceof Server)) return;
|
2021-09-13 20:37:35 -04:00
|
|
|
s.hackDifficulty = s.minDifficulty;
|
|
|
|
}
|
|
|
|
|
|
|
|
function minAllSecurity(): void {
|
2021-10-07 16:04:04 -04:00
|
|
|
for (const s of GetAllServers()) {
|
|
|
|
if (!(s instanceof Server)) return;
|
|
|
|
s.hackDifficulty = s.minDifficulty;
|
2021-09-13 20:37:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function maxMoney(): void {
|
2021-10-07 16:56:01 -04:00
|
|
|
const s = GetServer(server);
|
2021-09-13 20:37:35 -04:00
|
|
|
if (s === null) return;
|
2021-10-07 16:04:04 -04:00
|
|
|
if (!(s instanceof Server)) return;
|
2021-09-13 20:37:35 -04:00
|
|
|
s.moneyAvailable = s.moneyMax;
|
|
|
|
}
|
|
|
|
|
|
|
|
function maxAllMoney(): void {
|
2021-10-07 16:04:04 -04:00
|
|
|
for (const s of GetAllServers()) {
|
|
|
|
if (!(s instanceof Server)) return;
|
|
|
|
s.moneyAvailable = s.moneyMax;
|
2021-09-13 20:37:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-22 01:12:08 +00:00
|
|
|
function minMoney(): void {
|
|
|
|
const s = GetServer(server);
|
|
|
|
if (s === null) return;
|
|
|
|
if (!(s instanceof Server)) return;
|
|
|
|
s.moneyAvailable = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function minAllMoney(): void {
|
|
|
|
for (const s of GetAllServers()) {
|
|
|
|
if (!(s instanceof Server)) return;
|
|
|
|
s.moneyAvailable = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-13 20:37:35 -04:00
|
|
|
return (
|
2021-09-17 21:30:02 -04:00
|
|
|
<Accordion TransitionProps={{ unmountOnExit: true }}>
|
2021-09-13 20:37:35 -04:00
|
|
|
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
2021-10-01 16:22:33 -04:00
|
|
|
<Typography>Servers</Typography>
|
2021-09-13 20:37:35 -04:00
|
|
|
</AccordionSummary>
|
|
|
|
<AccordionDetails>
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>
|
2021-09-30 20:06:40 -04:00
|
|
|
<Typography>Server:</Typography>
|
2021-09-13 20:37:35 -04:00
|
|
|
</td>
|
|
|
|
<td colSpan={2}>
|
2021-09-29 01:49:22 -04:00
|
|
|
<Select id="dev-servers-dropdown" onChange={setServerDropdown} value={server}>
|
2021-10-07 16:04:04 -04:00
|
|
|
{GetAllServers().map((server) => (
|
2021-09-13 20:37:35 -04:00
|
|
|
<MenuItem key={server.hostname} value={server.hostname}>
|
|
|
|
{server.hostname}
|
|
|
|
</MenuItem>
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>
|
2021-09-30 20:06:40 -04:00
|
|
|
<Typography>Root:</Typography>
|
2021-09-13 20:37:35 -04:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button onClick={rootServer}>Root one</Button>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button onClick={rootAllServers}>Root all</Button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2023-12-18 04:23:47 -08:00
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<Typography>Backdoor:</Typography>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button onClick={backdoorServer}>Backdoor one</Button>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button onClick={backdoorAllServers}>Backdoor all</Button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2021-09-13 20:37:35 -04:00
|
|
|
<tr>
|
|
|
|
<td>
|
2021-09-30 20:06:40 -04:00
|
|
|
<Typography>Security:</Typography>
|
2021-09-13 20:37:35 -04:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button onClick={minSecurity}>Min one</Button>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button onClick={minAllSecurity}>Min all</Button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>
|
2021-09-30 20:06:40 -04:00
|
|
|
<Typography>Money:</Typography>
|
2021-09-13 20:37:35 -04:00
|
|
|
</td>
|
2021-12-22 01:12:08 +00:00
|
|
|
<td>
|
|
|
|
<Button onClick={minMoney}>Min one</Button>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button onClick={minAllMoney}>Min all</Button>
|
|
|
|
</td>
|
2021-09-13 20:37:35 -04:00
|
|
|
<td>
|
|
|
|
<Button onClick={maxMoney}>Max one</Button>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button onClick={maxAllMoney}>Max all</Button>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</AccordionDetails>
|
|
|
|
</Accordion>
|
|
|
|
);
|
|
|
|
}
|