How ivpn/desktop-app works
• the UI and CLI are clients,
• the daemon is a privileged back-end service,
• external components (VPN engines, DNS resolver, firewall, etc.) and OS subsystems are orchestrated by the daemon.
Main Components (Containers)
• Electron UI (Client)
– Renderer process (Vue.js components, views, styles)
– Main process (Electron, IPC layers, “daemon‐client” module)
• CLI (Client)
– Go binary with commands & flags
– Communicates with daemon via its internal API layer
• Daemon (Server/Service)
– API module (api.go + types) exposing RPC/HTTP over a local socket
– Event Notifier (pushes real-time updates to clients)
– Service Layer (service/*.go orchestrating connect, firewall, DNS, preferences, servers_updater, etc.)
– Protocol Engines (vpn/openvpn, vpn/wireguard, obfsproxy, v2r, kem, ping, splittun)
– OS Helpers (netchange, netinfo, oshelpers platforms, wifiNotifier)
– Launcher & Shell modules (to spawn external binaries/scripts)
• External Tools & OS Subsystems
– OpenVPN, WireGuard, DNSCrypt Proxy, Obfsproxy, v2ray executables
– System firewall APIs (Windows WFP, iptables/macOS PF)
– Network stack, routing table
Relationships & Data Flows
• UI ⇄ Daemon:
– UI main process calls daemon‐client → daemon API over a local socket
– UI renderer ←→ UI main via Electron IPC
– Real-time events (status updates, connection changes) flow from daemon → UI via event notifier
• CLI ⇄ Daemon:
– CLI issues commands (e.g., ivpn connect) → daemon API → daemon service layer → protocol engines → OS
• Daemon → External Tools/OS:
– On “connect,” daemon service spawns OpenVPN or WireGuard subprocess, applies firewall rules via OS Helpers
– Daemon manages DNS via built-in DNS module or spawns DNSCrypt Proxy
– Daemon listens for netchange and wifi events via wifiNotifier and netchange detectors
– Daemon monitors ping and routing via ping module and netinfo
Architectural Patterns & Principles
• Separation of Concerns: UI/CLI vs. core logic vs. OS orchestration
• Modular Design: each service (DNS, firewall, VPN, preferences) in its own package
• Cross-Platform Abstraction: oshelpers and platform‐specific files (suffix _darwin, _linux, _windows)
• Event-Driven Communication: event_notifier pushing updates, clients subscribe via API
• External Process Management: launcher and shell modules spawn/manage external VPN/DNS binaries