Docker container changes
This commit is contained in:
128
api-model.txt
128
api-model.txt
@@ -1,128 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/api/general-stats
|
||||
|
||||
{
|
||||
"services":1,
|
||||
"closed":1,
|
||||
"regex":1
|
||||
}
|
||||
|
||||
#Processo di trasformazione del nome del servizio = primary_key
|
||||
serv_id = serv_id.strip().replace(" ","-")
|
||||
serv_id = "".join([c for c in serv_id if c in (strings.uppercase+strings.lowercase+strings.digits+"-")])
|
||||
serv_id = serv_id.lower()
|
||||
|
||||
/api/services
|
||||
|
||||
[
|
||||
{
|
||||
"id":"serv_id",
|
||||
"name":"text",
|
||||
"status":"stop"/"wait"/"active"/"pause",
|
||||
"public_port":1234,
|
||||
"internal_port":44444,
|
||||
"n_packets":1,
|
||||
"n_regex":1,
|
||||
}
|
||||
]
|
||||
|
||||
/api/service/<serv>
|
||||
|
||||
{
|
||||
"id":"serv_id",
|
||||
"name":"text",
|
||||
"status":"stop"/"wait"/"active"/"pause",
|
||||
"public_port":1234,
|
||||
"internal_port":44444,
|
||||
"n_packets":1,
|
||||
"n_regex":1,
|
||||
}
|
||||
|
||||
/api/service/<serv>/stop
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/start
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/delete
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/terminate
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/regen-port
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/regexes
|
||||
|
||||
[
|
||||
{
|
||||
"id":5787,
|
||||
"service_id":"serv_id",
|
||||
"regex":"base64"
|
||||
"is_blacklist":true,
|
||||
"mode":"C","S","B" // C->S S->C BOTH
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
/api/regex/<regex_id>
|
||||
{
|
||||
"id":5787,
|
||||
"service_id":"serv_id",
|
||||
"regex":"base64"
|
||||
"is_blacklist":true,
|
||||
"mode":"C","S","B" // C->S S->C BOTH
|
||||
}
|
||||
|
||||
/api/regex/<regex_id>/delete
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
|
||||
|
||||
/api/regexes/add POST
|
||||
|
||||
client
|
||||
{
|
||||
"service_id":"serv_id",
|
||||
"regex":"base64",
|
||||
"is_blacklist":true/false,
|
||||
"mode":"C","S","B" // C->S S->C BOTH
|
||||
}
|
||||
server
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
|
||||
/api/services/add POST
|
||||
client
|
||||
{
|
||||
"name":"text",
|
||||
"port":5362
|
||||
}
|
||||
server
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
@@ -9,8 +9,8 @@ ADD ./requirements.txt /execute/requirements.txt
|
||||
RUN pip install --no-cache-dir -r /execute/requirements.txt
|
||||
|
||||
COPY . /execute/
|
||||
COPY ./nginx.conf /etc/nginx/nginx.conf
|
||||
COPY ./supervisord.conf /etc/supervisor/supervisord.conf
|
||||
COPY ./config/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY ./config/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
|
||||
RUN usermod -a -G root nobody
|
||||
RUN chown -R nobody:root /execute && \
|
||||
|
||||
4
backend/Firegex-API/.gitignore
vendored
4
backend/Firegex-API/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
venv
|
||||
firegex.db
|
||||
firegex.db-journal
|
||||
__pycache__
|
||||
@@ -1,127 +0,0 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/api/general-stats
|
||||
|
||||
{
|
||||
"services":1,
|
||||
"closed":1,
|
||||
"regex":1
|
||||
}
|
||||
|
||||
#Processo di trasformazione del nome del servizio = primary_key
|
||||
serv_id = serv_id.strip().replace(" ","-")
|
||||
serv_id = "".join([c for c in serv_id if c in (strings.uppercase+strings.lowercase+strings.digits+"-")])
|
||||
serv_id = serv_id.lower()
|
||||
|
||||
/api/services
|
||||
|
||||
[
|
||||
{
|
||||
"id": "serv_id",
|
||||
"name":"text",
|
||||
"status":"text",
|
||||
"public_port":1234,
|
||||
"internal_port":44444,
|
||||
"n_pacchetti":1,
|
||||
"n_regex":1,
|
||||
}
|
||||
]
|
||||
|
||||
/api/service/<serv>
|
||||
{
|
||||
"id":"serv_id",
|
||||
"name":"text",
|
||||
"status":"stop"/"wait"/"active"/"pause",
|
||||
"public_port":1234,
|
||||
"internal_port":44444,
|
||||
"n_packets":1,
|
||||
"n_regex":1,
|
||||
}
|
||||
|
||||
/api/service/<serv>/stop
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/start
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/delete
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/terminate
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/regen-port
|
||||
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
/api/service/<serv>/regexes
|
||||
|
||||
[
|
||||
{
|
||||
"id": "5787",
|
||||
"service_id": "serv_id",
|
||||
"regex":"base64",
|
||||
"is_blacklist":true,
|
||||
"mode":"C","S","B" // C->S S->C BOTH
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
/api/regex/<regex_id>
|
||||
{
|
||||
"id": 5787
|
||||
"service_id":"serv_id",
|
||||
"regex":"base64"
|
||||
"is_blacklist":true,
|
||||
"mode":"C","S","B" // C->S S->C BOTH
|
||||
}
|
||||
|
||||
/api/regex/<regex_id>/delete
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
|
||||
|
||||
/api/regexes/add POST
|
||||
|
||||
client
|
||||
{
|
||||
"service_id":"serv_id",
|
||||
"regex":"base64",
|
||||
"is_blacklist":true/false,
|
||||
"mode":"C","S","B" // C->S S->C BOTH
|
||||
}
|
||||
server
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
|
||||
|
||||
/api/services/add POST
|
||||
client
|
||||
{
|
||||
"name":"text",
|
||||
"port":5362
|
||||
}
|
||||
server
|
||||
{
|
||||
"status":"ok"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
click==8.1.3
|
||||
colorama==0.4.4
|
||||
Flask==2.1.2
|
||||
itsdangerous==2.1.2
|
||||
Jinja2==3.1.2
|
||||
MarkupSafe==2.1.1
|
||||
Werkzeug==2.1.2
|
||||
@@ -30,33 +30,15 @@ class SQLite():
|
||||
''', (t,))
|
||||
|
||||
if len(self.cur.fetchall()) == 0:
|
||||
self.cur.execute('''CREATE TABLE main.?(?);''', (t, ''.join([(c + ' ' + tables[t][c] + ', ') for c in tables[t]])[:-2]))
|
||||
self.cur.execute(f'CREATE TABLE main.{t}({"".join([(c + " " + tables[t][c] + ", ") for c in tables[t]])[:-2]});')
|
||||
|
||||
def query(self, query, values = ()):
|
||||
self.cur.execute(query, values)
|
||||
return self.cur.fetchall()
|
||||
|
||||
# DB init
|
||||
|
||||
db = SQLite('firegex')
|
||||
db.connect()
|
||||
db.check_integrity({
|
||||
'regexes': {
|
||||
'regex': 'TEXT NOT NULL',
|
||||
'mode': 'CHAR(1)',
|
||||
'service_id': 'TEXT NOT NULL',
|
||||
'is_blacklist': 'CHAR(50) NOT NULL',
|
||||
'blocked_packets': 'INTEGER DEFAULT 0',
|
||||
'regex_id': 'INTEGER NOT NULL'
|
||||
},
|
||||
'services': {
|
||||
'status': 'CHAR(50)',
|
||||
'service_id': 'TEXT NOT NULL',
|
||||
'internal_port': 'INT NOT NULL',
|
||||
'public_port': 'INT NOT NULL'
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/api/general-stats')
|
||||
@@ -256,3 +238,26 @@ def post_services_add():
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
if __name__ == "__main__":
|
||||
import subprocess
|
||||
# DB init
|
||||
db.check_integrity({
|
||||
'regexes': {
|
||||
'regex': 'TEXT NOT NULL',
|
||||
'mode': 'CHAR(1)',
|
||||
'service_id': 'TEXT NOT NULL',
|
||||
'is_blacklist': 'CHAR(50) NOT NULL',
|
||||
'blocked_packets': 'INTEGER DEFAULT 0',
|
||||
'regex_id': 'INTEGER NOT NULL'
|
||||
},
|
||||
'services': {
|
||||
'status': 'CHAR(50)',
|
||||
'service_id': 'TEXT NOT NULL',
|
||||
'internal_port': 'INT NOT NULL',
|
||||
'public_port': 'INT NOT NULL'
|
||||
}
|
||||
})
|
||||
#uwsgi
|
||||
subprocess.run(["uwsgi","--http","127.0.0.1:8080","--master","--module","app:app"])
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
worker_processes 5; ## Default: 1
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
user nobody nobody;
|
||||
user nobody nogroup;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
@@ -15,12 +15,12 @@ http{
|
||||
|
||||
location / {
|
||||
include proxy_params;
|
||||
proxy_pass http://frontend:5000/;
|
||||
proxy_pass http://frontend:3000/;
|
||||
}
|
||||
|
||||
location /api/ {
|
||||
include proxy_params;
|
||||
proxy_pass http://127.0.0.1:8080/;
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ nodaemon = true
|
||||
command=/usr/sbin/nginx -g "daemon off;"
|
||||
autostart=true
|
||||
autorestart=true
|
||||
user = root
|
||||
startretries=5
|
||||
numprocs=1
|
||||
startsecs=0
|
||||
@@ -18,9 +19,10 @@ stderr_logfile_maxbytes=10MB
|
||||
stdout_logfile=/var/log/supervisor/%(program_name)s_stdout.log
|
||||
stdout_logfile_maxbytes=10MB
|
||||
|
||||
[program:uwsgi_backend]
|
||||
[program:backend]
|
||||
directory=/execute
|
||||
command=uwsgi --http 127.0.0.1:8080 --master --module app:app
|
||||
user = nobody
|
||||
command=python3 app.py
|
||||
stdout_logfile="syslog"
|
||||
stderr_logfile="syslog"
|
||||
startsecs=10
|
||||
@@ -1,2 +1,8 @@
|
||||
flask
|
||||
click==8.1.3
|
||||
colorama==0.4.4
|
||||
Flask==2.1.2
|
||||
itsdangerous==2.1.2
|
||||
Jinja2==3.1.2
|
||||
MarkupSafe==2.1.1
|
||||
Werkzeug==2.1.2
|
||||
uwsgi
|
||||
@@ -0,0 +1,11 @@
|
||||
version: '3.9'
|
||||
|
||||
services:
|
||||
frontend:
|
||||
restart: unless-stopped
|
||||
build: frontend
|
||||
backend:
|
||||
restart: unless-stopped
|
||||
build: backend
|
||||
ports:
|
||||
- 80:80
|
||||
Reference in New Issue
Block a user