Update application to use environment variables and force IPv4
Modify syslog_parser.py to load environment variables from .env file and force IPv4 connection to the database. Update replit.md to reflect recent fixes and workflow changes. Increment version in version.json. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 7a657272-55ba-4a79-9a2e-f1ed9bc7a528 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: 727221f9-ad54-4498-b2e4-e87a951b4308 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/449cf7c4-c97a-45ae-8234-e5c5b8d6a84f/7a657272-55ba-4a79-9a2e-f1ed9bc7a528/c9ITWqD
This commit is contained in:
parent
7b6fc148a5
commit
62c3a2b238
@ -1,5 +1,6 @@
|
|||||||
# Database PostgreSQL
|
# Database PostgreSQL
|
||||||
PGHOST=localhost
|
# IMPORTANTE: Usa 127.0.0.1 invece di localhost per forzare IPv4 (evita problemi con ::1)
|
||||||
|
PGHOST=127.0.0.1
|
||||||
PGPORT=5432
|
PGPORT=5432
|
||||||
PGDATABASE=ids_database
|
PGDATABASE=ids_database
|
||||||
PGUSER=ids_user
|
PGUSER=ids_user
|
||||||
|
|||||||
4
.replit
4
.replit
@ -14,6 +14,10 @@ run = ["npm", "run", "start"]
|
|||||||
localPort = 5000
|
localPort = 5000
|
||||||
externalPort = 80
|
externalPort = 80
|
||||||
|
|
||||||
|
[[ports]]
|
||||||
|
localPort = 42789
|
||||||
|
externalPort = 3000
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
PORT = "5000"
|
PORT = "5000"
|
||||||
|
|
||||||
|
|||||||
@ -183,9 +183,13 @@ class SyslogParser:
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main entry point"""
|
"""Main entry point"""
|
||||||
|
# Carica variabili d'ambiente da .env
|
||||||
|
load_dotenv("/opt/ids/.env")
|
||||||
|
|
||||||
# Configurazione database da environment
|
# Configurazione database da environment
|
||||||
|
# IMPORTANTE: Usa 127.0.0.1 invece di localhost per forzare IPv4
|
||||||
db_config = {
|
db_config = {
|
||||||
'host': os.getenv('PGHOST', 'localhost'),
|
'host': os.getenv('PGHOST', '127.0.0.1'),
|
||||||
'port': os.getenv('PGPORT', '5432'),
|
'port': os.getenv('PGPORT', '5432'),
|
||||||
'database': os.getenv('PGDATABASE', 'ids_database'),
|
'database': os.getenv('PGDATABASE', 'ids_database'),
|
||||||
'user': os.getenv('PGUSER', 'ids_user'),
|
'user': os.getenv('PGUSER', 'ids_user'),
|
||||||
|
|||||||
20
replit.md
20
replit.md
@ -36,11 +36,29 @@ Sistema di rilevamento intrusioni per router MikroTik basato su Machine Learning
|
|||||||
|
|
||||||
## Workflow
|
## Workflow
|
||||||
|
|
||||||
1. **Log Collection**: Router → Syslog → PostgreSQL `network_logs`
|
1. **Log Collection**: Router → Syslog (UDP:514) → RSyslog → syslog_parser.py → PostgreSQL `network_logs`
|
||||||
2. **Training**: Python ML estrae 25 feature → Isolation Forest
|
2. **Training**: Python ML estrae 25 feature → Isolation Forest
|
||||||
3. **Detection**: Analisi real-time → Scoring 0-100 → Classificazione
|
3. **Detection**: Analisi real-time → Scoring 0-100 → Classificazione
|
||||||
4. **Auto-Block**: IP critico (>=80) → API REST → Tutti i router (parallelo)
|
4. **Auto-Block**: IP critico (>=80) → API REST → Tutti i router (parallelo)
|
||||||
|
|
||||||
|
## Fix Recenti (Novembre 2025)
|
||||||
|
|
||||||
|
### PostgreSQL Authentication Fix
|
||||||
|
- **Problema**: Password authentication failed (SCRAM-SHA-256 vs MD5)
|
||||||
|
- **Soluzione**: `deployment/fix_postgresql_auth.sh` configura SCRAM-SHA-256 in pg_hba.conf
|
||||||
|
- **Password encryption**: ALTER SYSTEM SET password_encryption = 'scram-sha-256'
|
||||||
|
- **Utente ricreato**: DROP + CREATE con formato SCRAM corretto
|
||||||
|
|
||||||
|
### IPv4 Force Fix
|
||||||
|
- **Problema**: syslog_parser si connetteva a ::1 (IPv6) invece di 127.0.0.1 (IPv4)
|
||||||
|
- **Soluzione**: PGHOST=127.0.0.1 in .env (NON usare localhost)
|
||||||
|
- **Parser**: load_dotenv() carica .env automaticamente
|
||||||
|
|
||||||
|
### Git Ownership Fix
|
||||||
|
- **Problema**: dubious ownership error in /opt/ids
|
||||||
|
- **Soluzione**: `deployment/fix_git_ownership.sh` aggiunge safe.directory
|
||||||
|
- **Update script**: `deployment/update_from_git.sh` ora esegue git come utente ids
|
||||||
|
|
||||||
## File Importanti
|
## File Importanti
|
||||||
|
|
||||||
### Python ML Backend
|
### Python ML Backend
|
||||||
|
|||||||
10
version.json
10
version.json
@ -1,7 +1,13 @@
|
|||||||
{
|
{
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"lastUpdate": "2025-11-17T16:05:06.972Z",
|
"lastUpdate": "2025-11-17T16:47:34.637Z",
|
||||||
"changelog": [
|
"changelog": [
|
||||||
|
{
|
||||||
|
"version": "1.0.5",
|
||||||
|
"date": "2025-11-17",
|
||||||
|
"type": "patch",
|
||||||
|
"description": "Deployment automatico v1.0.5"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "1.0.4",
|
"version": "1.0.4",
|
||||||
"date": "2025-11-17",
|
"date": "2025-11-17",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user