Skip to content

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

  1. Spawn process.
  2. Child loads filters.
  3. Child opens listen port.
  4. Child emits READY.
  5. UI enables system proxy.

Stop

  1. terminate child process.
  2. force kill if needed.
  3. 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:

  1. Config panel saves values via config module.
  2. MainWindow receives settings signal.
  3. Runtime-relevant values apply immediately (timers, toggles, theme/language, logging).
  4. 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.