Runtime and Process Model¶
SafeMode splits responsibilities across UI thread, worker threads, and a separate mitmproxy process.
Why Multiprocessing for Proxy Engine¶
QtMonitorManager starts mitmproxy in a dedicated process.
Benefits:
- isolate event loop complexity
- fast stop via terminate/kill fallback
- reduce UI lock risk
- independent filter-manager lifecycle in child process
Main Runtime Actors¶
- MainWindow: shell orchestration, settings application, timers.
- MonitorWorker (QThread): drains queue and emits alert signals.
- FilterWorker (QThread): blocking downloads without freezing UI.
- Mitmproxy child process: traffic interception and analysis.
Inter-Process Communication¶
Two queues are used:
url_queue: events and READY signal from child to UI side.control_queue: runtime commands from UI side to child (toggle filters, whitelist updates, reloads).
Start/Stop Contract¶
Start¶
- Spawn process.
- Child loads filters.
- Child opens listen port.
- Child emits READY.
- UI enables system proxy.
Stop¶
- terminate child process.
- force kill if needed.
- disable proxy and update UI state.
Backpressure and Throughput¶
MonitorWorker behavior:
- drains queue when monitoring inactive to prevent memory buildup.
- emits alerts with minimal delay.
- lets UI batching in MonitorPanel handle rendering cadence.
Settings Propagation¶
Settings flow:
- Config panel saves values via config module.
- MainWindow receives settings signal.
- Runtime-relevant values apply immediately (timers, toggles, theme/language, logging).
- Running monitor receives control queue messages when needed.
Safety Defaults¶
- If app closes normally, it attempts proxy disable.
- If proxy toggled OFF manually, dependent services can cascade down.
- Certificate gate prevents silent HTTPS-monitoring false assumptions.