How mullvad/win-split-tunnel works
Main Components
• Kernel-mode driver (the core of the system)
• Contains several subsystems: Firewall, Process Management, Eventing, and supporting data structures (Process Registry and Registered Image).
• User Mode Agent
• Though not implemented fully in this repository (only example code is in the ‘testing’ directory), it is critical. It supplies configuration data (list of excluded process paths, tunnel IP addresses, etc.) and listens for events from the driver.
• Windows OS & Networking Subsystems
• Integration with Windows Filtering Platform (WFP) is an essential part of the architecture.
• Interaction with network interfaces, dealing with IP addresses, and handling of socket binds (including redirections for excluded applications).
Components’ Relationships and Interactions
• The user mode agent communicates with the driver through specific IOCTL commands. Illustrate this as a two-way communication channel:
• The agent sends configuration updates (e.g., register/exclude process paths, set IP addresses).
• The driver sends events back (such as process state changes or warnings about potential leaks).
• Internally, the driver’s subsystems interact:
• The Firewall subsystem intercepts and directs network traffic using WFP policies.
• The Process Management subsystem tracks process lifecycle events (arrival/departure) and propagates exclusions.
• The Eventing subsystem ensures asynchronous notifications are sent to the user mode agent.
• Shared data structures like the Process Registry and Registered Image hold state information that is used by various subsystems.
Architectural Patterns and Design Principles
• Modularity – Each subsystem (Firewall, Process Management, Eventing) is encapsulated, with clearly defined responsibilities.
• State Management – The driver must follow a strict state-transitions model from load to active engagement.
• Transactional Updates – Particularly within the firewall subsystem when modifying WFP settings to avoid race conditions.
• Inverted Call Model for Eventing – Events flow asynchronously back to the agent.
• Separation of concerns between kernel-mode operations (which enforce policies) and user mode configuration and monitoring.