Backport vendored openconnect and HIP flow

This commit is contained in:
Kevin Yue committed 2026-04-18 20:21:10 +08:00
1 parent 51c55376e8
commit f754a7f3c7
30 files changed
+2634 -23

No files matched your search

+5
View File
@@ -31,6 +31,8 @@ serde_urlencoded.workspace = true
md5.workspace = true
sha256.workspace = true
which.workspace = true
machine-uid = "0.5"
uuid = { version = "1", features = ["v5"] }
# Pin the version of home because the latest version requires Rust 1.81
home = "=0.5.9"
@@ -40,6 +42,9 @@ clap = { workspace = true, optional = true }
open = { version = "5", optional = true }
webbrowser = { version = "1", optional = true }
[target.'cfg(any(target_os="macos", target_os="windows"))'.dependencies]
os_info = { version = "3", default-features = false }
[features]
tauri = ["dep:tauri"]
clap = ["dep:clap"]
+99
View File
@@ -0,0 +1,99 @@
use std::sync::OnceLock;
const DEFAULT_MACOS_VERSION: &str = "13.4.0";
#[cfg(not(target_os = "linux"))]
const DEFAULT_LINUX_DISTRO: &str = "Ubuntu 24.04.3 LTS";
#[cfg(not(target_os = "windows"))]
const DEFAULT_WINDOWS_DISTRO: &str = "Windows 11 Pro";
const DEFAULT_WINDOWS_VERSION: &str = "10.0.22631.0";
const DEFAULT_MACHINE_ID: &str = "DEADBEEF-DEAD-BEEF-DEAD-BEEFDEADBEEF";
static MACHINE_ID: OnceLock<&'static str> = OnceLock::new();
static MACOS_VERSION: OnceLock<&'static str> = OnceLock::new();
static MACOS_OS_STRING: OnceLock<String> = OnceLock::new();
static LINUX_OS_STRING: OnceLock<String> = OnceLock::new();
static WINDOWS_VERSION: OnceLock<&'static str> = OnceLock::new();
static WINDOWS_OS_STRING: OnceLock<String> = OnceLock::new();
pub fn get_macos_version() -> &'static str {
MACOS_VERSION.get_or_init(|| {
#[cfg(target_os = "macos")]
{
match os_info::get().version() {
os_info::Version::Unknown => DEFAULT_MACOS_VERSION,
version => Box::leak(version.to_string().into_boxed_str()),
}
}
#[cfg(not(target_os = "macos"))]
DEFAULT_MACOS_VERSION
})
}
pub fn get_macos_os_string() -> &'static str {
MACOS_OS_STRING.get_or_init(|| format!("Apple Mac OS X {}", get_macos_version()))
}
pub fn get_linux_os_string() -> &'static str {
LINUX_OS_STRING.get_or_init(|| {
#[cfg(target_os = "linux")]
{
format!("Linux {}", whoami::distro())
}
#[cfg(not(target_os = "linux"))]
{
format!("Linux {}", DEFAULT_LINUX_DISTRO)
}
})
}
pub fn get_windows_version() -> &'static str {
WINDOWS_VERSION.get_or_init(|| {
#[cfg(target_os = "windows")]
{
match os_info::get().version() {
os_info::Version::Unknown => DEFAULT_WINDOWS_VERSION,
version => Box::leak(format!("{}.0", version).into_boxed_str()),
}
}
#[cfg(not(target_os = "windows"))]
DEFAULT_WINDOWS_VERSION
})
}
pub fn get_windows_os_string() -> &'static str {
WINDOWS_OS_STRING.get_or_init(|| {
#[cfg(target_os = "windows")]
{
let edition = os_info::get()
.edition()
.map(|edition| edition.to_string())
.unwrap_or_else(|| whoami::distro());
format!("Microsoft {} , 64-bit", edition)
}
#[cfg(not(target_os = "windows"))]
{
format!("Microsoft {} , 64-bit", DEFAULT_WINDOWS_DISTRO)
}
})
}
pub fn get_machine_id() -> &'static str {
MACHINE_ID.get_or_init(|| {
machine_uid::get()
.map(|id| Box::leak(id.to_string().into_boxed_str()) as &'static str)
.unwrap_or(DEFAULT_MACHINE_ID)
})
}
pub fn derive_uuid(seeds: &[&str]) -> String {
use uuid::Uuid;
let namespace = Uuid::NAMESPACE_DNS;
let name = format!("{}-{}", get_machine_id(), seeds.join("-"));
Uuid::new_v5(&namespace, name.as_bytes()).hyphenated().to_string()
}
+1
View File
@@ -5,6 +5,7 @@ pub mod checksum;
pub mod crypto;
pub mod endpoint;
pub mod env_file;
pub mod host_utils;
pub mod lock_file;
pub mod openssl;
pub mod redact;