diff --git a/.dockerignore b/.dockerignore new file mode 100755 index 0000000..91a50cc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,26 @@ +Dockerfile +docker-compose.yml + +**/*.pyc +**/__pycache__/ +/.vscode/ + +#Node filters + +/frontend/node_modules + +# testing +/frontend/coverage + +# production +/frontend/build + +# misc +**/.DS_Store +**/.env.local +**/.env.development.local +**/.env.test.local + +**/npm-debug.log* +**/yarn-debug.log* +**/yarn-error.log* diff --git a/.gitignore b/.gitignore index 3d37166..e5a403b 100755 --- a/.gitignore +++ b/.gitignore @@ -7,10 +7,10 @@ **/.pnp.js # testing -/firewall/frontend/coverage +/frontend/coverage # production -/firewall/frontend/build +/frontend/build # misc **/.DS_Store diff --git a/firewall/Dockerfile b/Dockerfile similarity index 53% rename from firewall/Dockerfile rename to Dockerfile index 8314d31..dce5ae9 100755 --- a/firewall/Dockerfile +++ b/Dockerfile @@ -1,30 +1,35 @@ #Frontend build -FROM node:16-alpine AS frontend +FROM node:lts-alpine AS frontend RUN apk add --update npm -RUN npm install -g npm@latest RUN mkdir /app WORKDIR /app +ENV PATH /app/node_modules/.bin:$PATH ADD ./frontend/package.json . ADD ./frontend/package-lock.json . -RUN npm install +RUN npm ci --silent COPY ./frontend/ . RUN npm run build #Building main conteiner -FROM python:3-buster +FROM python:slim-buster -RUN apt-get update && apt-get -y install supervisor build-essential libboost-dev nginx +RUN apt-get update && apt-get -y install curl supervisor gettext-base build-essential libboost-dev nginx +RUN curl -sL https://deb.nodesource.com/setup_16.x | bash +RUN apt-get install nodejs + +RUN npm install serve -g --silent RUN mkdir /execute WORKDIR /execute -ADD ./requirements.txt /execute/requirements.txt +ADD ./backend/requirements.txt /execute/requirements.txt RUN pip install --no-cache-dir -r /execute/requirements.txt -COPY . /execute/ -COPY ./config/nginx.conf /etc/nginx/nginx.conf +COPY ./backend/ /execute/ COPY ./config/supervisord.conf /etc/supervisor/supervisord.conf +COPY ./config/nginx.conf /tmp/nginx.conf +COPY ./config/start_nginx.sh /tmp/start_nginx.sh #Copy react app in the main container COPY --from=frontend /app/build/ ./frontend/ diff --git a/README.md b/README.md index 3a14c84..61aaef2 100644 --- a/README.md +++ b/README.md @@ -1 +1,200 @@ -# firegex \ No newline at end of file +# **WORK IN PROGRESS** + +# Firegex-API Documentation +### This is a short description of the API + +## TODO + +1. custom windows docker-compose +2. fix glich change page with loading screen +3. Instant refresh after an add or delete +4. backend checks and errors +5. frontend requests on buttons +6. frontend messages on success and some failure +7. back and frontend password +8. volume on the database +9. compile c++ -O3 + +# +# Documentation +## Index + +- [General stats](#get-apigeneral-stats) +- [List services](#get-apiservices) +- [Service info](#get-apiserviceserv) +- [Stop service](#get-apiserviceservstop) +- [Start service](#get-apiserviceservstart) +- [Delete service](#get-apiserviceservdelete) +- [Terminate service](#get-apiserviceservterminate) +- [Regenerate public port](#get-apiserviceservregen-port) +- [Service regexes](#get-apiserviceservregexes) +- [Regex info](#get-apiregexregexid) +- [Delete regex](#get-apiregexregexiddelete) +- [Add regex](#post-apiregexesadd) +- [Add service](#post-apiservicesadd) + +# +# +## **GET** **```/api/general-stats```** +### Server response: +```json +{ + "services": , + "closed": , + "regex": +} +``` + +# +## **GET** **```/api/services```** +### Server response: +```json +[ + { + "id": , + "status": , + "public_port": , + "internal_port": , + "n_packets": , + "n_regex": + }, + { + // Another service + } +] +``` + +# +## **GET** **```/api/service/```** +### Server response: +```json +{ + "id": , + "status": , + "public_port": , + "internal_port": , + "n_packets": , + "n_regex": +} +``` + +# +## **GET** **```/api/service//stop```** +### Server response: +```json +{ + "status": "ok" +} +``` + +# +## **GET** **```/api/service//start```** +### Server response: +```json +{ + "status": "ok" +} +``` + +# +## **GET** **```/api/service//delete```** +### Server response: +```json +{ + "status": "ok" +} +``` + +# +## **GET** **```/api/service//terminate```** +### Server response: +```json +{ + "status": "ok" +} +``` + +# +## **GET** **```/api/service//regen-port```** +### Server response: +```json +{ + "status": "ok" +} +``` + +# +## **GET** **```/api/service//regexes```** +### Server response: +```json +[ + { + "id": , + "service_id": , + "regex": , + "is_blacklist": , + "n_packets": , + "mode": <"C"|"S"|"B"> // Client to server, server to client or both + }, + { + // Another regex + } +] +``` + +# +## **GET** **```/api/regex/```** +### Server response: +```json +{ + "id": , + "service_id": , + "regex": , + "is_blacklist": , + "n_packets": , + "mode" <"C"|"S"|"B"> // Client to server, server to client or both +} +``` + +# +## **GET** **```/api/regex//delete```** +### Server response: +```json +{ + "status": "ok" +} +``` + +# +## **POST** **```/api/regexes/add```** +### Client request: +```json +{ + "service_id": , + "regex": , + "is_blacklist": , + "mode": <"C"|"S"|"B"> // Client to server, server to client or both +} +``` +### Server response: +```json +{ + "status": "ok" +} +``` + +# +## **POST** **```/api/services/add```** +### Client request: +```json +{ + "name": , + "port": +} +``` +### Server response: +```json +{ + "status": "ok" +} +``` \ No newline at end of file diff --git a/firewall/app.py b/backend/app.py similarity index 92% rename from firewall/app.py rename to backend/app.py index 714c0d9..ade163f 100644 --- a/firewall/app.py +++ b/backend/app.py @@ -1,5 +1,5 @@ import sqlite3, random, string, subprocess -from flask import Flask, jsonify, request +from flask import Flask, jsonify, request, abort class SQLite(): @@ -68,7 +68,7 @@ def get_services(): res = [] for i in db.query('SELECT * FROM services;'): n_regex = db.query('SELECT COUNT (*) FROM regexes WHERE service_id = ?;', (i[1],))[0][0] - n_pacchetti = db.query('SELECT SUM(blocked_packets) FROM regexes WHERE service_id = ?;', (i[1],))[0][0] + n_packets = db.query('SELECT SUM(blocked_packets) FROM regexes WHERE service_id = ?;', (i[1],))[0][0] res.append({ 'id': i[1], @@ -76,7 +76,7 @@ def get_services(): 'public_port': i[3], 'internal_port': i[2], 'n_regex': n_regex, - 'n_pacchetti': n_pacchetti if n_pacchetti else 0, + 'n_packets': n_packets if n_packets else 0, 'name': i[4] }) @@ -90,7 +90,7 @@ def get_service(serv): res = {} if len(q) != 0: n_regex = db.query('SELECT COUNT (*) FROM regexes WHERE service_id = ?;', (serv,))[0][0] - n_pacchetti = db.query('SELECT SUM(blocked_packets) FROM regexes WHERE service_id = ?;', (serv,))[0][0] + n_packets = db.query('SELECT SUM(blocked_packets) FROM regexes WHERE service_id = ?;', (serv,))[0][0] print(q[0]) res = { @@ -98,10 +98,12 @@ def get_service(serv): 'status': q[0][0], 'public_port': q[0][3], 'internal_port': q[0][2], - 'n_packets': n_pacchetti if n_pacchetti else 0, + 'n_packets': n_packets if n_packets else 0, 'n_regex': n_regex, 'name': q[0][4] } + else: + return abort(404) return res @@ -265,5 +267,5 @@ if __name__ == '__main__': }) #uwsgi - subprocess.run(["uwsgi","--http","127.0.0.1:8080","--master","--module","app:app"]) + subprocess.run(["uwsgi","--socket","/tmp/uwsgi.sock","--master","--module","app:app"]) diff --git a/firewall/c_back/proxy b/backend/c_back/proxy similarity index 100% rename from firewall/c_back/proxy rename to backend/c_back/proxy diff --git a/firewall/c_back/proxy.cpp b/backend/c_back/proxy.cpp similarity index 100% rename from firewall/c_back/proxy.cpp rename to backend/c_back/proxy.cpp diff --git a/firewall/c_back/proxy_wrap.py b/backend/c_back/proxy_wrap.py similarity index 100% rename from firewall/c_back/proxy_wrap.py rename to backend/c_back/proxy_wrap.py diff --git a/firewall/requirements.txt b/backend/requirements.txt similarity index 100% rename from firewall/requirements.txt rename to backend/requirements.txt diff --git a/firewall/config/nginx.conf b/config/nginx.conf similarity index 55% rename from firewall/config/nginx.conf rename to config/nginx.conf index d8130dd..67dfaaa 100755 --- a/firewall/config/nginx.conf +++ b/config/nginx.conf @@ -1,28 +1,26 @@ -worker_processes 5; ## Default: 1 -pid /var/run/nginx.pid; - -user nobody nogroup; - -events { - worker_connections 1024; -} - - -http{ - server { - listen ${NGINX_PORT}; - server_name _; - - - root /execute/frontend/; - location / { - try_files $uri /index.html; - } - - location /api/ { - include proxy_params; - proxy_pass http://127.0.0.1:8080; - } - - } +worker_processes 5; ## Default: 1 +pid /var/run/nginx.pid; + +user nobody nogroup; + +events { + worker_connections 1024; +} + + +http{ + server { + listen $NGINX_PORT; + + location / { + include proxy_params; + proxy_pass http://unix:/tmp/react.sock; + } + + location /api/ { + include uwsgi_params; + uwsgi_pass unix:/tmp/uwsgi.sock; + } + + } } \ No newline at end of file diff --git a/config/start_nginx.sh b/config/start_nginx.sh new file mode 100644 index 0000000..10f8347 --- /dev/null +++ b/config/start_nginx.sh @@ -0,0 +1,4 @@ +#/bin/bash + +envsubst '$NGINX_PORT' < /tmp/nginx.conf > /etc/nginx/nginx.conf +/usr/sbin/nginx -g "daemon off;" || exit 1 \ No newline at end of file diff --git a/firewall/config/supervisord.conf b/config/supervisord.conf similarity index 66% rename from firewall/config/supervisord.conf rename to config/supervisord.conf index 005f708..42cdb18 100755 --- a/firewall/config/supervisord.conf +++ b/config/supervisord.conf @@ -1,31 +1,37 @@ -[supervisord] -logfile = /dev/null -loglevel = info -user = root -pidfile = /var/run/supervisord.pid -nodaemon = true - -[program:nginx] -command=/usr/sbin/nginx -g "daemon off;" -autostart=true -autorestart=true -user = root -startretries=5 -numprocs=1 -startsecs=0 -process_name=%(program_name)s_%(process_num)02d -stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log -stderr_logfile_maxbytes=10MB -stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log -stdout_logfile_maxbytes=10MB - -[program:backend] -directory=/execute -user = nobody -command=python3 app.py -stdout_logfile="syslog" -stderr_logfile="syslog" -startsecs=10 -stopsignal=QUIT -stopasgroup=true -killasgroup=true \ No newline at end of file +[supervisord] +logfile = /dev/null +loglevel = info +user = root +pidfile = /var/run/supervisord.pid +nodaemon = true + +[program:backend] +directory=/execute +user = nobody +command=python3 app.py +startsecs=10 +stopsignal=QUIT +stopasgroup=true +killasgroup=true + +[program:frontend] +directory=/execute +user = nobody +command=serve -s frontend -l unix:/tmp/react.sock +startsecs=10 +stopsignal=QUIT +stopasgroup=true +killasgroup=true + +[program:nginx] +command=bash /tmp/start_nginx.sh +autostart=true +autorestart=true +user = root +startretries=5 +numprocs=1 +startsecs=0 +stderr_logfile=/var/log/supervisor/%(program_name)s_stderr.log +stderr_logfile_maxbytes=10MB +stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log +stdout_logfile_maxbytes=10MB \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index e2d48c1..21ef4f4 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,10 @@ version: '3.9' services: firewall: restart: unless-stopped - build: firewall - network_mode: "host" + build: . + #network_mode: "host" + ports: + - 80:80 environment: - - NGINX_PORT=8080 \ No newline at end of file + - NGINX_PORT=80 + \ No newline at end of file diff --git a/firewall/.dockerignore b/firewall/.dockerignore deleted file mode 100755 index 795c4ca..0000000 --- a/firewall/.dockerignore +++ /dev/null @@ -1,6 +0,0 @@ -Dockerfile -docker-compose.yml -**/*.pyc -**/__pycache__/ -/.vscode/** - diff --git a/firewall/README.md b/firewall/README.md deleted file mode 100644 index 8fe6dc3..0000000 --- a/firewall/README.md +++ /dev/null @@ -1,188 +0,0 @@ -# **WORK IN PROGRESS** - -# Firegex-API Documentation -### This is a short description of the API - -# -# Documentation -## Index - -- [General stats](#get-apigeneral-stats) -- [List services](#get-apiservices) -- [Service info](#get-apiserviceserv) -- [Stop service](#get-apiserviceservstop) -- [Start service](#get-apiserviceservstart) -- [Delete service](#get-apiserviceservdelete) -- [Terminate service](#get-apiserviceservterminate) -- [Regenerate public port](#get-apiserviceservregen-port) -- [Service regexes](#get-apiserviceservregexes) -- [Regex info](#get-apiregexregexid) -- [Delete regex](#get-apiregexregexiddelete) -- [Add regex](#post-apiregexesadd) -- [Add service](#post-apiservicesadd) - -# -# -## **GET** **```/api/general-stats```** -### Server response: -```json -{ - "services": , - "closed": , - "regex": -} -``` - -# -## **GET** **```/api/services```** -### Server response: -```json -[ - { - "id": , - "status": , - "public_port": , - "internal_port": , - "n_packets": , - "n_regex": - }, - { - // Another service - } -] -``` - -# -## **GET** **```/api/service/```** -### Server response: -```json -{ - "id": , - "status": , - "public_port": , - "internal_port": , - "n_packets": , - "n_regex": -} -``` - -# -## **GET** **```/api/service//stop```** -### Server response: -```json -{ - "status": "ok" -} -``` - -# -## **GET** **```/api/service//start```** -### Server response: -```json -{ - "status": "ok" -} -``` - -# -## **GET** **```/api/service//delete```** -### Server response: -```json -{ - "status": "ok" -} -``` - -# -## **GET** **```/api/service//terminate```** -### Server response: -```json -{ - "status": "ok" -} -``` - -# -## **GET** **```/api/service//regen-port```** -### Server response: -```json -{ - "status": "ok" -} -``` - -# -## **GET** **```/api/service//regexes```** -### Server response: -```json -[ - { - "id": , - "service_id": , - "regex": , - "is_blacklist": , - "n_packets": , - "mode": <"C"|"S"|"B"> // Client to server, server to client or both - }, - { - // Another regex - } -] -``` - -# -## **GET** **```/api/regex/```** -### Server response: -```json -{ - "id": , - "service_id": , - "regex": , - "is_blacklist": , - "n_packets": , - "mode" <"C"|"S"|"B"> // Client to server, server to client or both -} -``` - -# -## **GET** **```/api/regex//delete```** -### Server response: -```json -{ - "status": "ok" -} -``` - -# -## **POST** **```/api/regexes/add```** -### Client request: -```json -{ - "service_id": , - "regex": , - "is_blacklist": , - "mode": <"C"|"S"|"B"> // Client to server, server to client or both -} -``` -### Server response: -```json -{ - "status": "ok" -} -``` - -# -## **POST** **```/api/services/add```** -### Client request: -```json -{ - "name": , - "port": -} -``` -### Server response: -```json -{ - "status": "ok" -} -``` \ No newline at end of file diff --git a/firewall/frontend/.dockerignore b/firewall/frontend/.dockerignore deleted file mode 100755 index a2e2183..0000000 --- a/firewall/frontend/.dockerignore +++ /dev/null @@ -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* diff --git a/firewall/frontend/.gitignore b/firewall/frontend/.gitignore deleted file mode 100755 index 4d29575..0000000 --- a/firewall/frontend/.gitignore +++ /dev/null @@ -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* diff --git a/firewall/frontend/public/favicon.ico b/firewall/frontend/public/favicon.ico deleted file mode 100755 index a11777c..0000000 Binary files a/firewall/frontend/public/favicon.ico and /dev/null differ diff --git a/firewall/frontend/public/index.html b/firewall/frontend/public/index.html deleted file mode 100755 index aa069f2..0000000 --- a/firewall/frontend/public/index.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - React App - - - -
- - - diff --git a/firewall/frontend/public/logo192.png b/firewall/frontend/public/logo192.png deleted file mode 100755 index fc44b0a..0000000 Binary files a/firewall/frontend/public/logo192.png and /dev/null differ diff --git a/firewall/frontend/public/logo512.png b/firewall/frontend/public/logo512.png deleted file mode 100755 index a4e47a6..0000000 Binary files a/firewall/frontend/public/logo512.png and /dev/null differ diff --git a/firewall/frontend/public/manifest.json b/firewall/frontend/public/manifest.json deleted file mode 100755 index 080d6c7..0000000 --- a/firewall/frontend/public/manifest.json +++ /dev/null @@ -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" -} diff --git a/firewall/frontend/README.md b/frontend/README.md similarity index 100% rename from firewall/frontend/README.md rename to frontend/README.md diff --git a/firewall/frontend/package-lock.json b/frontend/package-lock.json similarity index 100% rename from firewall/frontend/package-lock.json rename to frontend/package-lock.json diff --git a/firewall/frontend/package.json b/frontend/package.json similarity index 100% rename from firewall/frontend/package.json rename to frontend/package.json diff --git a/frontend/public/android-chrome-192x192.png b/frontend/public/android-chrome-192x192.png new file mode 100755 index 0000000..f44f144 Binary files /dev/null and b/frontend/public/android-chrome-192x192.png differ diff --git a/frontend/public/android-chrome-512x512.png b/frontend/public/android-chrome-512x512.png new file mode 100755 index 0000000..90466d6 Binary files /dev/null and b/frontend/public/android-chrome-512x512.png differ diff --git a/frontend/public/apple-touch-icon.png b/frontend/public/apple-touch-icon.png new file mode 100755 index 0000000..bfe29b6 Binary files /dev/null and b/frontend/public/apple-touch-icon.png differ diff --git a/frontend/public/favicon-16x16.png b/frontend/public/favicon-16x16.png new file mode 100755 index 0000000..9139aa4 Binary files /dev/null and b/frontend/public/favicon-16x16.png differ diff --git a/frontend/public/favicon-32x32.png b/frontend/public/favicon-32x32.png new file mode 100755 index 0000000..52d9ff2 Binary files /dev/null and b/frontend/public/favicon-32x32.png differ diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico new file mode 100755 index 0000000..de25c6b Binary files /dev/null and b/frontend/public/favicon.ico differ diff --git a/frontend/public/header-logo.png b/frontend/public/header-logo.png new file mode 100755 index 0000000..2f0bc63 Binary files /dev/null and b/frontend/public/header-logo.png differ diff --git a/frontend/public/index.html b/frontend/public/index.html new file mode 100755 index 0000000..0803234 --- /dev/null +++ b/frontend/public/index.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + + Firegex + + + +
+ + diff --git a/firewall/frontend/public/robots.txt b/frontend/public/robots.txt similarity index 100% rename from firewall/frontend/public/robots.txt rename to frontend/public/robots.txt diff --git a/frontend/public/site.webmanifest b/frontend/public/site.webmanifest new file mode 100755 index 0000000..45dc8a2 --- /dev/null +++ b/frontend/public/site.webmanifest @@ -0,0 +1 @@ +{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} \ No newline at end of file diff --git a/firewall/frontend/src/App.tsx b/frontend/src/App.tsx similarity index 100% rename from firewall/frontend/src/App.tsx rename to frontend/src/App.tsx diff --git a/firewall/frontend/src/_vars.scss b/frontend/src/_vars.scss similarity index 100% rename from firewall/frontend/src/_vars.scss rename to frontend/src/_vars.scss diff --git a/firewall/frontend/src/components/AddNewRegex.tsx b/frontend/src/components/AddNewRegex.tsx similarity index 90% rename from firewall/frontend/src/components/AddNewRegex.tsx rename to frontend/src/components/AddNewRegex.tsx index 6cc87d6..2640206 100755 --- a/firewall/frontend/src/components/AddNewRegex.tsx +++ b/frontend/src/components/AddNewRegex.tsx @@ -1,8 +1,8 @@ -import { Button, Group, NumberInput, Space, TextInput, Notification, Switch, NativeSelect } from '@mantine/core'; +import { Button, Group, 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 { RegexAddForm } from '../js/models'; +import { addregex, b64encode, validateRegex } from '../js/utils'; import { ImCross } from "react-icons/im" import FilterTypeSelector from './FilterTypeSelector'; diff --git a/firewall/frontend/src/components/AddNewService.tsx b/frontend/src/components/AddNewService.tsx similarity index 100% rename from firewall/frontend/src/components/AddNewService.tsx rename to frontend/src/components/AddNewService.tsx diff --git a/firewall/frontend/src/components/FilterTypeSelector.tsx b/frontend/src/components/FilterTypeSelector.tsx similarity index 100% rename from firewall/frontend/src/components/FilterTypeSelector.tsx rename to frontend/src/components/FilterTypeSelector.tsx diff --git a/firewall/frontend/src/components/Footer/Footer.module.scss b/frontend/src/components/Footer/Footer.module.scss similarity index 100% rename from firewall/frontend/src/components/Footer/Footer.module.scss rename to frontend/src/components/Footer/Footer.module.scss diff --git a/firewall/frontend/src/components/Footer/index.tsx b/frontend/src/components/Footer/index.tsx similarity index 100% rename from firewall/frontend/src/components/Footer/index.tsx rename to frontend/src/components/Footer/index.tsx diff --git a/firewall/frontend/src/components/Header/Header.module.scss b/frontend/src/components/Header/Header.module.scss similarity index 100% rename from firewall/frontend/src/components/Header/Header.module.scss rename to frontend/src/components/Header/Header.module.scss diff --git a/firewall/frontend/src/components/Header/index.tsx b/frontend/src/components/Header/index.tsx similarity index 89% rename from firewall/frontend/src/components/Header/index.tsx rename to frontend/src/components/Header/index.tsx index 174075f..2c5f4ba 100755 --- a/firewall/frontend/src/components/Header/index.tsx +++ b/frontend/src/components/Header/index.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { ActionIcon, Badge, Modal } from '@mantine/core'; +import { ActionIcon, Badge, Image, Modal } from '@mantine/core'; import style from "./Header.module.scss"; import { errorNotify, generalstats } from '../../js/utils'; import { GeneralStats, update_freq } from '../../js/models'; @@ -37,7 +37,9 @@ function Header() { const closeModal = () => {setOpen(false);} return
-
LOGO
+
+ Firegex logo +
Services: {generalStats.services} Filtered Connections: {generalStats.closed} diff --git a/firewall/frontend/src/components/MainLayout.tsx b/frontend/src/components/MainLayout.tsx similarity index 100% rename from firewall/frontend/src/components/MainLayout.tsx rename to frontend/src/components/MainLayout.tsx diff --git a/firewall/frontend/src/components/RegexView/RegexView.module.scss b/frontend/src/components/RegexView/RegexView.module.scss similarity index 100% rename from firewall/frontend/src/components/RegexView/RegexView.module.scss rename to frontend/src/components/RegexView/RegexView.module.scss diff --git a/firewall/frontend/src/components/RegexView/index.tsx b/frontend/src/components/RegexView/index.tsx similarity index 91% rename from firewall/frontend/src/components/RegexView/index.tsx rename to frontend/src/components/RegexView/index.tsx index dd0232f..53c7671 100755 --- a/firewall/frontend/src/components/RegexView/index.tsx +++ b/frontend/src/components/RegexView/index.tsx @@ -1,10 +1,8 @@ -import { Center, Grid, SegmentedControl, Text, Title, Box, Badge, Space, ActionIcon } from '@mantine/core'; +import { Grid, Text, Title, 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'; diff --git a/firewall/frontend/src/components/ServiceRow/ServiceRow.module.scss b/frontend/src/components/ServiceRow/ServiceRow.module.scss similarity index 100% rename from firewall/frontend/src/components/ServiceRow/ServiceRow.module.scss rename to frontend/src/components/ServiceRow/ServiceRow.module.scss diff --git a/firewall/frontend/src/components/ServiceRow/index.tsx b/frontend/src/components/ServiceRow/index.tsx similarity index 100% rename from firewall/frontend/src/components/ServiceRow/index.tsx rename to frontend/src/components/ServiceRow/index.tsx diff --git a/firewall/frontend/src/components/YesNoModal.tsx b/frontend/src/components/YesNoModal.tsx similarity index 100% rename from firewall/frontend/src/components/YesNoModal.tsx rename to frontend/src/components/YesNoModal.tsx diff --git a/firewall/frontend/src/index.scss b/frontend/src/index.scss similarity index 100% rename from firewall/frontend/src/index.scss rename to frontend/src/index.scss diff --git a/firewall/frontend/src/index.tsx b/frontend/src/index.tsx similarity index 100% rename from firewall/frontend/src/index.tsx rename to frontend/src/index.tsx diff --git a/firewall/frontend/src/js/models.ts b/frontend/src/js/models.ts similarity index 100% rename from firewall/frontend/src/js/models.ts rename to frontend/src/js/models.ts diff --git a/firewall/frontend/src/js/utils.tsx b/frontend/src/js/utils.tsx similarity index 94% rename from firewall/frontend/src/js/utils.tsx rename to frontend/src/js/utils.tsx index 6c43b1c..9698a9c 100755 --- a/firewall/frontend/src/js/utils.tsx +++ b/frontend/src/js/utils.tsx @@ -47,7 +47,7 @@ export async function serviceregexlist(service_id:string){ return await getapi(`service/${service_id}/regexes`) as RegexFilter[]; } -const unescapedChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$&\'()*+,-./:;<=>?@[\\]^_`{|}~ "; +const unescapedChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$&'()*+,-./:;<=>?@[\\]^_`{|}~ "; export function getHumanReadableRegex(regexB64:string){ const regex = Buffer.from(regexB64, "base64") diff --git a/firewall/frontend/src/pages/HomePage.tsx b/frontend/src/pages/HomePage.tsx similarity index 100% rename from firewall/frontend/src/pages/HomePage.tsx rename to frontend/src/pages/HomePage.tsx diff --git a/firewall/frontend/src/pages/ServiceDetails.tsx b/frontend/src/pages/ServiceDetails.tsx similarity index 88% rename from firewall/frontend/src/pages/ServiceDetails.tsx rename to frontend/src/pages/ServiceDetails.tsx index 04dbeda..2cf15f3 100755 --- a/firewall/frontend/src/pages/ServiceDetails.tsx +++ b/frontend/src/pages/ServiceDetails.tsx @@ -32,7 +32,6 @@ function ServiceDetails() { setServiceInfo(res) }).catch( err =>{ - errorNotify(`Updater for ${srv_id} service failed [General Info]!`, err.toString()) error = true; navigator("/") }) @@ -40,17 +39,15 @@ function ServiceDetails() { await serviceregexlist(srv_id).then(res => { setRegexesList(res) }).catch( - err =>{ - errorNotify(`Updater for ${srv_id} service failed [Regex list]!`, err.toString()) - error = true; - }) + err => errorNotify(`Updater for ${srv_id} service failed [Regex list]!`, err.toString()) + ) } - + useEffect(()=>{ updateInfo() const updater = setInterval(updateInfo, update_freq) return () => { clearInterval(updater) } - }, []); + }); const [deleteModal, setDeleteModal] = useState(false) diff --git a/firewall/frontend/src/react-app-env.d.ts b/frontend/src/react-app-env.d.ts similarity index 100% rename from firewall/frontend/src/react-app-env.d.ts rename to frontend/src/react-app-env.d.ts diff --git a/firewall/frontend/tsconfig.json b/frontend/tsconfig.json similarity index 100% rename from firewall/frontend/tsconfig.json rename to frontend/tsconfig.json