windows: add module to install the wintun.dll by embedding it in the client's exe and then copying it out at runtime (#2843)

Signed-off-by: Reactor Scram <ReactorScram@users.noreply.github.com>
Co-authored-by: Jamil <jamilbk@users.noreply.github.com>
This commit is contained in:
Reactor Scram
2023-12-12 10:28:48 -06:00
committed by GitHub
parent f1e9715d79
commit 5853b13794
2 changed files with 30 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ mod local_webserver;
// Relies on some types from Tauri
#[cfg(target_os = "windows")]
mod settings;
#[cfg(target_os = "windows")]
mod wintun_install;
/// Prevents a problem where changing the args to `gui::run` breaks static analysis on non-Windows targets, where the gui is stubbed out
#[allow(dead_code)]

View File

@@ -0,0 +1,28 @@
//! "Installs" wintun.dll at runtime by copying it into whatever folder the exe is in
pub(crate) struct _DllBytes {
/// Bytes embedded in the client with `include_bytes`
bytes: &'static [u8],
/// Expected SHA256 hash
expected_sha256: &'static str,
}
/// Returns the platform-specific bytes of wintun.dll, or None if we don't support the compiled platform.
pub(crate) fn _get_dll_bytes() -> Option<_DllBytes> {
_get_platform_dll_bytes()
}
#[cfg(target_arch = "x86_64")]
fn _get_platform_dll_bytes() -> Option<_DllBytes> {
// SHA256 e5da8447dc2c320edc0fc52fa01885c103de8c118481f683643cacc3220dafce
Some(_DllBytes {
bytes: include_bytes!("../../wintun/bin/amd64/wintun.dll"),
expected_sha256: "e5da8447dc2c320edc0fc52fa01885c103de8c118481f683643cacc3220dafce",
})
}
#[cfg(target_arch = "aarch64")]
fn _get_platform_dll_bytes() -> Option<&'static [u8]> {
// wintun supports aarch64 but it's not in the Firezone repo yet
None
}