feat: upgrade Rust version to 1.85

This commit is contained in:
Kevin Yue committed 2025-11-13 00:13:53 +08:00
1 parent a4e1743691
commit 09cd8ecb18
22 files changed
+865 -938

No files matched your search

+5 -3
View File
@@ -39,11 +39,13 @@ pub fn load_env_vars<T: AsRef<Path>>(env_file: T) -> anyhow::Result<HashMap<Stri
pub fn patch_gui_runtime_env(hidpi: bool) {
// This is to avoid blank screen on some systems
std::env::set_var("WEBKIT_DISABLE_COMPOSITING_MODE", "1");
unsafe { std::env::set_var("WEBKIT_DISABLE_COMPOSITING_MODE", "1") };
if hidpi {
info!("Setting GDK_SCALE=2 and GDK_DPI_SCALE=0.5");
std::env::set_var("GDK_SCALE", "2");
std::env::set_var("GDK_DPI_SCALE", "0.5");
unsafe {
std::env::set_var("GDK_SCALE", "2");
std::env::set_var("GDK_DPI_SCALE", "0.5");
};
}
}
+1 -1
View File
@@ -46,7 +46,7 @@ pub fn fix_openssl_env() -> anyhow::Result<NamedTempFile> {
let openssl_conf_path = openssl_conf.path();
fix_openssl(openssl_conf_path)?;
std::env::set_var("OPENSSL_CONF", openssl_conf_path);
unsafe { std::env::set_var("OPENSSL_CONF", openssl_conf_path) };
Ok(openssl_conf)
}
+3 -3
View File
@@ -31,7 +31,7 @@ pub(crate) struct ConnectOptions {
}
#[link(name = "vpn")]
extern "C" {
unsafe extern "C" {
#[link_name = "vpn_connect"]
fn vpn_connect(options: *const ConnectOptions, callback: extern "C" fn(i32, *mut c_void)) -> c_int;
@@ -47,7 +47,7 @@ pub(crate) fn disconnect() {
unsafe { vpn_disconnect() }
}
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn on_vpn_connected(pipe_fd: i32, vpn: *mut c_void) {
let vpn = unsafe { &*(vpn as *const Vpn) };
vpn.on_connected(pipe_fd);
@@ -56,7 +56,7 @@ extern "C" fn on_vpn_connected(pipe_fd: i32, vpn: *mut c_void) {
// Logger used in the C code.
// level: 0 = error, 1 = info, 2 = debug, 3 = trace
// map the error level log in openconnect to the warning level
#[no_mangle]
#[unsafe(no_mangle)]
extern "C" fn vpn_log(level: i32, message: *const c_char) {
let message = unsafe { std::ffi::CStr::from_ptr(message) };
let message = message.to_str().unwrap_or("Invalid log message");
+6 -6
View File
@@ -241,17 +241,17 @@ impl VpnBuilder {
self
}
fn determine_script(&self) -> Result<String, VpnError> {
fn determine_script(&self) -> Result<&str, VpnError> {
match &self.script {
Some(script) => {
check_executable(script).map_err(|e| VpnError::new(e.to_string()))?;
Ok(script.clone())
Ok(script)
}
None => find_vpnc_script().ok_or_else(|| VpnError::new(String::from("Failed to find vpnc-script"))),
}
}
fn determine_csd_wrapper(&self) -> Result<Option<String>, VpnError> {
fn determine_csd_wrapper(&self) -> Result<Option<&str>, VpnError> {
if !self.hip {
return Ok(None);
}
@@ -259,7 +259,7 @@ impl VpnBuilder {
match &self.csd_wrapper {
Some(csd_wrapper) if !csd_wrapper.is_empty() => {
check_executable(csd_wrapper).map_err(|e| VpnError::new(e.to_string()))?;
Ok(Some(csd_wrapper.clone()))
Ok(Some(csd_wrapper))
}
_ => {
let s = find_csd_wrapper().ok_or_else(|| VpnError::new(String::from("Failed to find csd wrapper")))?;
@@ -269,8 +269,8 @@ impl VpnBuilder {
}
pub fn build(self) -> Result<Vpn, VpnError> {
let script = self.determine_script()?;
let csd_wrapper = self.determine_csd_wrapper()?;
let script = self.determine_script()?.to_owned();
let csd_wrapper = self.determine_csd_wrapper()?.map(|s| s.to_owned());
let user_agent = self.user_agent.unwrap_or_default();
let os = self.os.unwrap_or("linux".to_string());
+5 -5
View File
@@ -25,22 +25,22 @@ const CSD_WRAPPER_LOCATIONS: &[&str] = &[
"/opt/homebrew/opt/openconnect/libexec/openconnect/hipreport.sh",
];
fn find_executable(locations: &[&str]) -> Option<String> {
fn find_executable(locations: &[&'static str]) -> Option<&'static str> {
for location in locations.iter() {
let path = Path::new(location);
if path.is_executable() {
return Some(location.to_string());
return Some(*location);
}
}
None
}
pub fn find_vpnc_script() -> Option<String> {
pub fn find_vpnc_script() -> Option<&'static str> {
find_executable(&VPNC_SCRIPT_LOCATIONS)
}
pub fn find_csd_wrapper() -> Option<String> {
pub fn find_csd_wrapper() -> Option<&'static str> {
find_executable(&CSD_WRAPPER_LOCATIONS)
}
@@ -48,7 +48,7 @@ pub fn find_csd_wrapper() -> Option<String> {
pub fn check_executable(file: &str) -> Result<(), io::Error> {
let path = Path::new(file);
if !path.is_executable() {
if path.exists() && !path.is_executable() {
return Err(io::Error::new(
io::ErrorKind::PermissionDenied,
format!("{} is not executable", file),