diff --git a/rust/windows-client/src-tauri/src/client.rs b/rust/windows-client/src-tauri/src/client.rs index 0b6c38499..623d17f87 100644 --- a/rust/windows-client/src-tauri/src/client.rs +++ b/rust/windows-client/src-tauri/src/client.rs @@ -44,6 +44,26 @@ pub(crate) struct AppLocalDataDir(std::path::PathBuf); // const CREATE_NO_WINDOW: u32 = 0x08000000; +/// The program's entry point, equivalent to `main` +/// +/// When a user runs the Windows client normally without admin permissions, this will happen: +/// +/// 1. The exe runs with ``, blank arguments +/// 2. We call `elevation::check` and find out we don't have permission to open a wintun adapter +/// 3. We spawn powershell's `Start-Process` cmdlet with `RunAs` to launch our `elevated` subcommand with admin permissions +/// 4. The original un-elevated process from Step 1 exits +/// 5. The exe runs with `elevated`, which won't recursively try to elevate itself if elevation failed +/// 6. The elevated process from Step 5 enters the GUI module and spawns a new process for crash handling +/// 7. That crash handler process starts with `crash-handler-server`. Instead of running the GUI, it enters the `crash_handling` module and becomes a crash server. +/// 8. The GUI process from Step 6 connects to the crash server as a client +/// 9. The GUI process registers itself as a named pipe server for deep links +/// 10. The GUI process registers the exe to receive deep links. +/// 11. When a web browser gets a deep link for authentication, Windows calls the exe with `open-deep-link` and the URL. This process connects to the pipe server inside the GUI process (Step 5), sends the URL to the GUI, then exits. +/// 12. The GUI process (Step 5) receives the deep link URL. +/// 13. (TBD - connlib may run in a subprocess in the near future ) +/// +/// In total there are 4 subcommands (non-elevated, elevated GUI, crash handler, and deep link process) +/// In steady state, the only processes running will be the GUI and the crash handler. pub(crate) fn run() -> Result<()> { std::panic::set_hook(Box::new(tracing_panic::panic_hook)); let cli = cli::Cli::parse();