Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unstable #190

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b0bc6b6
[skip ci] pre-0.14
azukaar Nov 27, 2023
e46dc10
[skip ci] pre-0.14
azukaar Jan 21, 2024
a287640
[skip ci] pre-0.14
azukaar Jan 21, 2024
451fe2d
Fixed XSS (#184)
Kawanaao Jan 21, 2024
a13b7e8
[skip ci] pre-0.14
azukaar Jan 22, 2024
5cae6d9
[release] v0.14.0-unstable1
azukaar Jan 23, 2024
fcf9862
[release] v0.14.0-unstable2
azukaar Jan 23, 2024
f20ad6d
[skip ci] park lungo
azukaar Jan 26, 2024
918ff46
[skip ci] park lungo
azukaar Jan 28, 2024
a91cfa8
[release] v0.14.0-unstable3
azukaar Jan 28, 2024
268ea68
[release] v0.14.0-unstable4
azukaar Jan 28, 2024
3f52fa9
[release] v0.14.0-unstable5
azukaar Jan 28, 2024
6abf24d
[release] v0.14.0-unstable6
azukaar Jan 28, 2024
d886a86
[release] v0.14.0-unstable7
azukaar Jan 28, 2024
c49a2b4
[release] v0.14.0-unstable8
azukaar Jan 28, 2024
0b63ded
[release] v0.14.0-unstable9
azukaar Jan 28, 2024
80bc5a7
[release] v0.14.0-unstable10
azukaar Jan 28, 2024
8f6ee67
[release] v0.14.0-unstable11
azukaar Jan 28, 2024
5a0e81b
[release] v0.14.0-unstable12
azukaar Feb 2, 2024
87c1636
[skip ci] Optimizations/react (#186)
Kawanaao Feb 4, 2024
82074b5
[skip ci] merge PR
azukaar Feb 4, 2024
e4c7e19
[release] v0.14.0-unstable13
azukaar Feb 4, 2024
ebcd8fc
[release] v0.14.0-unstable14
azukaar Feb 4, 2024
e1c56e6
[release] v0.14.0-unstable15
azukaar Feb 4, 2024
b8ec9d6
[release] v0.14.0-unstable16
azukaar Feb 4, 2024
dc95a6c
[release] v0.14.0-unstable17
azukaar Feb 5, 2024
3db8f18
[release] v0.14.0-unstable18
azukaar Feb 5, 2024
f5046b6
[release] v0.14.0-unstable19
azukaar Feb 5, 2024
60fcbc1
[release] v0.14.0-unstable20
azukaar Feb 7, 2024
6aa0ffe
[release] v0.14.0-unstable21
azukaar Feb 8, 2024
2122d2d
[release] v0.14.0-unstable22
azukaar Feb 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clabot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"contributors": ["azukaar", "jwr1", "Jogai", "InterN0te", "catmandx", "revam"],
"contributors": ["azukaar", "jwr1", "Jogai", "InterN0te", "catmandx", "revam", "Kawanaao"],
"message": "We require contributors to sign our [Contributor License Agreement](https://github.com/azukaar/Cosmos-Server/blob/master/cla.md). In order for us to review and merge your code, add yourself to the .clabot file as contributor, as a way of signing the CLA."
}
25 changes: 25 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
## Version 0.14.0
- Cosmos is now fully functional dockerless
- Reworked Cosmos Compose for better compatibility with docker-compose.yml files
- Added a "compose" tab to edit containers in text mode
- Moved critical data (credentials and VPN) out of the database, to keep Cosmos online in case of incidents
- Added an auto .zip backup mechanism
- Added a syntax highlighter to the compose editor
- New Database "puppet" mode that allows Cosmos to manage the database for you
- Improved network IP resolution for containers, including supporting any network mode
- Added support for markets and template directly with docker-compose.yml files
- Add whitelist and constellation restriction options to the admin panel
- Force low RAM usage on the MongoDB container (we don't need much!)
- Removed all sort of container bootstrapping (much faster boot)
- Added image clean up
- Replaced network clean up by vanilla docker prune
- Fix issue with removing IP whitelist
- Add UI to create MCVlan networks
- Add a log file in config folder for the selfupdater
- Add a migration script to host mode
- UI optimizations (thanks @Kawanaao)
- Add duplicate filter on store listing
- Fixed an issue where container picker would select 'null' as container
- Fix bug where Enabled checkbox was broken after a search
- remove mac address when switching to host mode

## Version 0.13.2
- Fix display issue with fault network configurations

Expand Down
1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="expires" content="0">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cosmos</title>
Expand Down
18 changes: 18 additions & 0 deletions client/src/PrivateRoute.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Suspense } from "react"
import { Await, Navigate } from "react-router"
import isLoggedIn from "./isLoggedIn"

function PrivateRoute({ children }) {
return <Suspense>
<Await resolve={isLoggedIn()}>
{authStatus => {
switch (authStatus) {
case "OK": return children
default: return <Navigate to={authStatus} replace />
}
}}
</Await>
</Suspense>
}

export default PrivateRoute
4 changes: 2 additions & 2 deletions client/src/api/authentication.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function login(values) {
}

function me() {
return fetch('/cosmos/api/me/', {
return fetch('/cosmos/api/me', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
Expand All @@ -21,7 +21,7 @@ function me() {
}

function logout() {
return wrap(fetch('/cosmos/api/logout/', {
return wrap(fetch('/cosmos/api/logout', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
Expand Down
23 changes: 23 additions & 0 deletions client/src/api/docker.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import wrap from './wrap';
import yaml from 'js-yaml';

function list() {
return wrap(fetch('/cosmos/api/servapps', {
Expand Down Expand Up @@ -100,6 +101,16 @@ const manageContainer = (containerId, action) => {
}))
}

function migrateHost(values) {
return wrap(fetch('/cosmos/api/migrate-host', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(values),
}))
}

function updateContainer(containerId, values) {
return wrap(fetch('/cosmos/api/servapps/' + containerId + '/update', {
method: 'POST',
Expand All @@ -110,6 +121,16 @@ function updateContainer(containerId, values) {
}))
}

function exportContainer(containerId, values) {
return wrap(fetch('/cosmos/api/servapps/' + containerId + '/export', {
method: 'GET',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(values),
}))
}

function listContainerNetworks(containerId) {
return wrap(fetch('/cosmos/api/servapps/' + containerId + '/networks', {
method: 'GET',
Expand Down Expand Up @@ -348,4 +369,6 @@ export {
pullImage,
autoUpdate,
updateContainerImage,
exportContainer,
migrateHost,
};
12 changes: 11 additions & 1 deletion client/src/api/wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@ export default function wrap(apicall, noError = false) {
return apicall.then(async (response) => {
let rep;
try {
rep = await response.json();
rep = await response.text();

try {
rep = JSON.parse(rep);
} catch (err) {
rep = {
message: rep,
status: response.status,
code: response.status
};
}
} catch (err) {
if (!noError) {
snackit('Server error');
Expand Down
6 changes: 0 additions & 6 deletions client/src/components/MainCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ const MainCard = forwardRef(
':hover': {
boxShadow: boxShadow ? shadow || theme.customShadows.z1 : 'inherit'
},
'& pre': {
m: 0,
p: '16px !important',
fontFamily: theme.typography.fontFamily,
fontSize: '0.75rem'
}
}}
>
{/* card header and action */}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/apiModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const preStyle = {
padding: '10px',
borderRadius: '5px',
overflow: 'auto',
maxHeight: '500px',
maxHeight: '520px',
maxWidth: '100%',
width: '100%',
margin: '0',
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/logLine.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ function decodeUnicode(str) {
const LogLine = ({ message, docker, isMobile }) => {
let html = decodeUnicode(message)
.replace('\u0001\u0000\u0000\u0000\u0000\u0000\u0000', '')
.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;')
.replace(/(?:\r\n|\r|\n)/g, '<br>')
.replace(/ /g, '&nbsp;')
.replace(/�/g, '')
.replace(/\x1b\[([0-9]{1,2}(?:;[0-9]{1,2})*)?m/g, (match, p1) => {
if (!p1) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/logsInModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const preStyle = {
padding: '10px',
borderRadius: '5px',
overflow: 'auto',
maxHeight: '500px',
maxHeight: '520px',
maxWidth: '100%',
width: '100%',
margin: '0',
Expand Down
27 changes: 27 additions & 0 deletions client/src/components/persistentInput.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Checkbox } from "@mui/material";
import { useEffect } from "react";

export const PersistentCheckbox = ({ name, label, value, onChange }) => {
let eKey = "PersistentCheckbox-" + name;

useEffect(() => {
if (localStorage.getItem(eKey) === null) {
localStorage.setItem(eKey, value);
} else {
onChange(localStorage.getItem(eKey) === "true");
}
}, [name, value]);

const handleChange = (e) => {
onChange(e.target.checked);
localStorage.setItem(eKey, e.target.checked);
}

return (
<div style={{ display: 'flex', alignItems: 'center' }}>
<input type="checkbox" name={name} hidden value={value} checked={value} />
<Checkbox onChange={handleChange} checked={value} />
{label}
</div>
);
}
4 changes: 2 additions & 2 deletions client/src/components/third-party/Highlighter.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import PropTypes from 'prop-types';
import { useState } from 'react';
import { lazy, useState } from 'react';

// material-ui
import { Box, CardActions, Collapse, Divider, IconButton, Tooltip } from '@mui/material';

// third-party
import { CopyToClipboard } from 'react-copy-to-clipboard';
import reactElementToJSXString from 'react-element-to-jsx-string';
const reactElementToJSXString = lazy(() => import('react-element-to-jsx-string'));

// project import
import SyntaxHighlight from '../../utils/SyntaxHighlight';
Expand Down
36 changes: 18 additions & 18 deletions client/src/isLoggedIn.jsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@

import * as API from './api';
import { useEffect } from 'react';
import { redirectToLocal } from './utils/indexs';

const IsLoggedIn = () => useEffect(() => {
async function isLoggedIn() {
const urlSearch = encodeURIComponent(window.location.search);
const redirectToURL = (window.location.pathname + urlSearch);
const data = await API.auth.me();

API.auth.me().then((data) => {
if(data.status != 'OK') {
if(data.status == 'NEW_INSTALL') {
redirectToLocal('/cosmos-ui/newInstall');
} else if (data.status == 'error' && data.code == "HTTP004") {
redirectToLocal('/cosmos-ui/login?redirect=' + redirectToURL);
} else if (data.status == 'error' && data.code == "HTTP006") {
redirectToLocal('/cosmos-ui/loginmfa?redirect=' + redirectToURL);
} else if (data.status == 'error' && data.code == "HTTP007") {
redirectToLocal('/cosmos-ui/newmfa?redirect=' + redirectToURL);
}
}
})
}, []);
if (data.status == 'NEW_INSTALL') {
return '/cosmos-ui/newInstall';
} else if (data.status == 'error' && data.code == "HTTP004") {
return '/cosmos-ui/login?redirect=' + redirectToURL;
} else if (data.status == 'error' && data.code == "HTTP006") {
return '/cosmos-ui/loginmfa?redirect=' + redirectToURL;
} else if (data.status == 'error' && data.code == "HTTP007") {
return '/cosmos-ui/newmfa?redirect=' + redirectToURL;
} else if (data.status == 'OK') {
return data.status
} else {
console.warn(`Status "${data.status}" does not have a navigation handler, will be interpreted as OK!`)
return 'OK'
}
};

export default IsLoggedIn;
export default isLoggedIn;
2 changes: 0 additions & 2 deletions client/src/pages/authentication/openid.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Checkbox, Grid, Stack, Typography } from '@mui/material';
import AuthLogin from './auth-forms/AuthLogin';
import AuthWrapper from './AuthWrapper';
import { getFaviconURL } from '../../utils/routes';
import IsLoggedIn from '../../isLoggedIn';
import { LoadingButton } from '@mui/lab';
import { Field, useFormik } from 'formik';
import { useState } from 'react';
Expand Down Expand Up @@ -52,7 +51,6 @@ const OpenID = () => {
}

return (<AuthWrapper>
<IsLoggedIn />
<Grid container spacing={3}>
<Grid item xs={12}>
<Stack spacing={2}>
Expand Down
2 changes: 0 additions & 2 deletions client/src/pages/config/routeConfigPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useEffect, useState } from "react";
import * as API from "../../api";
import RouteSecurity from "./routes/routeSecurity";
import RouteOverview from "./routes/routeoverview";
import IsLoggedIn from "../../isLoggedIn";
import RouteMetrics from "../dashboard/routeMonitoring";
import EventExplorerStandalone from "../dashboard/eventsExplorerStandalone";

Expand All @@ -31,7 +30,6 @@ const RouteConfigPage = () => {
}, []);

return <div>
<IsLoggedIn />
<h2>
<Stack spacing={1}>
<Stack direction="row" spacing={1} alignItems="center">
Expand Down
1 change: 0 additions & 1 deletion client/src/pages/config/routes/newRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Paper from '@mui/material/Paper';
import { styled } from '@mui/material/styles';

import * as API from '../../../api';
import IsLoggedIn from '../../../isLoggedIn';
import RestartModal from '../../config/users/restart';
import RouteManagement from '../../config/routes/routeman';
import { ValidateRoute, getFaviconURL, sanitizeRoute } from '../../../utils/routes';
Expand Down
13 changes: 12 additions & 1 deletion client/src/pages/config/routes/routeman.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ const RouteManagement = ({ routeConfig, routeNames, config, TargetContainer, noC
return false;
} else {
let commaSepIps = values.WhitelistInboundIPs;
if(commaSepIps) {

if(commaSepIps && commaSepIps.length) {
values.WhitelistInboundIPs = commaSepIps.split(',').map((ip) => ip.trim());
} else {
values.WhitelistInboundIPs = [];
}

let fullValues = {
Expand Down Expand Up @@ -116,6 +119,14 @@ const RouteManagement = ({ routeConfig, routeNames, config, TargetContainer, noC
}
}}
validate={(values) => {
let commaSepIps = values.WhitelistInboundIPs;

if(commaSepIps && commaSepIps.length) {
values.WhitelistInboundIPs = commaSepIps.split(',').map((ip) => ip.trim());
} else {
values.WhitelistInboundIPs = [];
}

let fullValues = {
...routeConfig,
...values,
Expand Down
1 change: 0 additions & 1 deletion client/src/pages/config/routes/routeoverview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { RouteMode, RouteSecurity } from '../../../components/routeComponents';
import { getFaviconURL } from '../../../utils/routes';
import * as API from '../../../api';
import { CheckOutlined, ClockCircleOutlined, ContainerOutlined, DashboardOutlined, DeleteOutlined, DownOutlined, InfoCircleFilled, InfoCircleOutlined, LockOutlined, NodeExpandOutlined, SafetyCertificateOutlined, UpOutlined } from "@ant-design/icons";
import IsLoggedIn from '../../../isLoggedIn';
import { redirectToLocal } from '../../../utils/indexs';
import { CosmosCheckbox } from '../users/formShortcuts';
import { Field } from 'formik';
Expand Down
Loading
Loading