Bug fixes and additional checks
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -12,6 +12,7 @@
|
|||||||
/backend/db/firegex.db
|
/backend/db/firegex.db
|
||||||
/backend/db/firegex.db-journal
|
/backend/db/firegex.db-journal
|
||||||
/backend/proxy/proxy
|
/backend/proxy/proxy
|
||||||
|
docker-compose.yml
|
||||||
# production
|
# production
|
||||||
/frontend/build
|
/frontend/build
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,6 @@
|
|||||||
# Firegex-API Documentation
|
# Firegex-API Documentation
|
||||||
### This is a short description of the API
|
### This is a short description of the API
|
||||||
|
|
||||||
## TODO
|
|
||||||
|
|
||||||
1. back and frontend password
|
|
||||||
2. compile c++ -O3
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Documentation
|
# Documentation
|
||||||
## Index
|
## Index
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import sqlite3, subprocess, sys, threading, bcrypt, secrets, time
|
import sqlite3, subprocess, sys, threading, bcrypt, secrets, time, re
|
||||||
from flask import Flask, jsonify, request, abort, session
|
from flask import Flask, jsonify, request, abort, session
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
@@ -278,7 +278,9 @@ def post_regexes_add():
|
|||||||
"is_blacklist" : {"type" : "boolean"},
|
"is_blacklist" : {"type" : "boolean"},
|
||||||
"mode" : {"type" : "string"},
|
"mode" : {"type" : "string"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
if not re.match("^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$",req["regex"]):
|
||||||
|
return abort(400)
|
||||||
except Exception:
|
except Exception:
|
||||||
return abort(400)
|
return abort(400)
|
||||||
db.query("INSERT INTO regexes (service_id, regex, is_blacklist, mode) VALUES (?, ?, ?, ?);",
|
db.query("INSERT INTO regexes (service_id, regex, is_blacklist, mode) VALUES (?, ?, ?, ?);",
|
||||||
|
|||||||
@@ -76,13 +76,14 @@ class ProxyManager:
|
|||||||
self.lock = threading.Lock()
|
self.lock = threading.Lock()
|
||||||
|
|
||||||
def __clear_proxy_table(self):
|
def __clear_proxy_table(self):
|
||||||
for key in self.proxy_table.keys():
|
with self.lock:
|
||||||
if not self.proxy_table[key]["thread"].is_alive():
|
for key in list(self.proxy_table.keys()):
|
||||||
del self.proxy_table[key]
|
if not self.proxy_table[key]["thread"].is_alive():
|
||||||
|
del self.proxy_table[key]
|
||||||
|
|
||||||
def reload(self):
|
def reload(self):
|
||||||
with self.lock:
|
self.__clear_proxy_table()
|
||||||
self.__clear_proxy_table()
|
with self.lock:
|
||||||
for srv_id in self.db.query('SELECT service_id, status FROM services;'):
|
for srv_id in self.db.query('SELECT service_id, status FROM services;'):
|
||||||
srv_id, n_status = srv_id
|
srv_id, n_status = srv_id
|
||||||
if srv_id in self.proxy_table:
|
if srv_id in self.proxy_table:
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
version: '3.9'
|
|
||||||
|
|
||||||
services:
|
|
||||||
firewall:
|
|
||||||
restart: unless-stopped
|
|
||||||
build: .
|
|
||||||
ports:
|
|
||||||
- 80:80
|
|
||||||
environment:
|
|
||||||
- NGINX_PORT=80
|
|
||||||
volumes:
|
|
||||||
- /execute/db
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
version: '3.9'
|
|
||||||
|
|
||||||
services:
|
|
||||||
firewall:
|
|
||||||
restart: unless-stopped
|
|
||||||
build: .
|
|
||||||
network_mode: "host"
|
|
||||||
environment:
|
|
||||||
- NGINX_PORT=4444
|
|
||||||
volumes:
|
|
||||||
- /execute/db
|
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ function App() {
|
|||||||
|
|
||||||
|
|
||||||
return <div className='center-flex-row' style={{padding:"100px"}}>
|
return <div className='center-flex-row' style={{padding:"100px"}}>
|
||||||
<Title order={3} align="center">Choose the password for access to the firewall 🔒</Title>
|
<Title order={3} align="center">Setup: Choose the password for access to the firewall 🔒</Title>
|
||||||
<Space h="xl" />
|
<Space h="xl" />
|
||||||
<form onSubmit={form.onSubmit(submitRequest)} style={{width:"80%"}}>
|
<form onSubmit={form.onSubmit(submitRequest)} style={{width:"80%"}}>
|
||||||
<TextInput
|
<TextInput
|
||||||
@@ -104,7 +104,7 @@ function App() {
|
|||||||
return <div className='center-flex-row' style={{padding:"100px"}}>
|
return <div className='center-flex-row' style={{padding:"100px"}}>
|
||||||
<Title order={2} align="center">Welcome to Firegex 🔥</Title>
|
<Title order={2} align="center">Welcome to Firegex 🔥</Title>
|
||||||
<Space h="xl" />
|
<Space h="xl" />
|
||||||
<Title order={2} align="center">Before you use the firewall, insert a password 🔒</Title>
|
<Title order={2} align="center">Before you use the firewall, insert the password 🔒</Title>
|
||||||
<Space h="xl" />
|
<Space h="xl" />
|
||||||
<form onSubmit={form.onSubmit(submitRequest)} style={{width:"80%"}}>
|
<form onSubmit={form.onSubmit(submitRequest)} style={{width:"80%"}}>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { GeneralStats, Service, ServiceAddForm, ServerResponse, RegexFilter, not
|
|||||||
|
|
||||||
var Buffer = require('buffer').Buffer
|
var Buffer = require('buffer').Buffer
|
||||||
|
|
||||||
const DEBUG = true
|
const DEBUG = false
|
||||||
|
|
||||||
const custom_url = DEBUG?"http://127.0.0.1:8080":""
|
const custom_url = DEBUG?"http://127.0.0.1:8080":""
|
||||||
|
|
||||||
|
|||||||
43
start.py
Executable file
43
start.py
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
import argparse, sys, platform
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('port', type=int, help='Port where open the web service of the firewall')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
with open("docker-compose.yml","wt") as compose:
|
||||||
|
|
||||||
|
if "linux" in sys.platform and not 'microsoft-standard' in platform.uname().release: #Check if not is a wsl also
|
||||||
|
compose.write(f"""
|
||||||
|
version: '3.9'
|
||||||
|
|
||||||
|
services:
|
||||||
|
firewall:
|
||||||
|
restart: unless-stopped
|
||||||
|
build: .
|
||||||
|
network_mode: "host"
|
||||||
|
environment:
|
||||||
|
- NGINX_PORT={args.port}
|
||||||
|
volumes:
|
||||||
|
- /execute/db
|
||||||
|
""")
|
||||||
|
print("Done! You can start firegex with docker-compose up -d --build")
|
||||||
|
else:
|
||||||
|
print("-----------------------------------")
|
||||||
|
print("You are not in a linux machine, due to docker limitation on other platform, the firewall will not work in this machine. You will only see the interface of firegex.")
|
||||||
|
print("-----------------------------------")
|
||||||
|
compose.write(f"""
|
||||||
|
version: '3.9'
|
||||||
|
|
||||||
|
services:
|
||||||
|
firewall:
|
||||||
|
restart: unless-stopped
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- {args.port}:{args.port}
|
||||||
|
environment:
|
||||||
|
- NGINX_PORT={args.port}
|
||||||
|
volumes:
|
||||||
|
- /execute/db
|
||||||
|
""")
|
||||||
|
print("Done! You can start firegex with docker-compose up -d --build")
|
||||||
Reference in New Issue
Block a user