Docker: single container compose
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
Dockerfile
|
||||
docker-compose.yml
|
||||
**/*.pyc
|
||||
**/__pycache__/
|
||||
/.vscode/**
|
||||
|
||||
#Node filters
|
||||
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
23
frontend/.gitignore
vendored
23
frontend/.gitignore
vendored
@@ -1,23 +0,0 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
@@ -1,14 +0,0 @@
|
||||
FROM node:16-alpine
|
||||
|
||||
#React project copy
|
||||
RUN apk add --update npm
|
||||
RUN npm install -g npm@latest
|
||||
RUN mkdir /app
|
||||
WORKDIR /app
|
||||
ADD package.json .
|
||||
ADD package-lock.json .
|
||||
RUN npm install
|
||||
RUN npm install serve -g
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
ENTRYPOINT [ "serve", "-s", "build" ]
|
||||
@@ -1,46 +0,0 @@
|
||||
# Getting Started with Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
||||
|
||||
## Available Scripts
|
||||
|
||||
In the project directory, you can run:
|
||||
|
||||
### `npm start`
|
||||
|
||||
Runs the app in the development mode.\
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
The page will reload if you make edits.\
|
||||
You will also see any lint errors in the console.
|
||||
|
||||
### `npm test`
|
||||
|
||||
Launches the test runner in the interactive watch mode.\
|
||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
||||
|
||||
### `npm run build`
|
||||
|
||||
Builds the app for production to the `build` folder.\
|
||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
||||
|
||||
The build is minified and the filenames include the hashes.\
|
||||
Your app is ready to be deployed!
|
||||
|
||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
||||
|
||||
### `npm run eject`
|
||||
|
||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
||||
|
||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
||||
|
||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
||||
|
||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
||||
|
||||
## Learn More
|
||||
|
||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
||||
|
||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
||||
29144
frontend/package-lock.json
generated
29144
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,54 +0,0 @@
|
||||
{
|
||||
"name": "firegex-frontend",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@mantine/core": "^4.2.8",
|
||||
"@mantine/form": "^4.2.8",
|
||||
"@mantine/hooks": "^4.2.8",
|
||||
"@mantine/modals": "^4.2.8",
|
||||
"@mantine/notifications": "^4.2.8",
|
||||
"@mantine/prism": "^4.2.8",
|
||||
"@mantine/spotlight": "^4.2.8",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"@types/jest": "^27.5.2",
|
||||
"@types/node": "^16.11.39",
|
||||
"@types/react": "^18.0.12",
|
||||
"@types/react-dom": "^18.0.5",
|
||||
"buffer": "^6.0.3",
|
||||
"react": "^18.1.0",
|
||||
"react-dom": "^18.1.0",
|
||||
"react-icons": "^4.4.0",
|
||||
"react-router-dom": "^6.3.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"sass": "^1.52.3",
|
||||
"typescript": "^4.7.3",
|
||||
"web-vitals": "^2.1.4"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
"react-app/jest"
|
||||
]
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.8 KiB |
@@ -1,43 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Web site created using create-react-app"
|
||||
/>
|
||||
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
||||
<!--
|
||||
manifest.json provides metadata used when your web app is installed on a
|
||||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
||||
-->
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tags above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
work correctly both with client-side routing and a non-root public URL.
|
||||
Learn how to configure a non-root public URL by running `npm run build`.
|
||||
-->
|
||||
<title>React App</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start` or `yarn start`.
|
||||
To create a production bundle, use `npm run build` or `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.4 KiB |
@@ -1,25 +0,0 @@
|
||||
{
|
||||
"short_name": "React App",
|
||||
"name": "Create React App Sample",
|
||||
"icons": [
|
||||
{
|
||||
"src": "favicon.ico",
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon"
|
||||
},
|
||||
{
|
||||
"src": "logo192.png",
|
||||
"type": "image/png",
|
||||
"sizes": "192x192"
|
||||
},
|
||||
{
|
||||
"src": "logo512.png",
|
||||
"type": "image/png",
|
||||
"sizes": "512x512"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"theme_color": "#000000",
|
||||
"background_color": "#ffffff"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
# https://www.robotstxt.org/robotstxt.html
|
||||
User-agent: *
|
||||
Disallow:
|
||||
@@ -1,17 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Navigate, Outlet, Route, Routes } from 'react-router-dom';
|
||||
import MainLayout from './components/MainLayout';
|
||||
import HomePage from './pages/HomePage';
|
||||
import ServiceDetails from './pages/ServiceDetails';
|
||||
|
||||
function App() {
|
||||
return <Routes>
|
||||
<Route element={<MainLayout><Outlet /></MainLayout>}>
|
||||
<Route index element={<HomePage />} />
|
||||
<Route path=":srv_id" element={<ServiceDetails />} />
|
||||
<Route path="*" element={<Navigate to="/" />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
}
|
||||
|
||||
export default App;
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
$primary_color: #242a33;
|
||||
$second_color: #1A1B1E;
|
||||
$third_color:#25262b;
|
||||
@@ -1,120 +0,0 @@
|
||||
import { Button, Group, NumberInput, Space, TextInput, Notification, Switch, NativeSelect } from '@mantine/core';
|
||||
import { useForm } from '@mantine/hooks';
|
||||
import React, { useState } from 'react';
|
||||
import { RegexAddForm, ServiceAddForm } from '../js/models';
|
||||
import { addregex, addservice, b64encode, validateRegex } from '../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
import FilterTypeSelector from './FilterTypeSelector';
|
||||
|
||||
|
||||
type RegexAddInfo = {
|
||||
regex:string,
|
||||
type:string,
|
||||
mode:string,
|
||||
regex_exact:boolean,
|
||||
percentage_encoding:boolean
|
||||
}
|
||||
|
||||
function AddNewRegex({ closePopup, service }:{ closePopup:()=>void, service:string }) {
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
regex:"",
|
||||
type:"blacklist",
|
||||
mode:"C <-> S",
|
||||
regex_exact:false,
|
||||
percentage_encoding:false
|
||||
},
|
||||
validationRules:{
|
||||
regex: (value) => value !== "" && validateRegex(value),
|
||||
type: (value) => ["blacklist","whitelist"].includes(value),
|
||||
mode: (value) => ['C -> S', 'S -> C', 'C <-> S'].includes(value)
|
||||
}
|
||||
})
|
||||
|
||||
const [submitLoading, setSubmitLoading] = useState(false)
|
||||
const [error, setError] = useState<string|null>(null)
|
||||
|
||||
const submitRequest = (values:RegexAddInfo) => {
|
||||
setSubmitLoading(true)
|
||||
const filter_mode = ({'C -> S':'C', 'S -> C':'S', 'C <-> S':'B'}[values.mode])
|
||||
|
||||
let final_regex = values.regex
|
||||
if (values.percentage_encoding){
|
||||
final_regex = decodeURIComponent(final_regex)
|
||||
}
|
||||
if(!values.regex_exact){
|
||||
final_regex = ".*"+final_regex+".*"
|
||||
}
|
||||
|
||||
const request:RegexAddForm = {
|
||||
is_blacklist:values.type !== "whitelist",
|
||||
service_id: service,
|
||||
mode: filter_mode?filter_mode:"B",
|
||||
regex: b64encode(final_regex)
|
||||
}
|
||||
setSubmitLoading(false)
|
||||
addregex(request).then( res => {
|
||||
if (!res){
|
||||
setSubmitLoading(false)
|
||||
closePopup();
|
||||
}else{
|
||||
setSubmitLoading(false)
|
||||
setError("Invalid request! [ "+res+" ]")
|
||||
}
|
||||
}).catch( err => {
|
||||
setSubmitLoading(false)
|
||||
setError("Request Failed! [ "+err+" ]")
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
return <form onSubmit={form.onSubmit(submitRequest)}>
|
||||
<TextInput
|
||||
required
|
||||
label="Regex"
|
||||
placeholder="[A-Z0-9]{31}="
|
||||
{...form.getInputProps('regex')}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<Switch
|
||||
label="Use percentage encoding for binary values"
|
||||
{...form.getInputProps('percentage_encoding', { type: 'checkbox' })}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<Switch
|
||||
label="Match the exactly the regex"
|
||||
{...form.getInputProps('regex_exact', { type: 'checkbox' })}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<NativeSelect
|
||||
data={['C -> S', 'S -> C', 'C <-> S']}
|
||||
label="Choose the source of the packets to filter"
|
||||
variant="filled"
|
||||
required
|
||||
{...form.getInputProps('mode')}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<FilterTypeSelector
|
||||
size="md"
|
||||
color="gray"
|
||||
required
|
||||
{...form.getInputProps('type')}
|
||||
/>
|
||||
<Group position="right" mt="md">
|
||||
<Button loading={submitLoading} type="submit">Add Filter</Button>
|
||||
</Group>
|
||||
|
||||
<Space h="md" />
|
||||
|
||||
{error?<>
|
||||
<Notification icon={<ImCross size={14} />} color="red" onClose={()=>{setError(null)}}>
|
||||
Error: {error}
|
||||
</Notification><Space h="md" /></>:null}
|
||||
|
||||
</form>
|
||||
|
||||
}
|
||||
|
||||
export default AddNewRegex;
|
||||
@@ -1,77 +0,0 @@
|
||||
import { Button, Group, NumberInput, Space, TextInput, Notification } from '@mantine/core';
|
||||
import { useForm } from '@mantine/hooks';
|
||||
import React, { useState } from 'react';
|
||||
import { ServiceAddForm } from '../js/models';
|
||||
import { addservice } from '../js/utils';
|
||||
import { ImCross } from "react-icons/im"
|
||||
|
||||
function AddNewService({ closePopup }:{ closePopup:()=>void }) {
|
||||
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
name:"",
|
||||
port:1,
|
||||
},
|
||||
validationRules:{
|
||||
name: (value) => value !== ""?true:false,
|
||||
port: (value) => value>0 && value<65536
|
||||
}
|
||||
})
|
||||
|
||||
const [submitLoading, setSubmitLoading] = useState(false)
|
||||
const [error, setError] = useState<string|null>(null)
|
||||
|
||||
const submitRequest = (values:ServiceAddForm) =>{
|
||||
setSubmitLoading(true)
|
||||
addservice(values).then( res => {
|
||||
if (!res){
|
||||
setSubmitLoading(false)
|
||||
closePopup();
|
||||
}else{
|
||||
setSubmitLoading(false)
|
||||
setError("Invalid request! [ "+res+" ]")
|
||||
}
|
||||
}).catch( err => {
|
||||
setSubmitLoading(false)
|
||||
setError("Request Failed! [ "+err+" ]")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
return <form onSubmit={form.onSubmit(submitRequest)}>
|
||||
<TextInput
|
||||
required
|
||||
label="Service name"
|
||||
placeholder="Challenge 01"
|
||||
{...form.getInputProps('name')}
|
||||
/>
|
||||
<Space h="md" />
|
||||
|
||||
<NumberInput
|
||||
required
|
||||
placeholder="8080"
|
||||
min={1}
|
||||
max={65535}
|
||||
label="Service port"
|
||||
{...form.getInputProps('port')}
|
||||
/>
|
||||
|
||||
|
||||
<Space h="md" />
|
||||
|
||||
<Group position="right" mt="md">
|
||||
<Button loading={submitLoading} type="submit">Add Service</Button>
|
||||
</Group>
|
||||
|
||||
<Space h="md" />
|
||||
|
||||
{error?<>
|
||||
<Notification icon={<ImCross size={14} />} color="red" onClose={()=>{setError(null)}}>
|
||||
Error: {error}
|
||||
</Notification><Space h="md" /></>:null}
|
||||
|
||||
</form>
|
||||
|
||||
}
|
||||
|
||||
export default AddNewService;
|
||||
@@ -1,32 +0,0 @@
|
||||
import { Box, Center, SegmentedControl } from "@mantine/core";
|
||||
import React from "react";
|
||||
import { FaListAlt } from "react-icons/fa";
|
||||
import { TiCancel } from "react-icons/ti";
|
||||
|
||||
|
||||
|
||||
export default function FilterTypeSelector(props:any){
|
||||
return <SegmentedControl
|
||||
data={[
|
||||
{
|
||||
value: 'blacklist',
|
||||
label: (
|
||||
<Center style={{color:"#FFF"}}>
|
||||
<TiCancel size={23} color="red"/>
|
||||
<Box ml={10}>Blacklist</Box>
|
||||
</Center>
|
||||
),
|
||||
},
|
||||
{
|
||||
value: 'whitelist',
|
||||
label: (
|
||||
<Center style={{color:"#FFF"}}>
|
||||
<FaListAlt size={16} color="gray"/>
|
||||
<Box ml={10}>Whitelist</Box>
|
||||
</Center>
|
||||
),
|
||||
},
|
||||
]}
|
||||
{...props}
|
||||
/>
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
@use "../../vars" as *;
|
||||
@use "../../index.scss" as *;
|
||||
|
||||
.footer{
|
||||
height: 150px;
|
||||
margin-top: 50px;
|
||||
background-color: $primary_color;
|
||||
@extend .center-flex;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
import style from "./Footer.module.scss";
|
||||
|
||||
|
||||
function Footer() {
|
||||
return <div id="footer" className={style.footer}>
|
||||
Made by Pwnzer0tt1
|
||||
</div>
|
||||
}
|
||||
|
||||
export default Footer;
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
@use "../../vars" as *;
|
||||
|
||||
.header{
|
||||
width: 100%;
|
||||
height: 140px;
|
||||
background-color: $primary_color;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.logo{
|
||||
width: 200px;
|
||||
margin-left: 40px;
|
||||
height: 70%;
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { ActionIcon, Badge, Modal } from '@mantine/core';
|
||||
import style from "./Header.module.scss";
|
||||
import { errorNotify, generalstats } from '../../js/utils';
|
||||
import { GeneralStats, update_freq } from '../../js/models';
|
||||
import { BsPlusLg } from "react-icons/bs"
|
||||
import { AiFillHome } from "react-icons/ai"
|
||||
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
||||
import AddNewRegex from '../AddNewRegex';
|
||||
import AddNewService from '../AddNewService';
|
||||
|
||||
|
||||
function Header() {
|
||||
|
||||
const [generalStats, setGeneralStats] = useState<GeneralStats>({closed:0, regexes:0, services:0});
|
||||
const location = useLocation()
|
||||
|
||||
const navigator = useNavigate()
|
||||
|
||||
const updateInfo = () => {
|
||||
generalstats().then(res => {
|
||||
setGeneralStats(res)
|
||||
}).catch(
|
||||
err => errorNotify("General Info Auto-Update failed!", err.toString())
|
||||
)
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
updateInfo()
|
||||
const updater = setInterval(updateInfo, update_freq)
|
||||
return () => { clearInterval(updater) }
|
||||
}, []);
|
||||
|
||||
|
||||
const {srv_id} = useParams()
|
||||
const [open, setOpen] = useState(false);
|
||||
const closeModal = () => {setOpen(false);}
|
||||
|
||||
return <div id="header-page" className={style.header}>
|
||||
<div className={style.logo} >LOGO</div>
|
||||
<div className="flex-spacer" />
|
||||
<Badge color="green" size="lg" variant="filled">Services: {generalStats.services}</Badge>
|
||||
<Badge style={{marginLeft:"10px"}} size="lg" color="yellow" variant="filled">Filtered Connections: {generalStats.closed}</Badge>
|
||||
<Badge style={{marginLeft:"10px"}} size="lg" color="violet" variant="filled">Regexes: {generalStats.regexes}</Badge>
|
||||
<div style={{marginLeft:"20px"}}></div>
|
||||
{ location.pathname !== "/"?
|
||||
<ActionIcon color="teal" style={{marginRight:"10px"}}
|
||||
size="xl" radius="md" variant="filled"
|
||||
onClick={()=>navigator("/")}>
|
||||
<AiFillHome size="25px" />
|
||||
</ActionIcon>
|
||||
:null}
|
||||
<ActionIcon color="blue" onClick={()=>setOpen(true)} size="xl" radius="md" variant="filled"><BsPlusLg size="20px" /></ActionIcon>
|
||||
{srv_id?
|
||||
<Modal size="xl" title="Add a new regex filter" opened={open} onClose={closeModal} closeOnClickOutside={false} centered>
|
||||
<AddNewRegex closePopup={closeModal} service={srv_id} />
|
||||
</Modal>:
|
||||
<Modal size="xl" title="Add a new service" opened={open} onClose={closeModal} closeOnClickOutside={false} centered>
|
||||
<AddNewService closePopup={closeModal} />
|
||||
</Modal>
|
||||
}
|
||||
|
||||
|
||||
<div style={{marginLeft:"40px"}}></div>
|
||||
</div>
|
||||
}
|
||||
|
||||
export default Header;
|
||||
@@ -1,23 +0,0 @@
|
||||
import { Container, MantineProvider, Space } from '@mantine/core';
|
||||
import { NotificationsProvider } from '@mantine/notifications';
|
||||
import React from 'react';
|
||||
import Footer from './Footer';
|
||||
import Header from './Header';
|
||||
|
||||
function MainLayout({ children }:{ children:any }) {
|
||||
return <>
|
||||
<MantineProvider theme={{ colorScheme: 'dark' }} withGlobalStyles withNormalizeCSS>
|
||||
<NotificationsProvider>
|
||||
<Header />
|
||||
<Space h="xl" />
|
||||
<Container size="xl" style={{minHeight:"57.5vh"}}>
|
||||
{children}
|
||||
</Container>
|
||||
<Space h="xl" />
|
||||
<Footer />
|
||||
</NotificationsProvider>
|
||||
</MantineProvider>
|
||||
</>
|
||||
}
|
||||
|
||||
export default MainLayout;
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
@use "../../vars" as *;
|
||||
|
||||
.box{
|
||||
padding:30px;
|
||||
margin:5px;
|
||||
}
|
||||
|
||||
.regex_text{
|
||||
padding: 10px;
|
||||
background-color: $third_color;
|
||||
border-radius: 15px;
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
import { Center, Grid, SegmentedControl, Text, Title, Box, Badge, Space, ActionIcon } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { RegexFilter } from '../../js/models';
|
||||
import { getHumanReadableRegex } from '../../js/utils';
|
||||
import style from "./RegexView.module.scss";
|
||||
import { FaListAlt } from "react-icons/fa"
|
||||
import { TiCancel } from "react-icons/ti"
|
||||
import { BsTrashFill } from "react-icons/bs"
|
||||
import YesNoModal from '../YesNoModal';
|
||||
import FilterTypeSelector from '../FilterTypeSelector';
|
||||
|
||||
|
||||
function RegexView({ regexInfo }:{ regexInfo:RegexFilter }) {
|
||||
|
||||
const mode_string = regexInfo.mode === "C"? "C -> S":
|
||||
regexInfo.mode === "S"? "S -> C":
|
||||
regexInfo.mode === "B"? "S <-> C": "🤔"
|
||||
|
||||
let regex_expr = getHumanReadableRegex(regexInfo.regex);
|
||||
let exact_regex = true;
|
||||
|
||||
if (regex_expr.length>=4 && regex_expr.startsWith(".*") && regex_expr.endsWith(".*")){
|
||||
regex_expr = regex_expr.substring(2,regex_expr.length-2)
|
||||
exact_regex = false;
|
||||
}
|
||||
|
||||
const [deleteModal, setDeleteModal] = useState(false);
|
||||
|
||||
return <div className={style.box}>
|
||||
<Grid>
|
||||
<Grid.Col span={2}>
|
||||
<Title order={2} style={{color:"#FFF"}}>Regex:</Title>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={8}>
|
||||
<Text className={style.regex_text}> {regex_expr}</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={2}>
|
||||
<ActionIcon color="red" onClick={()=>setDeleteModal(true)} size="xl" radius="md" variant="filled"><BsTrashFill size={22} /></ActionIcon>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={2} />
|
||||
<Grid.Col className='center-flex-row' span={4}>
|
||||
<Space h="xs" />
|
||||
<FilterTypeSelector
|
||||
size="md"
|
||||
color="gray"
|
||||
disabled
|
||||
value={regexInfo.is_blacklist?"blacklist":"whitelist"}
|
||||
/>
|
||||
<Space h="md" />
|
||||
<div className='center-flex'>
|
||||
<Badge size="md" color="green" variant="filled">Service: {regexInfo.service_id}</Badge>
|
||||
<Space w="xs" />
|
||||
<Badge size="md" color="gray" variant="filled">ID: {regexInfo.id}</Badge>
|
||||
</div>
|
||||
</Grid.Col>
|
||||
<Grid.Col style={{width:"100%"}} span={6}>
|
||||
<Space h="xs" />
|
||||
<div className='center-flex-row'>
|
||||
<Badge size="md" color={exact_regex?"grape":"pink"} variant="filled">Match: {exact_regex?"EXACT":"FIND"}</Badge>
|
||||
<Space h="xs" />
|
||||
<Badge size="md" color="yellow" variant="filled">Packets filtered: {regexInfo.n_packets}</Badge>
|
||||
<Space h="xs" />
|
||||
<Badge size="md" color="blue" variant="filled">Mode: {mode_string}</Badge>
|
||||
</div>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<YesNoModal
|
||||
title='Are you sure to delete this regex?'
|
||||
description={`You are going to delete the regex '${regex_expr}', causing the restart of the firewall if it is active.`}
|
||||
onClose={()=>setDeleteModal(false)}
|
||||
action={()=>console.log("Delete regex please!")}
|
||||
opened={deleteModal}
|
||||
/>
|
||||
|
||||
</div>
|
||||
}
|
||||
|
||||
export default RegexView;
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
@use "../../index.scss" as *;
|
||||
|
||||
.row{
|
||||
width: 95%;
|
||||
padding: 30px 0px;
|
||||
border-radius: 20px;
|
||||
margin: 10px;
|
||||
@extend .center-flex;
|
||||
}
|
||||
|
||||
.name{
|
||||
font-size: 2.3em;
|
||||
font-weight: bolder;
|
||||
margin-right: 10px;
|
||||
margin-bottom: 13px;
|
||||
color:#FFF;
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
import { ActionIcon, Badge, Grid, Space, Title } from '@mantine/core';
|
||||
import React, { useState } from 'react';
|
||||
import { FaPause, FaPlay, FaStop } from 'react-icons/fa';
|
||||
import { Service } from '../../js/models';
|
||||
import { MdOutlineArrowForwardIos } from "react-icons/md"
|
||||
import style from "./ServiceRow.module.scss";
|
||||
import YesNoModal from '../YesNoModal';
|
||||
|
||||
//"status":"stop"/"wait"/"active"/"pause",
|
||||
function ServiceRow({ service, onClick, additional_buttons }:{ service:Service, onClick?:()=>void, additional_buttons?:any }) {
|
||||
|
||||
let status_color = "gray";
|
||||
switch(service.status){
|
||||
case "stop": status_color = "red"; break;
|
||||
case "wait": status_color = "yellow"; break;
|
||||
case "active": status_color = "teal"; break;
|
||||
case "pause": status_color = "cyan"; break;
|
||||
}
|
||||
|
||||
const [stopModal, setStopModal] = useState(false);
|
||||
const [buttonLoading, setButtonLoading] = useState(false)
|
||||
|
||||
const stopService = () => {
|
||||
setButtonLoading(true)
|
||||
console.log("Stop this service please!")
|
||||
setButtonLoading(false)
|
||||
}
|
||||
|
||||
const startService = () => {
|
||||
setButtonLoading(true)
|
||||
console.log("Start this service please!")
|
||||
setButtonLoading(false)
|
||||
}
|
||||
|
||||
const pauseService = () => {
|
||||
if (service.status === "pause") return setStopModal(true)
|
||||
setButtonLoading(true)
|
||||
console.log("Pause this service please!")
|
||||
setButtonLoading(false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
return <>
|
||||
<Grid className={style.row} style={{width:"100%"}}>
|
||||
<Grid.Col span={4}>
|
||||
<div className="center-flex-row">
|
||||
<div className="center-flex"><Title className={style.name}>{service.name}</Title> <Badge size="xl" gradient={{ from: 'indigo', to: 'cyan' }} variant="gradient">:{service.public_port}</Badge></div>
|
||||
<Badge color={status_color} size="xl" radius="md">{service.internal_port} {"->"} {service.public_port}</Badge>
|
||||
</div>
|
||||
</Grid.Col>
|
||||
<Grid.Col className="center-flex" span={8}>
|
||||
<div className='flex-spacer'></div>
|
||||
<div className="center-flex-row">
|
||||
<Badge style={{marginBottom:"20px"}} color={status_color} radius="sm" size="xl" variant="filled">Status: <u>{service.status}</u></Badge>
|
||||
<Badge style={{marginBottom:"8px"}}color="violet" radius="sm" size="lg" variant="filled">Regex: {service.n_regex}</Badge>
|
||||
<Badge color="yellow" radius="sm" size="lg" variant="filled">Connections Blocked: {service.n_packets}</Badge>
|
||||
</div>
|
||||
<Space w="xl" /><Space w="xl" />
|
||||
<div className="center-flex">
|
||||
{additional_buttons}
|
||||
<ActionIcon color={service.status === "pause"?"yellow":"red"} loading={buttonLoading}
|
||||
onClick={pauseService} size="xl" radius="md" variant="filled"
|
||||
disabled={!["wait","active","pause"].includes(service.status)?true:false}>
|
||||
{service.status === "pause"?<FaStop size="20px" />:<FaPause size="20px" />}
|
||||
</ActionIcon>
|
||||
<Space w="md"/>
|
||||
<ActionIcon color="teal" size="xl" radius="md" onClick={startService} loading={buttonLoading}
|
||||
variant="filled" disabled={!["stop","pause"].includes(service.status)?true:false}>
|
||||
<FaPlay size="20px" />
|
||||
</ActionIcon>
|
||||
</div>
|
||||
<Space w="xl" /><Space w="xl" />
|
||||
{onClick?<MdOutlineArrowForwardIos onClick={onClick} style={{cursor:"pointer"}} size="45px" />:null}
|
||||
<Space w="xl" />
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<YesNoModal
|
||||
title='Are you sure to stop this service!'
|
||||
description={`You are going to delete the service '${service.id}', causing the stopping of the firewall. This will cause the shutdown of your service ⚠️!`}
|
||||
onClose={()=>setStopModal(false)}
|
||||
action={stopService}
|
||||
opened={stopModal}
|
||||
/>
|
||||
<hr style={{width:"100%"}}/>
|
||||
</>
|
||||
}
|
||||
|
||||
export default ServiceRow;
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Button, Group, Modal } from '@mantine/core';
|
||||
import React from 'react';
|
||||
|
||||
function YesNoModal( { title, description, action, onClose, opened}:{ title:string, description:string, onClose:()=>void, action:()=>void, opened:boolean} ){
|
||||
|
||||
return <Modal size="xl" title={title} opened={opened} onClose={onClose} centered>
|
||||
{description}
|
||||
<Group position="right" mt="md">
|
||||
<Button onClick={()=>{
|
||||
onClose()
|
||||
action()
|
||||
}} color="teal" type="submit">Yes</Button>
|
||||
<Button onClick={onClose} color="red" type="submit">No</Button>
|
||||
|
||||
</Group>
|
||||
</Modal>
|
||||
}
|
||||
|
||||
export default YesNoModal;
|
||||
@@ -1,35 +0,0 @@
|
||||
|
||||
@use "vars" as *;
|
||||
|
||||
@import url('https://fonts.googleapis.com/css2?family=Lato&display=swap');
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: 'Lato', sans-serif;
|
||||
}
|
||||
|
||||
.center-flex{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.center-flex-row{
|
||||
@extend .center-flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.flex-spacer{
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 12px;
|
||||
margin:3px;
|
||||
background: #333;
|
||||
cursor: pointer;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #757575;
|
||||
border-radius: 8px;
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { BrowserRouter } from "react-router-dom"
|
||||
import './index.scss';
|
||||
import App from './App';
|
||||
|
||||
const root = ReactDOM.createRoot(
|
||||
document.getElementById('root') as HTMLElement
|
||||
);
|
||||
root.render(
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
);
|
||||
@@ -1,45 +0,0 @@
|
||||
|
||||
|
||||
export const update_freq = 3000;
|
||||
export const notification_time = 2000;
|
||||
|
||||
export type GeneralStats = {
|
||||
services:number,
|
||||
closed:number,
|
||||
regexes:number
|
||||
}
|
||||
|
||||
export type Service = {
|
||||
id:string,
|
||||
name:string,
|
||||
status:string,
|
||||
public_port:number,
|
||||
internal_port:number,
|
||||
n_packets:number,
|
||||
n_regex:number,
|
||||
}
|
||||
|
||||
export type ServiceAddForm = {
|
||||
name:string,
|
||||
port:number
|
||||
}
|
||||
|
||||
export type ServerResponse = {
|
||||
status:string
|
||||
}
|
||||
|
||||
export type RegexFilter = {
|
||||
id:number,
|
||||
service_id:string,
|
||||
regex:string
|
||||
is_blacklist:boolean,
|
||||
mode:string //C S B => C->S S->C BOTH
|
||||
n_packets:number
|
||||
}
|
||||
|
||||
export type RegexAddForm = {
|
||||
"service_id":string,
|
||||
"regex":string,
|
||||
"is_blacklist":boolean,
|
||||
"mode":string // C->S S->C BOTH
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
import { showNotification } from "@mantine/notifications";
|
||||
import { ImCross } from "react-icons/im";
|
||||
import { TiTick } from "react-icons/ti"
|
||||
import { GeneralStats, Service, ServiceAddForm, ServerResponse, RegexFilter, notification_time, RegexAddForm } from "./models";
|
||||
|
||||
var Buffer = require('buffer').Buffer
|
||||
|
||||
export async function getapi(path:string):Promise<any>{
|
||||
return await fetch(`/api/${path}`).then( res => res.json() )
|
||||
}
|
||||
|
||||
export async function postapi(path:string,data:any):Promise<any>{
|
||||
return await fetch(`/api/${path}`, {
|
||||
method: 'POST',
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
}).then(res => res.json());
|
||||
}
|
||||
|
||||
|
||||
export async function generalstats(){
|
||||
return await getapi("general-stats") as GeneralStats;
|
||||
}
|
||||
|
||||
export async function servicelist(){
|
||||
return await getapi("services") as Service[];
|
||||
}
|
||||
|
||||
export async function serviceinfo(service_id:string){
|
||||
return await getapi(`service/${service_id}`) as Service;
|
||||
}
|
||||
|
||||
export async function addservice(data:ServiceAddForm) {
|
||||
const { status } = await postapi("services/add",data) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
}
|
||||
|
||||
export async function addregex(data:RegexAddForm) {
|
||||
const { status } = await postapi("regexes/add",data) as ServerResponse;
|
||||
return status === "ok"?undefined:status
|
||||
}
|
||||
|
||||
export async function serviceregexlist(service_id:string){
|
||||
return await getapi(`service/${service_id}/regexes`) as RegexFilter[];
|
||||
}
|
||||
|
||||
const unescapedChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$&\'()*+,-./:;<=>?@[\\]^_`{|}~ ";
|
||||
|
||||
export function getHumanReadableRegex(regexB64:string){
|
||||
const regex = Buffer.from(regexB64, "base64")
|
||||
let res = ""
|
||||
for (let i=0; i < regex.length; i++){
|
||||
const byte = String.fromCharCode(regex[i]);
|
||||
if (unescapedChars.includes(byte)){
|
||||
res+=byte
|
||||
}else{
|
||||
res+="%"+regex[i].toString(16)
|
||||
}
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
export function errorNotify(title:string, description:string ){
|
||||
showNotification({
|
||||
autoClose: notification_time,
|
||||
title: title,
|
||||
message: description,
|
||||
color: 'red',
|
||||
icon: <ImCross />,
|
||||
});
|
||||
}
|
||||
|
||||
export function okNotify(title:string, description:string ){
|
||||
showNotification({
|
||||
autoClose: notification_time,
|
||||
title: title,
|
||||
message: description,
|
||||
color: 'teal',
|
||||
icon: <TiTick />,
|
||||
});
|
||||
}
|
||||
|
||||
export function validateRegex(pattern:string) {
|
||||
var parts = pattern.split('/'),
|
||||
regex = pattern,
|
||||
options = "";
|
||||
if (parts.length > 1) {
|
||||
regex = parts[1];
|
||||
options = parts[2];
|
||||
}
|
||||
try {
|
||||
new RegExp(regex, options);
|
||||
return true;
|
||||
}
|
||||
catch(e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function b64encode(data:string){
|
||||
return Buffer.from(data).toString('base64')
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
import { Space, Title } from '@mantine/core';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import ServiceRow from '../components/ServiceRow';
|
||||
import { Service, update_freq } from '../js/models';
|
||||
import { errorNotify, servicelist } from '../js/utils';
|
||||
|
||||
|
||||
function HomePage() {
|
||||
|
||||
const [services, setServices] = useState<Service[]>([]);
|
||||
const navigator = useNavigate()
|
||||
|
||||
const updateInfo = () => {
|
||||
servicelist().then(res => {
|
||||
setServices(res)
|
||||
}).catch(
|
||||
err => errorNotify("Home Page Auto-Update failed!", err.toString())
|
||||
)
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
updateInfo()
|
||||
const updater = setInterval(updateInfo, update_freq)
|
||||
return () => { clearInterval(updater) }
|
||||
}, []);
|
||||
|
||||
return <div id="service-list" className="center-flex-row">
|
||||
{services.length > 0?services.map( srv => <ServiceRow service={srv} key={srv.id} onClick={()=>{
|
||||
navigator("/"+srv.id)
|
||||
}} />):<><Space h="xl"/> <Title className='center-flex' order={3}>No services found! Add one clicking the button above</Title></>}
|
||||
</div>
|
||||
}
|
||||
|
||||
export default HomePage;
|
||||
@@ -1,78 +0,0 @@
|
||||
import { ActionIcon, Grid, Space, Title } from '@mantine/core';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { BsTrashFill } from 'react-icons/bs';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import RegexView from '../components/RegexView';
|
||||
import ServiceRow from '../components/ServiceRow';
|
||||
import YesNoModal from '../components/YesNoModal';
|
||||
import { RegexFilter, Service, update_freq } from '../js/models';
|
||||
import { errorNotify, serviceinfo, serviceregexlist } from '../js/utils';
|
||||
|
||||
function ServiceDetails() {
|
||||
const {srv_id} = useParams()
|
||||
|
||||
const [serviceInfo, setServiceInfo] = useState<Service>({
|
||||
id:srv_id?srv_id:"",
|
||||
internal_port:0,
|
||||
n_packets:0,
|
||||
n_regex:0,
|
||||
name:srv_id?srv_id:"",
|
||||
public_port:0,
|
||||
status:"🤔"
|
||||
})
|
||||
|
||||
const [regexesList, setRegexesList] = useState<RegexFilter[]>([])
|
||||
|
||||
const navigator = useNavigate()
|
||||
|
||||
const updateInfo = async () => {
|
||||
if (!srv_id) return
|
||||
let error = false;
|
||||
await serviceinfo(srv_id).then(res => {
|
||||
setServiceInfo(res)
|
||||
}).catch(
|
||||
err =>{
|
||||
errorNotify(`Updater for ${srv_id} service failed [General Info]!`, err.toString())
|
||||
error = true;
|
||||
navigator("/")
|
||||
})
|
||||
if (error) return
|
||||
await serviceregexlist(srv_id).then(res => {
|
||||
setRegexesList(res)
|
||||
}).catch(
|
||||
err =>{
|
||||
errorNotify(`Updater for ${srv_id} service failed [Regex list]!`, err.toString())
|
||||
error = true;
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
updateInfo()
|
||||
const updater = setInterval(updateInfo, update_freq)
|
||||
return () => { clearInterval(updater) }
|
||||
}, []);
|
||||
|
||||
const [deleteModal, setDeleteModal] = useState(false)
|
||||
|
||||
return <>
|
||||
<ServiceRow service={serviceInfo} additional_buttons={<>
|
||||
<ActionIcon color="red" onClick={()=>setDeleteModal(true)} size="xl" radius="md" variant="filled"><BsTrashFill size={22} /></ActionIcon>
|
||||
<Space w="md"/>
|
||||
</>}></ServiceRow>
|
||||
{regexesList.length === 0?
|
||||
<><Space h="xl" /> <Title className='center-flex' order={3}>No regex found for this service! Add one clicking the add button above</Title></>:
|
||||
<Grid>
|
||||
{regexesList.map( (regexInfo) => <Grid.Col key={regexInfo.id} span={6}><RegexView regexInfo={regexInfo}/></Grid.Col>)}
|
||||
</Grid>
|
||||
}
|
||||
<YesNoModal
|
||||
title='Are you sure to delete this service?'
|
||||
description={`You are going to delete the service '${serviceInfo.id}', causing the stopping of the firewall and deleting all the regex associated. This will cause the shutdown of your service ⚠️!`}
|
||||
onClose={()=>setDeleteModal(false)}
|
||||
action={()=>console.log("Delete the service please!")}
|
||||
opened={deleteModal}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
|
||||
export default ServiceDetails;
|
||||
1
frontend/src/react-app-env.d.ts
vendored
1
frontend/src/react-app-env.d.ts
vendored
@@ -1 +0,0 @@
|
||||
/// <reference types="react-scripts" />
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user