try nfstream
All checks were successful
Build and Deploy MITM Webserver / build (push) Successful in 19s

This commit is contained in:
2026-03-07 18:09:38 +01:00
parent 02f76144fa
commit 3ea07bf1df
8 changed files with 613 additions and 1 deletions

View File

@@ -25,6 +25,13 @@ def _env_float(name: str, default: float) -> float:
return float(value)
def _env_bool(name: str, default: bool) -> bool:
value = os.getenv(name)
if value in (None, ""):
return default
return value.strip().lower() in {"1", "true", "yes", "on"}
@dataclass(frozen=True)
class BackendSettings:
db_dsn: str
@@ -50,6 +57,16 @@ class BackendSettings:
ndpi_max_flows: int
ndpi_flow_ttl_seconds: float
ndpi_cleanup_interval_packets: int
nfstream_enabled: bool
nfstream_promiscuous_mode: bool
nfstream_idle_timeout_seconds: int
nfstream_active_timeout_seconds: int
nfstream_snapshot_length: int
nfstream_n_dissections: int
nfstream_cache_ttl_seconds: float
nfstream_lookup_window_ms: int
nfstream_reader_join_timeout_seconds: float
nfstream_process_stop_timeout_seconds: float
def load_settings() -> BackendSettings:
@@ -80,6 +97,16 @@ def load_settings() -> BackendSettings:
ndpi_max_flows=_env_int("BACKEND_NDPI_MAX_FLOWS", 200_000),
ndpi_flow_ttl_seconds=_env_float("BACKEND_NDPI_FLOW_TTL_SECONDS", 120.0),
ndpi_cleanup_interval_packets=_env_int("BACKEND_NDPI_CLEANUP_INTERVAL_PACKETS", 10_000),
nfstream_enabled=_env_bool("BACKEND_NFSTREAM_ENABLED", True),
nfstream_promiscuous_mode=_env_bool("BACKEND_NFSTREAM_PROMISCUOUS_MODE", True),
nfstream_idle_timeout_seconds=_env_int("BACKEND_NFSTREAM_IDLE_TIMEOUT_SECONDS", 120),
nfstream_active_timeout_seconds=_env_int("BACKEND_NFSTREAM_ACTIVE_TIMEOUT_SECONDS", 1800),
nfstream_snapshot_length=_env_int("BACKEND_NFSTREAM_SNAPSHOT_LENGTH", 1536),
nfstream_n_dissections=_env_int("BACKEND_NFSTREAM_N_DISSECTIONS", 20),
nfstream_cache_ttl_seconds=_env_float("BACKEND_NFSTREAM_CACHE_TTL_SECONDS", 10.0),
nfstream_lookup_window_ms=_env_int("BACKEND_NFSTREAM_LOOKUP_WINDOW_MS", 5_000),
nfstream_reader_join_timeout_seconds=_env_float("BACKEND_NFSTREAM_READER_JOIN_TIMEOUT_SECONDS", 2.0),
nfstream_process_stop_timeout_seconds=_env_float("BACKEND_NFSTREAM_PROCESS_STOP_TIMEOUT_SECONDS", 3.0),
)