mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
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:
@@ -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)]
|
||||
|
||||
28
rust/windows-client/src-tauri/src/wintun_install.rs
Executable file
28
rust/windows-client/src-tauri/src/wintun_install.rs
Executable 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
|
||||
}
|
||||
Reference in New Issue
Block a user