add config
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 10s

This commit is contained in:
2026-03-07 10:44:45 +01:00
parent 8e6c759cb8
commit c19fab4d32
8 changed files with 140 additions and 21 deletions

View File

@@ -12,6 +12,7 @@ from typing import Any, Dict, List, Optional
import src.shared_objects as shared_objects
from src.Models.etherType import EtherTypeEnum, ethertype_from_int
from src.Models.ip_protocol import protocol_from_number
from src.config import settings
from src.utilities.packet_identity import build_packet_uid
logger = logging.getLogger("packet_tracker")
@@ -41,7 +42,7 @@ class PacketTracker:
def stop(self) -> None:
self._stop_event.set()
self._thread.join(timeout=2)
self._thread.join(timeout=settings.packet_tracker_stop_join_timeout_seconds)
def observe_packet(self, pkt_info: Dict[str, Any]) -> str:
"""Merge parsed packet information into a pending packet entry."""
@@ -221,7 +222,7 @@ class PacketTracker:
if not src_ip or not dst_ip or protocol_raw is None:
return None
cutoff = time.time() - 1.0
cutoff = time.time() - settings.packet_tracker_reject_correlation_window_seconds
for entry in self._entries.values():
payload = entry["payload"]
if entry["last_observed_at"] < cutoff:
@@ -292,7 +293,7 @@ class PacketTracker:
try:
fut = asyncio.run_coroutine_threadsafe(web_db.upsert_packet(payload), web_loop)
fut.result(timeout=2.0)
fut.result(timeout=settings.packet_tracker_persist_timeout_seconds)
with self._lock:
current = self._entries.get(entry["packet_uid"])
if current is not None:
@@ -303,4 +304,8 @@ class PacketTracker:
logger.exception("Failed to persist packet %s", entry["packet_uid"])
packet_tracker = PacketTracker()
packet_tracker = PacketTracker(
finalize_delay_seconds=settings.packet_tracker_finalize_delay_seconds,
retention_seconds=settings.packet_tracker_retention_seconds,
min_flush_interval_seconds=settings.packet_tracker_min_flush_interval_seconds,
)