fix hostname for mac

This commit is contained in:
rustdesk 2024-03-11 01:36:43 +08:00
parent c0e5e78d2b
commit f644053811

View File

@ -865,7 +865,16 @@ pub fn username() -> String {
#[inline]
pub fn hostname() -> String {
#[cfg(not(any(target_os = "android", target_os = "ios")))]
return whoami::hostname();
{
#[allow(unused_mut)]
let mut name = whoami::hostname();
// some time, there is .local, some time not, so remove it for osx
#[cfg(target_os = "macos")]
if name.ends_with(".local") {
name = name.trim_end_matches(".local").to_owned();
}
name
}
#[cfg(any(target_os = "android", target_os = "ios"))]
return DEVICE_NAME.lock().unwrap().clone();
}